nm_rs/auto/
bridge_vlan.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};
7#[cfg(feature = "v1_18")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
9use glib::{translate::*};
10
11glib::wrapper! {
12    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
13    pub struct BridgeVlan(Shared<ffi::NMBridgeVlan>);
14
15    match fn {
16        ref => |ptr| ffi::nm_bridge_vlan_ref(ptr),
17        unref => |ptr| ffi::nm_bridge_vlan_unref(ptr),
18        type_ => || ffi::nm_bridge_vlan_get_type(),
19    }
20}
21
22impl BridgeVlan {
23    /// Creates a new #NMBridgeVlan object for the given VLAN id range.
24    /// Setting @vid_end to 0 is equivalent to setting it to @vid_start
25    /// and creates a single-id VLAN.
26    ///
27    /// Since 1.42, ref-counting of #NMBridgeVlan is thread-safe.
28    /// ## `vid_start`
29    /// the start VLAN id, must be between 1 and 4094.
30    /// ## `vid_end`
31    /// the end VLAN id, must be 0 or between @vid_start and 4094.
32    ///
33    /// # Returns
34    ///
35    /// the new #NMBridgeVlan object.
36    #[cfg(feature = "v1_18")]
37    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
38    #[doc(alias = "nm_bridge_vlan_new")]
39    pub fn new(vid_start: u16, vid_end: u16) -> BridgeVlan {
40        assert_initialized_main_thread!();
41        unsafe {
42            from_glib_full(ffi::nm_bridge_vlan_new(vid_start, vid_end))
43        }
44    }
45
46    /// Compare two bridge VLAN objects.
47    /// ## `b`
48    /// another #NMBridgeVlan
49    ///
50    /// # Returns
51    ///
52    /// zero of the two instances are equivalent or
53    ///   a non-zero integer otherwise. This defines a total ordering
54    ///   over the VLANs. Whether a VLAN is sealed or not does not
55    ///   affect the comparison.
56    #[cfg(feature = "v1_18")]
57    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
58    #[doc(alias = "nm_bridge_vlan_cmp")]
59    pub fn cmp(&self, b: &BridgeVlan) -> i32 {
60        unsafe {
61            ffi::nm_bridge_vlan_cmp(self.to_glib_none().0, b.to_glib_none().0)
62        }
63    }
64
65    /// Gets the VLAN id range.
66    ///
67    /// # Returns
68    ///
69    /// [`true`] is the VLAN specifies a range, [`false`] if it is
70    /// a single-id VLAN.
71    ///
72    /// ## `vid_start`
73    /// location to store the VLAN id range start.
74    ///
75    /// ## `vid_end`
76    /// location to store the VLAN id range end
77    #[cfg(feature = "v1_18")]
78    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
79    #[doc(alias = "nm_bridge_vlan_get_vid_range")]
80    #[doc(alias = "get_vid_range")]
81    pub fn vid_range(&self) -> Option<(u16, u16)> {
82        unsafe {
83            let mut vid_start = std::mem::MaybeUninit::uninit();
84            let mut vid_end = std::mem::MaybeUninit::uninit();
85            let ret = from_glib(ffi::nm_bridge_vlan_get_vid_range(self.to_glib_none().0, vid_start.as_mut_ptr(), vid_end.as_mut_ptr()));
86            if ret { Some((vid_start.assume_init(), vid_end.assume_init())) } else { None }
87        }
88    }
89
90    /// Returns whether the VLAN is the PVID for the port.
91    ///
92    /// # Returns
93    ///
94    /// [`true`] if the VLAN is the PVID
95    #[cfg(feature = "v1_18")]
96    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
97    #[doc(alias = "nm_bridge_vlan_is_pvid")]
98    pub fn is_pvid(&self) -> bool {
99        unsafe {
100            from_glib(ffi::nm_bridge_vlan_is_pvid(self.to_glib_none().0))
101        }
102    }
103
104    ///
105    /// # Returns
106    ///
107    /// whether @self_ is sealed or not.
108    #[cfg(feature = "v1_18")]
109    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
110    #[doc(alias = "nm_bridge_vlan_is_sealed")]
111    pub fn is_sealed(&self) -> bool {
112        unsafe {
113            from_glib(ffi::nm_bridge_vlan_is_sealed(self.to_glib_none().0))
114        }
115    }
116
117    /// Returns whether the VLAN is untagged.
118    ///
119    /// # Returns
120    ///
121    /// [`true`] if the VLAN is untagged, [`false`] otherwise
122    #[cfg(feature = "v1_18")]
123    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
124    #[doc(alias = "nm_bridge_vlan_is_untagged")]
125    pub fn is_untagged(&self) -> bool {
126        unsafe {
127            from_glib(ffi::nm_bridge_vlan_is_untagged(self.to_glib_none().0))
128        }
129    }
130
131    ///
132    /// # Returns
133    ///
134    /// a clone of @self. This instance
135    ///   is always unsealed.
136    #[cfg(feature = "v1_18")]
137    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
138    #[doc(alias = "nm_bridge_vlan_new_clone")]
139#[must_use]
140    pub fn new_clone(&self) -> BridgeVlan {
141        unsafe {
142            from_glib_full(ffi::nm_bridge_vlan_new_clone(self.to_glib_none().0))
143        }
144    }
145
146    /// Seal the #NMBridgeVlan instance. Afterwards, it is a bug
147    /// to call all functions that modify the instance (except ref/unref).
148    /// A sealed instance cannot be unsealed again, but you can create
149    /// an unsealed copy with nm_bridge_vlan_new_clone().
150    #[cfg(feature = "v1_18")]
151    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
152    #[doc(alias = "nm_bridge_vlan_seal")]
153    pub fn seal(&self) {
154        unsafe {
155            ffi::nm_bridge_vlan_seal(self.to_glib_none().0);
156        }
157    }
158
159    /// Change the value of the PVID property of the VLAN. It
160    /// is invalid to set the value to [`true`] for non-single-id
161    /// VLANs.
162    /// ## `value`
163    /// the new value
164    #[cfg(feature = "v1_18")]
165    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
166    #[doc(alias = "nm_bridge_vlan_set_pvid")]
167    pub fn set_pvid(&self, value: bool) {
168        unsafe {
169            ffi::nm_bridge_vlan_set_pvid(self.to_glib_none().0, value.into_glib());
170        }
171    }
172
173    /// Change the value of the untagged property of the VLAN.
174    /// ## `value`
175    /// the new value
176    #[cfg(feature = "v1_18")]
177    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
178    #[doc(alias = "nm_bridge_vlan_set_untagged")]
179    pub fn set_untagged(&self, value: bool) {
180        unsafe {
181            ffi::nm_bridge_vlan_set_untagged(self.to_glib_none().0, value.into_glib());
182        }
183    }
184
185    /// Convert a `NMBridgeVlan` to a string.
186    ///
187    /// # Returns
188    ///
189    /// formatted string or [`None`]
190    #[cfg(feature = "v1_18")]
191    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
192    #[doc(alias = "nm_bridge_vlan_to_str")]
193    pub fn to_str(&self) -> Result<glib::GString, glib::Error> {
194        unsafe {
195            let mut error = std::ptr::null_mut();
196            let ret = ffi::nm_bridge_vlan_to_str(self.to_glib_none().0, &mut error);
197            if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
198        }
199    }
200
201    /// Parses the string representation of the queueing
202    /// discipline to a `NMBridgeVlan` instance.
203    /// ## `str`
204    /// the string representation of a bridge VLAN
205    ///
206    /// # Returns
207    ///
208    /// the `NMBridgeVlan` or [`None`]
209    #[cfg(feature = "v1_18")]
210    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
211    #[doc(alias = "nm_bridge_vlan_from_str")]
212    pub fn from_str(str: &str) -> Result<BridgeVlan, glib::Error> {
213        assert_initialized_main_thread!();
214        unsafe {
215            let mut error = std::ptr::null_mut();
216            let ret = ffi::nm_bridge_vlan_from_str(str.to_glib_none().0, &mut error);
217            if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
218        }
219    }
220}