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