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,SettingSecretFlags};
use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
use std::{boxed::Box as Box_};

glib::wrapper! {
    /// ADSL Settings
    ///
    /// ## Properties
    ///
    ///
    /// #### `encapsulation`
    ///  Encapsulation of ADSL connection.  Can be "vcmux" or "llc".
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `password`
    ///  Password used to authenticate with the ADSL service.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `password-flags`
    ///  Flags indicating how to handle the #NMSettingAdsl:password property.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `protocol`
    ///  ADSL connection protocol.  Can be "pppoa", "pppoe" or "ipoatm".
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `username`
    ///  Username used to authenticate with the ADSL service.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `vci`
    ///  VCI of ADSL connection
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `vpi`
    ///  VPI of ADSL connection
    ///
    /// 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 = "NMSettingAdsl")]
    pub struct SettingAdsl(Object<ffi::NMSettingAdsl, ffi::NMSettingAdslClass>) @extends Setting;

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

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

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

    ///
    /// # Returns
    ///
    /// the #NMSettingAdsl:encapsulation property of the setting
    #[doc(alias = "nm_setting_adsl_get_encapsulation")]
    #[doc(alias = "get_encapsulation")]
    pub fn encapsulation(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_setting_adsl_get_encapsulation(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingAdsl:password property of the setting
    #[doc(alias = "nm_setting_adsl_get_password")]
    #[doc(alias = "get_password")]
    pub fn password(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_setting_adsl_get_password(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingSecretFlags pertaining to the #NMSettingAdsl:password
    #[doc(alias = "nm_setting_adsl_get_password_flags")]
    #[doc(alias = "get_password_flags")]
    #[doc(alias = "password-flags")]
    pub fn password_flags(&self) -> SettingSecretFlags {
        unsafe {
            from_glib(ffi::nm_setting_adsl_get_password_flags(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingAdsl:protocol property of the setting
    #[doc(alias = "nm_setting_adsl_get_protocol")]
    #[doc(alias = "get_protocol")]
    pub fn protocol(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_setting_adsl_get_protocol(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingAdsl:username property of the setting
    #[doc(alias = "nm_setting_adsl_get_username")]
    #[doc(alias = "get_username")]
    pub fn username(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_setting_adsl_get_username(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingAdsl:vci property of the setting
    #[doc(alias = "nm_setting_adsl_get_vci")]
    #[doc(alias = "get_vci")]
    pub fn vci(&self) -> u32 {
        unsafe {
            ffi::nm_setting_adsl_get_vci(self.to_glib_none().0)
        }
    }

    ///
    /// # Returns
    ///
    /// the #NMSettingAdsl:vpi property of the setting
    #[doc(alias = "nm_setting_adsl_get_vpi")]
    #[doc(alias = "get_vpi")]
    pub fn vpi(&self) -> u32 {
        unsafe {
            ffi::nm_setting_adsl_get_vpi(self.to_glib_none().0)
        }
    }

    /// Encapsulation of ADSL connection.  Can be "vcmux" or "llc".
    pub fn set_encapsulation(&self, encapsulation: Option<&str>) {
        ObjectExt::set_property(self,"encapsulation", encapsulation)
    }

    /// Password used to authenticate with the ADSL service.
    pub fn set_password(&self, password: Option<&str>) {
        ObjectExt::set_property(self,"password", password)
    }

    /// Flags indicating how to handle the #NMSettingAdsl:password property.
    #[doc(alias = "password-flags")]
    pub fn set_password_flags(&self, password_flags: SettingSecretFlags) {
        ObjectExt::set_property(self,"password-flags", password_flags)
    }

    /// ADSL connection protocol.  Can be "pppoa", "pppoe" or "ipoatm".
    pub fn set_protocol(&self, protocol: Option<&str>) {
        ObjectExt::set_property(self,"protocol", protocol)
    }

    /// Username used to authenticate with the ADSL service.
    pub fn set_username(&self, username: Option<&str>) {
        ObjectExt::set_property(self,"username", username)
    }

    /// VCI of ADSL connection
    pub fn set_vci(&self, vci: u32) {
        ObjectExt::set_property(self,"vci", vci)
    }

    /// VPI of ADSL connection
    pub fn set_vpi(&self, vpi: u32) {
        ObjectExt::set_property(self,"vpi", vpi)
    }

    #[doc(alias = "encapsulation")]
    pub fn connect_encapsulation_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_encapsulation_trampoline<F: Fn(&SettingAdsl) + 'static>(this: *mut ffi::NMSettingAdsl, _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::encapsulation".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_encapsulation_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "password")]
    pub fn connect_password_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_password_trampoline<F: Fn(&SettingAdsl) + 'static>(this: *mut ffi::NMSettingAdsl, _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::password".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_password_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "password-flags")]
    pub fn connect_password_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_password_flags_trampoline<F: Fn(&SettingAdsl) + 'static>(this: *mut ffi::NMSettingAdsl, _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::password-flags".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_password_flags_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "protocol")]
    pub fn connect_protocol_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_protocol_trampoline<F: Fn(&SettingAdsl) + 'static>(this: *mut ffi::NMSettingAdsl, _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::protocol".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_protocol_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "username")]
    pub fn connect_username_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_username_trampoline<F: Fn(&SettingAdsl) + 'static>(this: *mut ffi::NMSettingAdsl, _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::username".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_username_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "vci")]
    pub fn connect_vci_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_vci_trampoline<F: Fn(&SettingAdsl) + 'static>(this: *mut ffi::NMSettingAdsl, _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::vci".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_vci_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "vpi")]
    pub fn connect_vpi_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_vpi_trampoline<F: Fn(&SettingAdsl) + 'static>(this: *mut ffi::NMSettingAdsl, _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::vpi".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_vpi_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }
}

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

// rustdoc-stripper-ignore-next
        /// A [builder-pattern] type to construct [`SettingAdsl`] 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 SettingAdslBuilder {
            builder: glib::object::ObjectBuilder<'static, SettingAdsl>,
        }

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

                            /// Encapsulation of ADSL connection.  Can be "vcmux" or "llc".
                            pub fn encapsulation(self, encapsulation: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("encapsulation", encapsulation.into()), }
                        }

                            /// Password used to authenticate with the ADSL service.
                            pub fn password(self, password: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("password", password.into()), }
                        }

                            /// Flags indicating how to handle the #NMSettingAdsl:password property.
                            pub fn password_flags(self, password_flags: SettingSecretFlags) -> Self {
                            Self { builder: self.builder.property("password-flags", password_flags), }
                        }

                            /// ADSL connection protocol.  Can be "pppoa", "pppoe" or "ipoatm".
                            pub fn protocol(self, protocol: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("protocol", protocol.into()), }
                        }

                            /// Username used to authenticate with the ADSL service.
                            pub fn username(self, username: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("username", username.into()), }
                        }

                            /// VCI of ADSL connection
                            pub fn vci(self, vci: u32) -> Self {
                            Self { builder: self.builder.property("vci", vci), }
                        }

                            /// VPI of ADSL connection
                            pub fn vpi(self, vpi: u32) -> Self {
                            Self { builder: self.builder.property("vpi", vpi), }
                        }

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