nm_rs/auto/
setting_veth.rs1use crate::{ffi,Setting};
7use glib::{prelude::*};
8#[cfg(feature = "v1_30")]
9#[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
10use glib::{signal::{connect_raw, SignalHandlerId},translate::*};
11#[cfg(feature = "v1_30")]
12#[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
13use std::{boxed::Box as Box_};
14
15glib::wrapper! {
16 #[doc(alias = "NMSettingVeth")]
41 pub struct SettingVeth(Object<ffi::NMSettingVeth, ffi::NMSettingVethClass>) @extends Setting;
42
43 match fn {
44 type_ => || ffi::nm_setting_veth_get_type(),
45 }
46}
47
48impl SettingVeth {
49 #[cfg(feature = "v1_30")]
55 #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
56 #[doc(alias = "nm_setting_veth_new")]
57 pub fn new() -> SettingVeth {
58 assert_initialized_main_thread!();
59 unsafe {
60 Setting::from_glib_full(ffi::nm_setting_veth_new()).unsafe_cast()
61 }
62 }
63
64 pub fn builder() -> SettingVethBuilder {
69 SettingVethBuilder::new()
70 }
71
72
73 #[cfg(feature = "v1_30")]
78 #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
79 #[doc(alias = "nm_setting_veth_get_peer")]
80 #[doc(alias = "get_peer")]
81 pub fn peer(&self) -> glib::GString {
82 unsafe {
83 from_glib_none(ffi::nm_setting_veth_get_peer(self.to_glib_none().0))
84 }
85 }
86
87 #[cfg(feature = "v1_30")]
90 #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
91 pub fn set_peer(&self, peer: Option<&str>) {
92 ObjectExt::set_property(self,"peer", peer)
93 }
94
95 #[cfg(feature = "v1_30")]
96 #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
97 #[doc(alias = "peer")]
98 pub fn connect_peer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
99 unsafe extern "C" fn notify_peer_trampoline<F: Fn(&SettingVeth) + 'static>(this: *mut ffi::NMSettingVeth, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
100 let f: &F = &*(f as *const F);
101 f(&from_glib_borrow(this))
102 }
103 unsafe {
104 let f: Box_<F> = Box_::new(f);
105 connect_raw(self.as_ptr() as *mut _, c"notify::peer".as_ptr() as *const _,
106 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_peer_trampoline::<F> as *const ())), Box_::into_raw(f))
107 }
108 }
109}
110
111#[cfg(feature = "v1_30")]
112#[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
113impl Default for SettingVeth {
114 fn default() -> Self {
115 Self::new()
116 }
117 }
118
119#[must_use = "The builder must be built to be used"]
124pub struct SettingVethBuilder {
125 builder: glib::object::ObjectBuilder<'static, SettingVeth>,
126 }
127
128 impl SettingVethBuilder {
129 fn new() -> Self {
130 Self { builder: glib::object::Object::builder() }
131 }
132
133 #[cfg(feature = "v1_30")]
136 #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
137 pub fn peer(self, peer: impl Into<glib::GString>) -> Self {
138 Self { builder: self.builder.property("peer", peer.into()), }
139 }
140
141 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
144 pub fn build(self) -> SettingVeth {
145assert_initialized_main_thread!();
146 self.builder.build() }
147}