Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for enum fields #79

Merged
merged 1 commit into from
Jun 2, 2023
Merged

Conversation

ohadravid
Copy link
Owner

@ohadravid ohadravid commented May 26, 2023

This PR makes it possible to have fields which are enums containing other WMI objects, like so:

#[derive(Deserialize, Debug)]
struct Win32_Process {}

#[derive(Deserialize, Debug)]
struct Win32_Thread {}

#[derive(Deserialize, Debug)]
enum Instance {
    #[serde(rename = "Win32_Process")]
    Process(Win32_Process),
    #[serde(rename = "Win32_Thread")]
    Thread(Win32_Thread),
}

#[derive(Deserialize, Debug)]
struct __InstanceCreationEvent {
    TargetInstance: Instance,
}

let mut filters_process = HashMap::new();

filters_process.insert(
    "TargetInstance".to_owned(),
    FilterValue::is_a::<Win32_Process>().unwrap(),
);

let mut instances_iter = wmi_con
    .filtered_notification::<__InstanceCreationEvent>(
        &filters_process,
        Some(Duration::from_secs(1)),
    )
    .unwrap();

@ohadravid ohadravid changed the title Added support for enum fields Add support for enum fields May 26, 2023
@ohadravid ohadravid merged commit 15c64b4 into main Jun 2, 2023
@ohadravid ohadravid deleted the add-support-for-enum-field branch June 2, 2023 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant