nm_rs/auto/
checkpoint.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir
3// from gtk-girs (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{ffi,Device,Object};
7use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
8use std::{boxed::Box as Box_};
9
10glib::wrapper! {
11    ///
12    ///
13    /// ## Properties
14    ///
15    ///
16    /// #### `created`
17    ///  The timestamp (in CLOCK_BOOTTIME milliseconds) of checkpoint creation.
18    ///
19    /// Readable
20    ///
21    ///
22    /// #### `devices`
23    ///  The devices that are part of this checkpoint.
24    ///
25    /// Readable
26    ///
27    ///
28    /// #### `rollback-timeout`
29    ///  Timeout in seconds for automatic rollback, or zero.
30    ///
31    /// Readable
32    /// <details><summary><h4>Object</h4></summary>
33    ///
34    ///
35    /// #### `client`
36    ///  The NMClient instance as returned by nm_object_get_client().
37    ///
38    /// When an NMObject gets removed from the NMClient cache,
39    /// the NMObject:path property stays unchanged, but this client
40    /// instance gets reset to [`None`]. You can use this property to
41    /// track removal of the object from the cache.
42    ///
43    /// Readable
44    ///
45    ///
46    /// #### `path`
47    ///  The D-Bus object path.
48    ///
49    /// The D-Bus path of an object instance never changes, even if the object
50    /// gets removed from the cache. To see whether the object is still in the
51    /// cache, check NMObject:client.
52    ///
53    /// Readable
54    /// </details>
55    ///
56    /// # Implements
57    ///
58    /// [`ObjectExt`][trait@crate::prelude::ObjectExt]
59    #[doc(alias = "NMCheckpoint")]
60    pub struct Checkpoint(Object<ffi::NMCheckpoint, ffi::NMCheckpointClass>) @extends Object;
61
62    match fn {
63        type_ => || ffi::nm_checkpoint_get_type(),
64    }
65}
66
67impl Checkpoint {
68    /// Gets the timestamp (in CLOCK_BOOTTIME milliseconds) of checkpoint creation.
69    ///
70    /// Use nm_utils_get_timestamp_msec() to obtain current time value suitable for
71    /// comparing to this value.
72    ///
73    /// # Returns
74    ///
75    /// the timestamp of checkpoint creation.
76    #[doc(alias = "nm_checkpoint_get_created")]
77    #[doc(alias = "get_created")]
78    pub fn created(&self) -> i64 {
79        unsafe {
80            ffi::nm_checkpoint_get_created(self.to_glib_none().0)
81        }
82    }
83
84    /// The devices that are part of this checkpoint.
85    ///
86    /// # Returns
87    ///
88    /// the devices list.
89    #[doc(alias = "nm_checkpoint_get_devices")]
90    #[doc(alias = "get_devices")]
91    pub fn devices(&self) -> Vec<Device> {
92        unsafe {
93            FromGlibPtrContainer::from_glib_none(ffi::nm_checkpoint_get_devices(self.to_glib_none().0))
94        }
95    }
96
97    /// Gets the timeout in seconds for automatic rollback.
98    ///
99    /// # Returns
100    ///
101    /// the rollback timeout.
102    #[doc(alias = "nm_checkpoint_get_rollback_timeout")]
103    #[doc(alias = "get_rollback_timeout")]
104    #[doc(alias = "rollback-timeout")]
105    pub fn rollback_timeout(&self) -> u32 {
106        unsafe {
107            ffi::nm_checkpoint_get_rollback_timeout(self.to_glib_none().0)
108        }
109    }
110
111    #[cfg(feature = "v1_12")]
112    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
113    #[doc(alias = "created")]
114    pub fn connect_created_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
115        unsafe extern "C" fn notify_created_trampoline<F: Fn(&Checkpoint) + 'static>(this: *mut ffi::NMCheckpoint, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
116            let f: &F = &*(f as *const F);
117            f(&from_glib_borrow(this))
118        }
119        unsafe {
120            let f: Box_<F> = Box_::new(f);
121            connect_raw(self.as_ptr() as *mut _, c"notify::created".as_ptr() as *const _,
122                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_created_trampoline::<F> as *const ())), Box_::into_raw(f))
123        }
124    }
125
126    #[cfg(feature = "v1_12")]
127    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
128    #[doc(alias = "devices")]
129    pub fn connect_devices_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
130        unsafe extern "C" fn notify_devices_trampoline<F: Fn(&Checkpoint) + 'static>(this: *mut ffi::NMCheckpoint, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
131            let f: &F = &*(f as *const F);
132            f(&from_glib_borrow(this))
133        }
134        unsafe {
135            let f: Box_<F> = Box_::new(f);
136            connect_raw(self.as_ptr() as *mut _, c"notify::devices".as_ptr() as *const _,
137                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_devices_trampoline::<F> as *const ())), Box_::into_raw(f))
138        }
139    }
140
141    #[cfg(feature = "v1_12")]
142    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
143    #[doc(alias = "rollback-timeout")]
144    pub fn connect_rollback_timeout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
145        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) {
146            let f: &F = &*(f as *const F);
147            f(&from_glib_borrow(this))
148        }
149        unsafe {
150            let f: Box_<F> = Box_::new(f);
151            connect_raw(self.as_ptr() as *mut _, c"notify::rollback-timeout".as_ptr() as *const _,
152                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_rollback_timeout_trampoline::<F> as *const ())), Box_::into_raw(f))
153        }
154    }
155}