nm_rs/auto/
setting_ovs_other_config.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir
3// from gtk-girs (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{ffi,Setting};
7use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
8use std::{boxed::Box as Box_};
9
10glib::wrapper! {
11    /// OVS Other Config Settings
12    ///
13    /// ## Properties
14    ///
15    ///
16    /// #### `data`
17    ///  A dictionary of key/value pairs with other_config settings for OVS.
18    /// See also "other_config" in the "ovs-vswitchd.conf.db" manual for the keys
19    /// that OVS supports.
20    ///
21    /// Readable | Writeable
22    /// <details><summary><h4>Setting</h4></summary>
23    ///
24    ///
25    /// #### `name`
26    ///  The setting's name, which uniquely identifies the setting within the
27    /// connection.  Each setting type has a name unique to that type, for
28    /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
29    ///
30    /// Readable
31    /// </details>
32    ///
33    /// # Implements
34    ///
35    /// [`SettingExt`][trait@crate::prelude::SettingExt]
36    #[doc(alias = "NMSettingOvsOtherConfig")]
37    pub struct SettingOvsOtherConfig(Object<ffi::NMSettingOvsOtherConfig, ffi::NMSettingOvsOtherConfigClass>) @extends Setting;
38
39    match fn {
40        type_ => || ffi::nm_setting_ovs_other_config_get_type(),
41    }
42}
43
44impl SettingOvsOtherConfig {
45    /// Creates a new #NMSettingOvsOtherConfig object with default values.
46    ///
47    /// # Returns
48    ///
49    /// the new empty
50    /// #NMSettingOvsOtherConfig object
51    #[doc(alias = "nm_setting_ovs_other_config_new")]
52    pub fn new() -> SettingOvsOtherConfig {
53        assert_initialized_main_thread!();
54        unsafe {
55            from_glib_full(ffi::nm_setting_ovs_other_config_new())
56        }
57    }
58
59            // rustdoc-stripper-ignore-next
60            /// Creates a new builder-pattern struct instance to construct [`SettingOvsOtherConfig`] objects.
61            ///
62            /// This method returns an instance of [`SettingOvsOtherConfigBuilder`](crate::builders::SettingOvsOtherConfigBuilder) which can be used to create [`SettingOvsOtherConfig`] objects.
63            pub fn builder() -> SettingOvsOtherConfigBuilder {
64                SettingOvsOtherConfigBuilder::new()
65            }
66        
67
68    /// ## `key`
69    /// the other-config to lookup
70    ///
71    /// # Returns
72    ///
73    /// the value associated with @key or [`None`] if no such
74    ///   value exists.
75    #[doc(alias = "nm_setting_ovs_other_config_get_data")]
76    #[doc(alias = "get_data")]
77    pub fn data(&self, key: &str) -> glib::GString {
78        unsafe {
79            from_glib_none(ffi::nm_setting_ovs_other_config_get_data(self.to_glib_none().0, key.to_glib_none().0))
80        }
81    }
82
83    ///
84    /// # Returns
85    ///
86    /// a
87    ///   [`None`]-terminated array containing each key from the table.
88    #[doc(alias = "nm_setting_ovs_other_config_get_data_keys")]
89    #[doc(alias = "get_data_keys")]
90    pub fn data_keys(&self) -> Vec<glib::GString> {
91        unsafe {
92            let mut out_len = std::mem::MaybeUninit::uninit();
93            let ret = FromGlibContainer::from_glib_none_num(ffi::nm_setting_ovs_other_config_get_data_keys(self.to_glib_none().0, out_len.as_mut_ptr()), out_len.assume_init() as _);
94            ret
95        }
96    }
97
98    /// ## `key`
99    /// the key to set
100    /// ## `val`
101    /// the value to set or [`None`] to clear a key.
102    #[doc(alias = "nm_setting_ovs_other_config_set_data")]
103    #[doc(alias = "data")]
104    pub fn set_data(&self, key: &str, val: Option<&str>) {
105        unsafe {
106            ffi::nm_setting_ovs_other_config_set_data(self.to_glib_none().0, key.to_glib_none().0, val.to_glib_none().0);
107        }
108    }
109
110    #[cfg(feature = "v1_42")]
111    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
112    #[doc(alias = "data")]
113    pub fn connect_data_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
114        unsafe extern "C" fn notify_data_trampoline<F: Fn(&SettingOvsOtherConfig) + 'static>(this: *mut ffi::NMSettingOvsOtherConfig, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
115            let f: &F = &*(f as *const F);
116            f(&from_glib_borrow(this))
117        }
118        unsafe {
119            let f: Box_<F> = Box_::new(f);
120            connect_raw(self.as_ptr() as *mut _, c"notify::data".as_ptr() as *const _,
121                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_data_trampoline::<F> as *const ())), Box_::into_raw(f))
122        }
123    }
124}
125
126#[cfg(feature = "v1_42")]
127#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
128impl Default for SettingOvsOtherConfig {
129                     fn default() -> Self {
130                         Self::new()
131                     }
132                 }
133
134// rustdoc-stripper-ignore-next
135        /// A [builder-pattern] type to construct [`SettingOvsOtherConfig`] objects.
136        ///
137        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
138#[must_use = "The builder must be built to be used"]
139pub struct SettingOvsOtherConfigBuilder {
140            builder: glib::object::ObjectBuilder<'static, SettingOvsOtherConfig>,
141        }
142
143        impl SettingOvsOtherConfigBuilder {
144        fn new() -> Self {
145            Self { builder: glib::object::Object::builder() }
146        }
147
148                        //    #[cfg(feature = "v1_42")]
149    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
150    //pub fn data(self, data: /*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }) -> Self {
151                        //    Self { builder: self.builder.property("data", data), }
152                        //}
153
154    // rustdoc-stripper-ignore-next
155    /// Build the [`SettingOvsOtherConfig`].
156    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
157    pub fn build(self) -> SettingOvsOtherConfig {
158assert_initialized_main_thread!();
159    self.builder.build() }
160}