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! {
    /// PPP-over-Ethernet Settings
    ///
    /// ## Properties
    ///
    ///
    /// #### `parent`
    ///  If given, specifies the parent interface name on which this PPPoE
    /// connection should be created.  If this property is not specified,
    /// the connection is activated on the interface specified in
    /// #NMSettingConnection:interface-name of #NMSettingConnection.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `password`
    ///  Password used to authenticate with the PPPoE service.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `password-flags`
    ///  Flags indicating how to handle the #NMSettingPppoe:password property.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `service`
    ///  If specified, instruct PPPoE to only initiate sessions with access
    /// concentrators that provide the specified service.  For most providers,
    /// this should be left blank.  It is only required if there are multiple
    /// access concentrators or a specific service is known to be required.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `username`
    ///  Username used to authenticate with the PPPoE service.
    ///
    /// 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 = "NMSettingPppoe")]
    pub struct SettingPppoe(Object<ffi::NMSettingPppoe, ffi::NMSettingPppoeClass>) @extends Setting;

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

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

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

    ///
    /// # Returns
    ///
    /// the #NMSettingPppoe:parent property of the setting
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "nm_setting_pppoe_get_parent")]
    #[doc(alias = "get_parent")]
    pub fn parent(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_setting_pppoe_get_parent(self.to_glib_none().0))
        }
    }

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

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

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

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

    /// If given, specifies the parent interface name on which this PPPoE
    /// connection should be created.  If this property is not specified,
    /// the connection is activated on the interface specified in
    /// #NMSettingConnection:interface-name of #NMSettingConnection.
    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    pub fn set_parent(&self, parent: Option<&str>) {
        ObjectExt::set_property(self,"parent", parent)
    }

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

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

    /// If specified, instruct PPPoE to only initiate sessions with access
    /// concentrators that provide the specified service.  For most providers,
    /// this should be left blank.  It is only required if there are multiple
    /// access concentrators or a specific service is known to be required.
    pub fn set_service(&self, service: Option<&str>) {
        ObjectExt::set_property(self,"service", service)
    }

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

    #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    #[doc(alias = "parent")]
    pub fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_parent_trampoline<F: Fn(&SettingPppoe) + 'static>(this: *mut ffi::NMSettingPppoe, _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::parent".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_parent_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(&SettingPppoe) + 'static>(this: *mut ffi::NMSettingPppoe, _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(&SettingPppoe) + 'static>(this: *mut ffi::NMSettingPppoe, _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 = "service")]
    pub fn connect_service_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_service_trampoline<F: Fn(&SettingPppoe) + 'static>(this: *mut ffi::NMSettingPppoe, _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::service".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_service_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(&SettingPppoe) + 'static>(this: *mut ffi::NMSettingPppoe, _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))
        }
    }
}

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

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

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

                            /// If given, specifies the parent interface name on which this PPPoE
                            /// connection should be created.  If this property is not specified,
                            /// the connection is activated on the interface specified in
                            /// #NMSettingConnection:interface-name of #NMSettingConnection.
                            #[cfg(feature = "v1_10")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
    pub fn parent(self, parent: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("parent", parent.into()), }
                        }

                            /// Password used to authenticate with the PPPoE 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 #NMSettingPppoe:password property.
                            pub fn password_flags(self, password_flags: SettingSecretFlags) -> Self {
                            Self { builder: self.builder.property("password-flags", password_flags), }
                        }

                            /// If specified, instruct PPPoE to only initiate sessions with access
                            /// concentrators that provide the specified service.  For most providers,
                            /// this should be left blank.  It is only required if there are multiple
                            /// access concentrators or a specific service is known to be required.
                            pub fn service(self, service: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("service", service.into()), }
                        }

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

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