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

glib::wrapper! {
    ///
    ///
    /// ## Properties
    ///
    ///
    /// #### `created`
    ///  The timestamp (in CLOCK_BOOTTIME milliseconds) of checkpoint creation.
    ///
    /// Readable
    ///
    ///
    /// #### `devices`
    ///  The devices that are part of this checkpoint.
    ///
    /// Readable
    ///
    ///
    /// #### `rollback-timeout`
    ///  Timeout in seconds for automatic rollback, or zero.
    ///
    /// Readable
    /// <details><summary><h4>Object</h4></summary>
    ///
    ///
    /// #### `client`
    ///  The NMClient instance as returned by nm_object_get_client().
    ///
    /// When an NMObject gets removed from the NMClient cache,
    /// the NMObject:path property stays unchanged, but this client
    /// instance gets reset to [`None`]. You can use this property to
    /// track removal of the object from the cache.
    ///
    /// Readable
    ///
    ///
    /// #### `path`
    ///  The D-Bus object path.
    ///
    /// The D-Bus path of an object instance never changes, even if the object
    /// gets removed from the cache. To see whether the object is still in the
    /// cache, check NMObject:client.
    ///
    /// Readable
    /// </details>
    ///
    /// # Implements
    ///
    /// [`ObjectExt`][trait@crate::prelude::ObjectExt]
    #[doc(alias = "NMCheckpoint")]
    pub struct Checkpoint(Object<ffi::NMCheckpoint, ffi::NMCheckpointClass>) @extends Object;

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

impl Checkpoint {
    /// Gets the timestamp (in CLOCK_BOOTTIME milliseconds) of checkpoint creation.
    ///
    /// Use nm_utils_get_timestamp_msec() to obtain current time value suitable for
    /// comparing to this value.
    ///
    /// # Returns
    ///
    /// the timestamp of checkpoint creation.
    #[doc(alias = "nm_checkpoint_get_created")]
    #[doc(alias = "get_created")]
    pub fn created(&self) -> i64 {
        unsafe {
            ffi::nm_checkpoint_get_created(self.to_glib_none().0)
        }
    }

    /// The devices that are part of this checkpoint.
    ///
    /// # Returns
    ///
    /// the devices list.
    #[doc(alias = "nm_checkpoint_get_devices")]
    #[doc(alias = "get_devices")]
    pub fn devices(&self) -> Vec<Device> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(ffi::nm_checkpoint_get_devices(self.to_glib_none().0))
        }
    }

    /// Gets the timeout in seconds for automatic rollback.
    ///
    /// # Returns
    ///
    /// the rollback timeout.
    #[doc(alias = "nm_checkpoint_get_rollback_timeout")]
    #[doc(alias = "get_rollback_timeout")]
    #[doc(alias = "rollback-timeout")]
    pub fn rollback_timeout(&self) -> u32 {
        unsafe {
            ffi::nm_checkpoint_get_rollback_timeout(self.to_glib_none().0)
        }
    }

    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "created")]
    pub fn connect_created_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_created_trampoline<F: Fn(&Checkpoint) + 'static>(this: *mut ffi::NMCheckpoint, _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::created".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_created_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "devices")]
    pub fn connect_devices_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_devices_trampoline<F: Fn(&Checkpoint) + 'static>(this: *mut ffi::NMCheckpoint, _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::devices".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_devices_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[cfg(feature = "v1_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
    #[doc(alias = "rollback-timeout")]
    pub fn connect_rollback_timeout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_rollback_timeout_trampoline<F: Fn(&Checkpoint) + 'static>(this: *mut ffi::NMCheckpoint, _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::rollback-timeout".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_rollback_timeout_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }
}