nm_rs/auto/
setting_serial.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,Setting,SettingSerialParity};
7use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
8use std::{boxed::Box as Box_};
9
10glib::wrapper! {
11    /// Serial Link Settings
12    ///
13    /// ## Properties
14    ///
15    ///
16    /// #### `baud`
17    ///  Speed to use for communication over the serial port.  Note that this
18    /// value usually has no effect for mobile broadband modems as they generally
19    /// ignore speed settings and use the highest available speed.
20    ///
21    /// Readable | Writeable
22    ///
23    ///
24    /// #### `bits`
25    ///  Byte-width of the serial communication. The 8 in "8n1" for example.
26    ///
27    /// Readable | Writeable
28    ///
29    ///
30    /// #### `parity`
31    ///  Parity setting of the serial port.
32    ///
33    /// Readable | Writeable
34    ///
35    ///
36    /// #### `send-delay`
37    ///  Time to delay between each byte sent to the modem, in microseconds.
38    ///
39    /// Readable | Writeable
40    ///
41    ///
42    /// #### `stopbits`
43    ///  Number of stop bits for communication on the serial port.  Either 1 or 2.
44    /// The 1 in "8n1" for example.
45    ///
46    /// Readable | Writeable
47    /// <details><summary><h4>Setting</h4></summary>
48    ///
49    ///
50    /// #### `name`
51    ///  The setting's name, which uniquely identifies the setting within the
52    /// connection.  Each setting type has a name unique to that type, for
53    /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
54    ///
55    /// Readable
56    /// </details>
57    ///
58    /// # Implements
59    ///
60    /// [`SettingExt`][trait@crate::prelude::SettingExt]
61    #[doc(alias = "NMSettingSerial")]
62    pub struct SettingSerial(Object<ffi::NMSettingSerial, ffi::NMSettingSerialClass>) @extends Setting;
63
64    match fn {
65        type_ => || ffi::nm_setting_serial_get_type(),
66    }
67}
68
69impl SettingSerial {
70    /// Creates a new #NMSettingSerial object with default values.
71    ///
72    /// # Returns
73    ///
74    /// the new empty #NMSettingSerial object
75    #[doc(alias = "nm_setting_serial_new")]
76    pub fn new() -> SettingSerial {
77        assert_initialized_main_thread!();
78        unsafe {
79            Setting::from_glib_full(ffi::nm_setting_serial_new()).unsafe_cast()
80        }
81    }
82
83            // rustdoc-stripper-ignore-next
84            /// Creates a new builder-pattern struct instance to construct [`SettingSerial`] objects.
85            ///
86            /// This method returns an instance of [`SettingSerialBuilder`](crate::builders::SettingSerialBuilder) which can be used to create [`SettingSerial`] objects.
87            pub fn builder() -> SettingSerialBuilder {
88                SettingSerialBuilder::new()
89            }
90        
91
92    ///
93    /// # Returns
94    ///
95    /// the #NMSettingSerial:baud property of the setting
96    #[doc(alias = "nm_setting_serial_get_baud")]
97    #[doc(alias = "get_baud")]
98    pub fn baud(&self) -> u32 {
99        unsafe {
100            ffi::nm_setting_serial_get_baud(self.to_glib_none().0)
101        }
102    }
103
104    ///
105    /// # Returns
106    ///
107    /// the #NMSettingSerial:bits property of the setting
108    #[doc(alias = "nm_setting_serial_get_bits")]
109    #[doc(alias = "get_bits")]
110    pub fn bits(&self) -> u32 {
111        unsafe {
112            ffi::nm_setting_serial_get_bits(self.to_glib_none().0)
113        }
114    }
115
116    ///
117    /// # Returns
118    ///
119    /// the #NMSettingSerial:parity property of the setting
120    #[doc(alias = "nm_setting_serial_get_parity")]
121    #[doc(alias = "get_parity")]
122    pub fn parity(&self) -> SettingSerialParity {
123        unsafe {
124            from_glib(ffi::nm_setting_serial_get_parity(self.to_glib_none().0))
125        }
126    }
127
128    ///
129    /// # Returns
130    ///
131    /// the #NMSettingSerial:send-delay property of the setting
132    #[doc(alias = "nm_setting_serial_get_send_delay")]
133    #[doc(alias = "get_send_delay")]
134    #[doc(alias = "send-delay")]
135    pub fn send_delay(&self) -> u64 {
136        unsafe {
137            ffi::nm_setting_serial_get_send_delay(self.to_glib_none().0)
138        }
139    }
140
141    ///
142    /// # Returns
143    ///
144    /// the #NMSettingSerial:stopbits property of the setting
145    #[doc(alias = "nm_setting_serial_get_stopbits")]
146    #[doc(alias = "get_stopbits")]
147    pub fn stopbits(&self) -> u32 {
148        unsafe {
149            ffi::nm_setting_serial_get_stopbits(self.to_glib_none().0)
150        }
151    }
152
153    /// Speed to use for communication over the serial port.  Note that this
154    /// value usually has no effect for mobile broadband modems as they generally
155    /// ignore speed settings and use the highest available speed.
156    pub fn set_baud(&self, baud: u32) {
157        ObjectExt::set_property(self,"baud", baud)
158    }
159
160    /// Byte-width of the serial communication. The 8 in "8n1" for example.
161    pub fn set_bits(&self, bits: u32) {
162        ObjectExt::set_property(self,"bits", bits)
163    }
164
165    /// Parity setting of the serial port.
166    pub fn set_parity(&self, parity: SettingSerialParity) {
167        ObjectExt::set_property(self,"parity", parity)
168    }
169
170    /// Time to delay between each byte sent to the modem, in microseconds.
171    #[doc(alias = "send-delay")]
172    pub fn set_send_delay(&self, send_delay: u64) {
173        ObjectExt::set_property(self,"send-delay", send_delay)
174    }
175
176    /// Number of stop bits for communication on the serial port.  Either 1 or 2.
177    /// The 1 in "8n1" for example.
178    pub fn set_stopbits(&self, stopbits: u32) {
179        ObjectExt::set_property(self,"stopbits", stopbits)
180    }
181
182    #[doc(alias = "baud")]
183    pub fn connect_baud_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
184        unsafe extern "C" fn notify_baud_trampoline<F: Fn(&SettingSerial) + 'static>(this: *mut ffi::NMSettingSerial, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
185            let f: &F = &*(f as *const F);
186            f(&from_glib_borrow(this))
187        }
188        unsafe {
189            let f: Box_<F> = Box_::new(f);
190            connect_raw(self.as_ptr() as *mut _, c"notify::baud".as_ptr() as *const _,
191                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_baud_trampoline::<F> as *const ())), Box_::into_raw(f))
192        }
193    }
194
195    #[doc(alias = "bits")]
196    pub fn connect_bits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
197        unsafe extern "C" fn notify_bits_trampoline<F: Fn(&SettingSerial) + 'static>(this: *mut ffi::NMSettingSerial, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
198            let f: &F = &*(f as *const F);
199            f(&from_glib_borrow(this))
200        }
201        unsafe {
202            let f: Box_<F> = Box_::new(f);
203            connect_raw(self.as_ptr() as *mut _, c"notify::bits".as_ptr() as *const _,
204                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_bits_trampoline::<F> as *const ())), Box_::into_raw(f))
205        }
206    }
207
208    #[doc(alias = "parity")]
209    pub fn connect_parity_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
210        unsafe extern "C" fn notify_parity_trampoline<F: Fn(&SettingSerial) + 'static>(this: *mut ffi::NMSettingSerial, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
211            let f: &F = &*(f as *const F);
212            f(&from_glib_borrow(this))
213        }
214        unsafe {
215            let f: Box_<F> = Box_::new(f);
216            connect_raw(self.as_ptr() as *mut _, c"notify::parity".as_ptr() as *const _,
217                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_parity_trampoline::<F> as *const ())), Box_::into_raw(f))
218        }
219    }
220
221    #[doc(alias = "send-delay")]
222    pub fn connect_send_delay_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
223        unsafe extern "C" fn notify_send_delay_trampoline<F: Fn(&SettingSerial) + 'static>(this: *mut ffi::NMSettingSerial, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
224            let f: &F = &*(f as *const F);
225            f(&from_glib_borrow(this))
226        }
227        unsafe {
228            let f: Box_<F> = Box_::new(f);
229            connect_raw(self.as_ptr() as *mut _, c"notify::send-delay".as_ptr() as *const _,
230                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_send_delay_trampoline::<F> as *const ())), Box_::into_raw(f))
231        }
232    }
233
234    #[doc(alias = "stopbits")]
235    pub fn connect_stopbits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
236        unsafe extern "C" fn notify_stopbits_trampoline<F: Fn(&SettingSerial) + 'static>(this: *mut ffi::NMSettingSerial, _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::stopbits".as_ptr() as *const _,
243                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_stopbits_trampoline::<F> as *const ())), Box_::into_raw(f))
244        }
245    }
246}
247
248impl Default for SettingSerial {
249                     fn default() -> Self {
250                         Self::new()
251                     }
252                 }
253
254// rustdoc-stripper-ignore-next
255        /// A [builder-pattern] type to construct [`SettingSerial`] objects.
256        ///
257        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
258#[must_use = "The builder must be built to be used"]
259pub struct SettingSerialBuilder {
260            builder: glib::object::ObjectBuilder<'static, SettingSerial>,
261        }
262
263        impl SettingSerialBuilder {
264        fn new() -> Self {
265            Self { builder: glib::object::Object::builder() }
266        }
267
268                            /// Speed to use for communication over the serial port.  Note that this
269                            /// value usually has no effect for mobile broadband modems as they generally
270                            /// ignore speed settings and use the highest available speed.
271                            pub fn baud(self, baud: u32) -> Self {
272                            Self { builder: self.builder.property("baud", baud), }
273                        }
274
275                            /// Byte-width of the serial communication. The 8 in "8n1" for example.
276                            pub fn bits(self, bits: u32) -> Self {
277                            Self { builder: self.builder.property("bits", bits), }
278                        }
279
280                            /// Parity setting of the serial port.
281                            pub fn parity(self, parity: SettingSerialParity) -> Self {
282                            Self { builder: self.builder.property("parity", parity), }
283                        }
284
285                            /// Time to delay between each byte sent to the modem, in microseconds.
286                            pub fn send_delay(self, send_delay: u64) -> Self {
287                            Self { builder: self.builder.property("send-delay", send_delay), }
288                        }
289
290                            /// Number of stop bits for communication on the serial port.  Either 1 or 2.
291                            /// The 1 in "8n1" for example.
292                            pub fn stopbits(self, stopbits: u32) -> Self {
293                            Self { builder: self.builder.property("stopbits", stopbits), }
294                        }
295
296    // rustdoc-stripper-ignore-next
297    /// Build the [`SettingSerial`].
298    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
299    pub fn build(self) -> SettingSerial {
300assert_initialized_main_thread!();
301    self.builder.build() }
302}