nm-rs 0.1.3

Rust bindings for the libnm library.
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir
// from gtk-girs (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::{ffi,Setting,SettingSerialParity};
use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
use std::{boxed::Box as Box_};

glib::wrapper! {
    /// Serial Link Settings
    ///
    /// ## Properties
    ///
    ///
    /// #### `baud`
    ///  Speed to use for communication over the serial port.  Note that this
    /// value usually has no effect for mobile broadband modems as they generally
    /// ignore speed settings and use the highest available speed.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `bits`
    ///  Byte-width of the serial communication. The 8 in "8n1" for example.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `parity`
    ///  Parity setting of the serial port.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `send-delay`
    ///  Time to delay between each byte sent to the modem, in microseconds.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `stopbits`
    ///  Number of stop bits for communication on the serial port.  Either 1 or 2.
    /// The 1 in "8n1" for example.
    ///
    /// Readable | Writeable
    /// <details><summary><h4>Setting</h4></summary>
    ///
    ///
    /// #### `name`
    ///  The setting's name, which uniquely identifies the setting within the
    /// connection.  Each setting type has a name unique to that type, for
    /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
    ///
    /// Readable
    /// </details>
    ///
    /// # Implements
    ///
    /// [`SettingExt`][trait@crate::prelude::SettingExt]
    #[doc(alias = "NMSettingSerial")]
    pub struct SettingSerial(Object<ffi::NMSettingSerial, ffi::NMSettingSerialClass>) @extends Setting;

    match fn {
        type_ => || ffi::nm_setting_serial_get_type(),
    }
}

impl SettingSerial {
    /// Creates a new #NMSettingSerial object with default values.
    ///
    /// # Returns
    ///
    /// the new empty #NMSettingSerial object
    #[doc(alias = "nm_setting_serial_new")]
    pub fn new() -> SettingSerial {
        assert_initialized_main_thread!();
        unsafe {
            Setting::from_glib_full(ffi::nm_setting_serial_new()).unsafe_cast()
        }
    }

            // rustdoc-stripper-ignore-next
            /// Creates a new builder-pattern struct instance to construct [`SettingSerial`] objects.
            ///
            /// This method returns an instance of [`SettingSerialBuilder`](crate::builders::SettingSerialBuilder) which can be used to create [`SettingSerial`] objects.
            pub fn builder() -> SettingSerialBuilder {
                SettingSerialBuilder::new()
            }
        

    ///
    /// # Returns
    ///
    /// the #NMSettingSerial:baud property of the setting
    #[doc(alias = "nm_setting_serial_get_baud")]
    #[doc(alias = "get_baud")]
    pub fn baud(&self) -> u32 {
        unsafe {
            ffi::nm_setting_serial_get_baud(self.to_glib_none().0)
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingSerial:bits property of the setting
    #[doc(alias = "nm_setting_serial_get_bits")]
    #[doc(alias = "get_bits")]
    pub fn bits(&self) -> u32 {
        unsafe {
            ffi::nm_setting_serial_get_bits(self.to_glib_none().0)
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingSerial:parity property of the setting
    #[doc(alias = "nm_setting_serial_get_parity")]
    #[doc(alias = "get_parity")]
    pub fn parity(&self) -> SettingSerialParity {
        unsafe {
            from_glib(ffi::nm_setting_serial_get_parity(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingSerial:send-delay property of the setting
    #[doc(alias = "nm_setting_serial_get_send_delay")]
    #[doc(alias = "get_send_delay")]
    #[doc(alias = "send-delay")]
    pub fn send_delay(&self) -> u64 {
        unsafe {
            ffi::nm_setting_serial_get_send_delay(self.to_glib_none().0)
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingSerial:stopbits property of the setting
    #[doc(alias = "nm_setting_serial_get_stopbits")]
    #[doc(alias = "get_stopbits")]
    pub fn stopbits(&self) -> u32 {
        unsafe {
            ffi::nm_setting_serial_get_stopbits(self.to_glib_none().0)
        }
    }

    /// Speed to use for communication over the serial port.  Note that this
    /// value usually has no effect for mobile broadband modems as they generally
    /// ignore speed settings and use the highest available speed.
    pub fn set_baud(&self, baud: u32) {
        ObjectExt::set_property(self,"baud", baud)
    }

    /// Byte-width of the serial communication. The 8 in "8n1" for example.
    pub fn set_bits(&self, bits: u32) {
        ObjectExt::set_property(self,"bits", bits)
    }

    /// Parity setting of the serial port.
    pub fn set_parity(&self, parity: SettingSerialParity) {
        ObjectExt::set_property(self,"parity", parity)
    }

    /// Time to delay between each byte sent to the modem, in microseconds.
    #[doc(alias = "send-delay")]
    pub fn set_send_delay(&self, send_delay: u64) {
        ObjectExt::set_property(self,"send-delay", send_delay)
    }

    /// Number of stop bits for communication on the serial port.  Either 1 or 2.
    /// The 1 in "8n1" for example.
    pub fn set_stopbits(&self, stopbits: u32) {
        ObjectExt::set_property(self,"stopbits", stopbits)
    }

    #[doc(alias = "baud")]
    pub fn connect_baud_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_baud_trampoline<F: Fn(&SettingSerial) + 'static>(this: *mut ffi::NMSettingSerial, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::baud".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_baud_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "bits")]
    pub fn connect_bits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_bits_trampoline<F: Fn(&SettingSerial) + 'static>(this: *mut ffi::NMSettingSerial, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::bits".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_bits_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "parity")]
    pub fn connect_parity_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_parity_trampoline<F: Fn(&SettingSerial) + 'static>(this: *mut ffi::NMSettingSerial, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::parity".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_parity_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "send-delay")]
    pub fn connect_send_delay_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        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) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::send-delay".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_send_delay_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "stopbits")]
    pub fn connect_stopbits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_stopbits_trampoline<F: Fn(&SettingSerial) + 'static>(this: *mut ffi::NMSettingSerial, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::stopbits".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_stopbits_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }
}

impl Default for SettingSerial {
                     fn default() -> Self {
                         Self::new()
                     }
                 }

// rustdoc-stripper-ignore-next
        /// A [builder-pattern] type to construct [`SettingSerial`] objects.
        ///
        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct SettingSerialBuilder {
            builder: glib::object::ObjectBuilder<'static, SettingSerial>,
        }

        impl SettingSerialBuilder {
        fn new() -> Self {
            Self { builder: glib::object::Object::builder() }
        }

                            /// Speed to use for communication over the serial port.  Note that this
                            /// value usually has no effect for mobile broadband modems as they generally
                            /// ignore speed settings and use the highest available speed.
                            pub fn baud(self, baud: u32) -> Self {
                            Self { builder: self.builder.property("baud", baud), }
                        }

                            /// Byte-width of the serial communication. The 8 in "8n1" for example.
                            pub fn bits(self, bits: u32) -> Self {
                            Self { builder: self.builder.property("bits", bits), }
                        }

                            /// Parity setting of the serial port.
                            pub fn parity(self, parity: SettingSerialParity) -> Self {
                            Self { builder: self.builder.property("parity", parity), }
                        }

                            /// Time to delay between each byte sent to the modem, in microseconds.
                            pub fn send_delay(self, send_delay: u64) -> Self {
                            Self { builder: self.builder.property("send-delay", send_delay), }
                        }

                            /// Number of stop bits for communication on the serial port.  Either 1 or 2.
                            /// The 1 in "8n1" for example.
                            pub fn stopbits(self, stopbits: u32) -> Self {
                            Self { builder: self.builder.property("stopbits", stopbits), }
                        }

    // rustdoc-stripper-ignore-next
    /// Build the [`SettingSerial`].
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> SettingSerial {
assert_initialized_main_thread!();
    self.builder.build() }
}