nm_rs/auto/
setting_macvlan.rs1use crate::{ffi,Setting};
7#[cfg(feature = "v1_2")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
9use crate::{SettingMacvlanMode};
10use glib::{prelude::*};
11#[cfg(feature = "v1_2")]
12#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
13use glib::{signal::{connect_raw, SignalHandlerId},translate::*};
14#[cfg(feature = "v1_2")]
15#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
16use std::{boxed::Box as Box_};
17
18glib::wrapper! {
19 #[doc(alias = "NMSettingMacvlan")]
65 pub struct SettingMacvlan(Object<ffi::NMSettingMacvlan, ffi::NMSettingMacvlanClass>) @extends Setting;
66
67 match fn {
68 type_ => || ffi::nm_setting_macvlan_get_type(),
69 }
70}
71
72impl SettingMacvlan {
73 #[cfg(feature = "v1_2")]
79 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
80 #[doc(alias = "nm_setting_macvlan_new")]
81 pub fn new() -> SettingMacvlan {
82 assert_initialized_main_thread!();
83 unsafe {
84 Setting::from_glib_full(ffi::nm_setting_macvlan_new()).unsafe_cast()
85 }
86 }
87
88 pub fn builder() -> SettingMacvlanBuilder {
93 SettingMacvlanBuilder::new()
94 }
95
96
97 #[cfg(feature = "v1_2")]
102 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
103 #[doc(alias = "nm_setting_macvlan_get_mode")]
104 #[doc(alias = "get_mode")]
105 pub fn mode(&self) -> SettingMacvlanMode {
106 unsafe {
107 from_glib(ffi::nm_setting_macvlan_get_mode(self.to_glib_none().0))
108 }
109 }
110
111 #[cfg(feature = "v1_2")]
116 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
117 #[doc(alias = "nm_setting_macvlan_get_parent")]
118 #[doc(alias = "get_parent")]
119 pub fn parent(&self) -> glib::GString {
120 unsafe {
121 from_glib_none(ffi::nm_setting_macvlan_get_parent(self.to_glib_none().0))
122 }
123 }
124
125 #[cfg(feature = "v1_2")]
130 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
131 #[doc(alias = "nm_setting_macvlan_get_promiscuous")]
132 #[doc(alias = "get_promiscuous")]
133 #[doc(alias = "promiscuous")]
134 pub fn is_promiscuous(&self) -> bool {
135 unsafe {
136 from_glib(ffi::nm_setting_macvlan_get_promiscuous(self.to_glib_none().0))
137 }
138 }
139
140 #[cfg(feature = "v1_2")]
145 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
146 #[doc(alias = "nm_setting_macvlan_get_tap")]
147 #[doc(alias = "get_tap")]
148 #[doc(alias = "tap")]
149 pub fn is_tap(&self) -> bool {
150 unsafe {
151 from_glib(ffi::nm_setting_macvlan_get_tap(self.to_glib_none().0))
152 }
153 }
154
155 #[cfg(feature = "v1_2")]
158 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
159 pub fn set_mode(&self, mode: u32) {
160 ObjectExt::set_property(self,"mode", mode)
161 }
162
163 #[cfg(feature = "v1_2")]
168 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
169 pub fn set_parent(&self, parent: Option<&str>) {
170 ObjectExt::set_property(self,"parent", parent)
171 }
172
173 #[cfg(feature = "v1_2")]
175 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
176 pub fn set_promiscuous(&self, promiscuous: bool) {
177 ObjectExt::set_property(self,"promiscuous", promiscuous)
178 }
179
180 #[cfg(feature = "v1_2")]
182 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
183 pub fn set_tap(&self, tap: bool) {
184 ObjectExt::set_property(self,"tap", tap)
185 }
186
187 #[cfg(feature = "v1_2")]
188 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
189 #[doc(alias = "mode")]
190 pub fn connect_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
191 unsafe extern "C" fn notify_mode_trampoline<F: Fn(&SettingMacvlan) + 'static>(this: *mut ffi::NMSettingMacvlan, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
192 let f: &F = &*(f as *const F);
193 f(&from_glib_borrow(this))
194 }
195 unsafe {
196 let f: Box_<F> = Box_::new(f);
197 connect_raw(self.as_ptr() as *mut _, c"notify::mode".as_ptr() as *const _,
198 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mode_trampoline::<F> as *const ())), Box_::into_raw(f))
199 }
200 }
201
202 #[cfg(feature = "v1_2")]
203 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
204 #[doc(alias = "parent")]
205 pub fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
206 unsafe extern "C" fn notify_parent_trampoline<F: Fn(&SettingMacvlan) + 'static>(this: *mut ffi::NMSettingMacvlan, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
207 let f: &F = &*(f as *const F);
208 f(&from_glib_borrow(this))
209 }
210 unsafe {
211 let f: Box_<F> = Box_::new(f);
212 connect_raw(self.as_ptr() as *mut _, c"notify::parent".as_ptr() as *const _,
213 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_parent_trampoline::<F> as *const ())), Box_::into_raw(f))
214 }
215 }
216
217 #[cfg(feature = "v1_2")]
218 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
219 #[doc(alias = "promiscuous")]
220 pub fn connect_promiscuous_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
221 unsafe extern "C" fn notify_promiscuous_trampoline<F: Fn(&SettingMacvlan) + 'static>(this: *mut ffi::NMSettingMacvlan, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
222 let f: &F = &*(f as *const F);
223 f(&from_glib_borrow(this))
224 }
225 unsafe {
226 let f: Box_<F> = Box_::new(f);
227 connect_raw(self.as_ptr() as *mut _, c"notify::promiscuous".as_ptr() as *const _,
228 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_promiscuous_trampoline::<F> as *const ())), Box_::into_raw(f))
229 }
230 }
231
232 #[cfg(feature = "v1_2")]
233 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
234 #[doc(alias = "tap")]
235 pub fn connect_tap_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
236 unsafe extern "C" fn notify_tap_trampoline<F: Fn(&SettingMacvlan) + 'static>(this: *mut ffi::NMSettingMacvlan, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
237 let f: &F = &*(f as *const F);
238 f(&from_glib_borrow(this))
239 }
240 unsafe {
241 let f: Box_<F> = Box_::new(f);
242 connect_raw(self.as_ptr() as *mut _, c"notify::tap".as_ptr() as *const _,
243 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_tap_trampoline::<F> as *const ())), Box_::into_raw(f))
244 }
245 }
246}
247
248#[cfg(feature = "v1_2")]
249#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
250impl Default for SettingMacvlan {
251 fn default() -> Self {
252 Self::new()
253 }
254 }
255
256#[must_use = "The builder must be built to be used"]
261pub struct SettingMacvlanBuilder {
262 builder: glib::object::ObjectBuilder<'static, SettingMacvlan>,
263 }
264
265 impl SettingMacvlanBuilder {
266 fn new() -> Self {
267 Self { builder: glib::object::Object::builder() }
268 }
269
270 #[cfg(feature = "v1_2")]
273 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
274 pub fn mode(self, mode: u32) -> Self {
275 Self { builder: self.builder.property("mode", mode), }
276 }
277
278 #[cfg(feature = "v1_2")]
283 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
284 pub fn parent(self, parent: impl Into<glib::GString>) -> Self {
285 Self { builder: self.builder.property("parent", parent.into()), }
286 }
287
288 #[cfg(feature = "v1_2")]
290 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
291 pub fn promiscuous(self, promiscuous: bool) -> Self {
292 Self { builder: self.builder.property("promiscuous", promiscuous), }
293 }
294
295 #[cfg(feature = "v1_2")]
297 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
298 pub fn tap(self, tap: bool) -> Self {
299 Self { builder: self.builder.property("tap", tap), }
300 }
301
302 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
305 pub fn build(self) -> SettingMacvlan {
306assert_initialized_main_thread!();
307 self.builder.build() }
308}