nm_rs/auto/
setting_serial.rs1use crate::{ffi,Setting,SettingSerialParity};
7use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
8use std::{boxed::Box as Box_};
9
10glib::wrapper! {
11 #[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 #[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 pub fn builder() -> SettingSerialBuilder {
88 SettingSerialBuilder::new()
89 }
90
91
92 #[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 #[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 #[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 #[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 #[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 pub fn set_baud(&self, baud: u32) {
157 ObjectExt::set_property(self,"baud", baud)
158 }
159
160 pub fn set_bits(&self, bits: u32) {
162 ObjectExt::set_property(self,"bits", bits)
163 }
164
165 pub fn set_parity(&self, parity: SettingSerialParity) {
167 ObjectExt::set_property(self,"parity", parity)
168 }
169
170 #[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 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#[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 pub fn baud(self, baud: u32) -> Self {
272 Self { builder: self.builder.property("baud", baud), }
273 }
274
275 pub fn bits(self, bits: u32) -> Self {
277 Self { builder: self.builder.property("bits", bits), }
278 }
279
280 pub fn parity(self, parity: SettingSerialParity) -> Self {
282 Self { builder: self.builder.property("parity", parity), }
283 }
284
285 pub fn send_delay(self, send_delay: u64) -> Self {
287 Self { builder: self.builder.property("send-delay", send_delay), }
288 }
289
290 pub fn stopbits(self, stopbits: u32) -> Self {
293 Self { builder: self.builder.property("stopbits", stopbits), }
294 }
295
296 #[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}