1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// This file was generated by gir (https://github.com/gtk-rs/gir)
// DO NOT EDIT

use crate::{ConstraintType,ConstraintVerb,InterestMatch,InterestMatchFlags,Properties};
use glib::{prelude::*,translate::*};

glib::wrapper! {
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct ObjectInterest(Shared<ffi::WpObjectInterest>);

    match fn {
        ref => |ptr| ffi::wp_object_interest_ref(ptr),
        unref => |ptr| ffi::wp_object_interest_unref(ptr),
        type_ => || ffi::wp_object_interest_get_type(),
    }
}

impl ObjectInterest {
    #[doc(alias = "wp_object_interest_new_type")]
    #[doc(alias = "new_type")]
    pub fn new(gtype: glib::types::Type) -> ObjectInterest {
        unsafe {
            from_glib_full(ffi::wp_object_interest_new_type(gtype.into_glib()))
        }
    }

    #[doc(alias = "wp_object_interest_add_constraint")]
    pub fn add_constraint(&self, type_: ConstraintType, subject: &str, verb: ConstraintVerb, value: Option<&glib::Variant>) {
        unsafe {
            ffi::wp_object_interest_add_constraint(self.to_glib_none().0, type_.into_glib(), subject.to_glib_none().0, verb.into_glib(), value.to_glib_none().0);
        }
    }

    #[doc(alias = "wp_object_interest_matches_full")]
    #[doc(alias = "matches_full")]
    pub fn matches(&self, flags: InterestMatchFlags, object_type: glib::types::Type, object: Option<&impl IsA<glib::Object>>, pw_props: Option<&Properties>, pw_global_props: Option<&Properties>) -> InterestMatch {
        unsafe {
            from_glib(ffi::wp_object_interest_matches_full(self.to_glib_none().0, flags.into_glib(), object_type.into_glib(), object.map(|p| p.as_ref()).to_glib_none().0, pw_props.to_glib_none().0, pw_global_props.to_glib_none().0))
        }
    }

    #[doc(alias = "wp_object_interest_validate")]
    pub fn validate(&self) -> Result<(), glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let is_ok = ffi::wp_object_interest_validate(self.to_glib_none().0, &mut error);
            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
            if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
        }
    }
}