nm_rs/auto/
setting_hsr.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::*};
8#[cfg(feature = "v1_46")]
9#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
10use glib::{signal::{connect_raw, SignalHandlerId},translate::*};
11#[cfg(feature = "v1_46")]
12#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
13use std::{boxed::Box as Box_};
14
15glib::wrapper! {
16    /// HSR/PRP Settings
17    ///
18    /// ## Properties
19    ///
20    ///
21    /// #### `multicast-spec`
22    ///  The last byte of supervision address.
23    ///
24    /// Readable | Writeable
25    ///
26    ///
27    /// #### `port1`
28    ///  The port1 interface name of the HSR. This property is mandatory.
29    ///
30    /// Readable | Writeable
31    ///
32    ///
33    /// #### `port2`
34    ///  The port2 interface name of the HSR. This property is mandatory.
35    ///
36    /// Readable | Writeable
37    ///
38    ///
39    /// #### `prp`
40    ///  The protocol used by the interface, whether it is PRP or HSR.
41    ///
42    /// Readable | Writeable
43    /// <details><summary><h4>Setting</h4></summary>
44    ///
45    ///
46    /// #### `name`
47    ///  The setting's name, which uniquely identifies the setting within the
48    /// connection.  Each setting type has a name unique to that type, for
49    /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
50    ///
51    /// Readable
52    /// </details>
53    ///
54    /// # Implements
55    ///
56    /// [`SettingExt`][trait@crate::prelude::SettingExt]
57    #[doc(alias = "NMSettingHsr")]
58    pub struct SettingHsr(Object<ffi::NMSettingHsr, ffi::NMSettingHsrClass>) @extends Setting;
59
60    match fn {
61        type_ => || ffi::nm_setting_hsr_get_type(),
62    }
63}
64
65impl SettingHsr {
66    /// Creates a new #NMSettingHsr object with default values.
67    ///
68    /// # Returns
69    ///
70    /// the new empty #NMSettingHsr object
71    #[cfg(feature = "v1_46")]
72    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
73    #[doc(alias = "nm_setting_hsr_new")]
74    pub fn new() -> SettingHsr {
75        assert_initialized_main_thread!();
76        unsafe {
77            Setting::from_glib_full(ffi::nm_setting_hsr_new()).unsafe_cast()
78        }
79    }
80
81            // rustdoc-stripper-ignore-next
82            /// Creates a new builder-pattern struct instance to construct [`SettingHsr`] objects.
83            ///
84            /// This method returns an instance of [`SettingHsrBuilder`](crate::builders::SettingHsrBuilder) which can be used to create [`SettingHsr`] objects.
85            pub fn builder() -> SettingHsrBuilder {
86                SettingHsrBuilder::new()
87            }
88        
89
90    ///
91    /// # Returns
92    ///
93    /// the #NMSettingHsr:multicast_spec property of the setting
94    #[cfg(feature = "v1_46")]
95    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
96    #[doc(alias = "nm_setting_hsr_get_multicast_spec")]
97    #[doc(alias = "get_multicast_spec")]
98    #[doc(alias = "multicast-spec")]
99    pub fn multicast_spec(&self) -> u32 {
100        unsafe {
101            ffi::nm_setting_hsr_get_multicast_spec(self.to_glib_none().0)
102        }
103    }
104
105    ///
106    /// # Returns
107    ///
108    /// the #NMSettingHsr:port1 property of the setting
109    #[cfg(feature = "v1_46")]
110    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
111    #[doc(alias = "nm_setting_hsr_get_port1")]
112    #[doc(alias = "get_port1")]
113    pub fn port1(&self) -> glib::GString {
114        unsafe {
115            from_glib_none(ffi::nm_setting_hsr_get_port1(self.to_glib_none().0))
116        }
117    }
118
119    ///
120    /// # Returns
121    ///
122    /// the #NMSettingHsr:port2 property of the setting
123    #[cfg(feature = "v1_46")]
124    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
125    #[doc(alias = "nm_setting_hsr_get_port2")]
126    #[doc(alias = "get_port2")]
127    pub fn port2(&self) -> glib::GString {
128        unsafe {
129            from_glib_none(ffi::nm_setting_hsr_get_port2(self.to_glib_none().0))
130        }
131    }
132
133    ///
134    /// # Returns
135    ///
136    /// the #NMSettingHsr:prp property of the setting
137    #[cfg(feature = "v1_46")]
138    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
139    #[doc(alias = "nm_setting_hsr_get_prp")]
140    #[doc(alias = "get_prp")]
141    #[doc(alias = "prp")]
142    pub fn is_prp(&self) -> bool {
143        unsafe {
144            from_glib(ffi::nm_setting_hsr_get_prp(self.to_glib_none().0))
145        }
146    }
147
148    /// The last byte of supervision address.
149    #[cfg(feature = "v1_46")]
150    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
151    #[doc(alias = "multicast-spec")]
152    pub fn set_multicast_spec(&self, multicast_spec: u32) {
153        ObjectExt::set_property(self,"multicast-spec", multicast_spec)
154    }
155
156    /// The port1 interface name of the HSR. This property is mandatory.
157    #[cfg(feature = "v1_46")]
158    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
159    pub fn set_port1(&self, port1: Option<&str>) {
160        ObjectExt::set_property(self,"port1", port1)
161    }
162
163    /// The port2 interface name of the HSR. This property is mandatory.
164    #[cfg(feature = "v1_46")]
165    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
166    pub fn set_port2(&self, port2: Option<&str>) {
167        ObjectExt::set_property(self,"port2", port2)
168    }
169
170    /// The protocol used by the interface, whether it is PRP or HSR.
171    #[cfg(feature = "v1_46")]
172    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
173    pub fn set_prp(&self, prp: bool) {
174        ObjectExt::set_property(self,"prp", prp)
175    }
176
177    #[cfg(feature = "v1_46")]
178    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
179    #[doc(alias = "multicast-spec")]
180    pub fn connect_multicast_spec_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
181        unsafe extern "C" fn notify_multicast_spec_trampoline<F: Fn(&SettingHsr) + 'static>(this: *mut ffi::NMSettingHsr, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
182            let f: &F = &*(f as *const F);
183            f(&from_glib_borrow(this))
184        }
185        unsafe {
186            let f: Box_<F> = Box_::new(f);
187            connect_raw(self.as_ptr() as *mut _, c"notify::multicast-spec".as_ptr() as *const _,
188                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_multicast_spec_trampoline::<F> as *const ())), Box_::into_raw(f))
189        }
190    }
191
192    #[cfg(feature = "v1_46")]
193    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
194    #[doc(alias = "port1")]
195    pub fn connect_port1_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
196        unsafe extern "C" fn notify_port1_trampoline<F: Fn(&SettingHsr) + 'static>(this: *mut ffi::NMSettingHsr, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
197            let f: &F = &*(f as *const F);
198            f(&from_glib_borrow(this))
199        }
200        unsafe {
201            let f: Box_<F> = Box_::new(f);
202            connect_raw(self.as_ptr() as *mut _, c"notify::port1".as_ptr() as *const _,
203                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_port1_trampoline::<F> as *const ())), Box_::into_raw(f))
204        }
205    }
206
207    #[cfg(feature = "v1_46")]
208    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
209    #[doc(alias = "port2")]
210    pub fn connect_port2_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
211        unsafe extern "C" fn notify_port2_trampoline<F: Fn(&SettingHsr) + 'static>(this: *mut ffi::NMSettingHsr, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
212            let f: &F = &*(f as *const F);
213            f(&from_glib_borrow(this))
214        }
215        unsafe {
216            let f: Box_<F> = Box_::new(f);
217            connect_raw(self.as_ptr() as *mut _, c"notify::port2".as_ptr() as *const _,
218                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_port2_trampoline::<F> as *const ())), Box_::into_raw(f))
219        }
220    }
221
222    #[cfg(feature = "v1_46")]
223    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
224    #[doc(alias = "prp")]
225    pub fn connect_prp_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
226        unsafe extern "C" fn notify_prp_trampoline<F: Fn(&SettingHsr) + 'static>(this: *mut ffi::NMSettingHsr, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
227            let f: &F = &*(f as *const F);
228            f(&from_glib_borrow(this))
229        }
230        unsafe {
231            let f: Box_<F> = Box_::new(f);
232            connect_raw(self.as_ptr() as *mut _, c"notify::prp".as_ptr() as *const _,
233                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_prp_trampoline::<F> as *const ())), Box_::into_raw(f))
234        }
235    }
236}
237
238#[cfg(feature = "v1_46")]
239#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
240impl Default for SettingHsr {
241                     fn default() -> Self {
242                         Self::new()
243                     }
244                 }
245
246// rustdoc-stripper-ignore-next
247        /// A [builder-pattern] type to construct [`SettingHsr`] objects.
248        ///
249        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
250#[must_use = "The builder must be built to be used"]
251pub struct SettingHsrBuilder {
252            builder: glib::object::ObjectBuilder<'static, SettingHsr>,
253        }
254
255        impl SettingHsrBuilder {
256        fn new() -> Self {
257            Self { builder: glib::object::Object::builder() }
258        }
259
260                            /// The last byte of supervision address.
261                            #[cfg(feature = "v1_46")]
262    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
263    pub fn multicast_spec(self, multicast_spec: u32) -> Self {
264                            Self { builder: self.builder.property("multicast-spec", multicast_spec), }
265                        }
266
267                            /// The port1 interface name of the HSR. This property is mandatory.
268                            #[cfg(feature = "v1_46")]
269    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
270    pub fn port1(self, port1: impl Into<glib::GString>) -> Self {
271                            Self { builder: self.builder.property("port1", port1.into()), }
272                        }
273
274                            /// The port2 interface name of the HSR. This property is mandatory.
275                            #[cfg(feature = "v1_46")]
276    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
277    pub fn port2(self, port2: impl Into<glib::GString>) -> Self {
278                            Self { builder: self.builder.property("port2", port2.into()), }
279                        }
280
281                            /// The protocol used by the interface, whether it is PRP or HSR.
282                            #[cfg(feature = "v1_46")]
283    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
284    pub fn prp(self, prp: bool) -> Self {
285                            Self { builder: self.builder.property("prp", prp), }
286                        }
287
288    // rustdoc-stripper-ignore-next
289    /// Build the [`SettingHsr`].
290    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
291    pub fn build(self) -> SettingHsr {
292assert_initialized_main_thread!();
293    self.builder.build() }
294}