nm_rs/auto/
setting_hsr.rs1use 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 #[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 #[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 pub fn builder() -> SettingHsrBuilder {
86 SettingHsrBuilder::new()
87 }
88
89
90 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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#[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 #[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 #[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 #[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 #[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 #[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}