gio/auto/
unix_mount_point.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, Icon};
6use glib::translate::*;
7
8glib::wrapper! {
9    /// Defines a Unix mount point (e.g. `/dev`).
10    /// This corresponds roughly to a fstab entry.
11    #[derive(Debug)]
12    pub struct UnixMountPoint(Boxed<ffi::GUnixMountPoint>);
13
14    match fn {
15        copy => |ptr| ffi::g_unix_mount_point_copy(mut_override(ptr)),
16        free => |ptr| ffi::g_unix_mount_point_free(ptr),
17        type_ => || ffi::g_unix_mount_point_get_type(),
18    }
19}
20
21impl UnixMountPoint {
22    #[doc(alias = "g_unix_mount_point_compare")]
23    fn compare(&self, mount2: &UnixMountPoint) -> i32 {
24        unsafe {
25            ffi::g_unix_mount_point_compare(
26                mut_override(self.to_glib_none().0),
27                mut_override(mount2.to_glib_none().0),
28            )
29        }
30    }
31
32    /// Gets the device path for a Unix mount point.
33    ///
34    /// # Returns
35    ///
36    /// a string containing the device path
37    #[doc(alias = "g_unix_mount_point_get_device_path")]
38    #[doc(alias = "get_device_path")]
39    pub fn device_path(&self) -> std::path::PathBuf {
40        unsafe {
41            from_glib_none(ffi::g_unix_mount_point_get_device_path(mut_override(
42                self.to_glib_none().0,
43            )))
44        }
45    }
46
47    /// Gets the file system type for the mount point.
48    ///
49    /// # Returns
50    ///
51    /// a string containing the file system type
52    #[doc(alias = "g_unix_mount_point_get_fs_type")]
53    #[doc(alias = "get_fs_type")]
54    pub fn fs_type(&self) -> glib::GString {
55        unsafe {
56            from_glib_none(ffi::g_unix_mount_point_get_fs_type(mut_override(
57                self.to_glib_none().0,
58            )))
59        }
60    }
61
62    /// Gets the mount path for a Unix mount point.
63    ///
64    /// # Returns
65    ///
66    /// a string containing the mount path
67    #[doc(alias = "g_unix_mount_point_get_mount_path")]
68    #[doc(alias = "get_mount_path")]
69    pub fn mount_path(&self) -> std::path::PathBuf {
70        unsafe {
71            from_glib_none(ffi::g_unix_mount_point_get_mount_path(mut_override(
72                self.to_glib_none().0,
73            )))
74        }
75    }
76
77    /// Gets the options for the mount point.
78    ///
79    /// # Returns
80    ///
81    /// a string containing the options
82    #[doc(alias = "g_unix_mount_point_get_options")]
83    #[doc(alias = "get_options")]
84    pub fn options(&self) -> Option<glib::GString> {
85        unsafe {
86            from_glib_none(ffi::g_unix_mount_point_get_options(mut_override(
87                self.to_glib_none().0,
88            )))
89        }
90    }
91
92    /// Guesses whether a Unix mount point can be ejected.
93    ///
94    /// # Returns
95    ///
96    /// true if @self is deemed to be ejectable; false otherwise
97    #[doc(alias = "g_unix_mount_point_guess_can_eject")]
98    pub fn guess_can_eject(&self) -> bool {
99        unsafe {
100            from_glib(ffi::g_unix_mount_point_guess_can_eject(mut_override(
101                self.to_glib_none().0,
102            )))
103        }
104    }
105
106    /// Guesses the icon of a Unix mount point.
107    ///
108    /// # Returns
109    ///
110    /// a [`Icon`][crate::Icon]
111    #[doc(alias = "g_unix_mount_point_guess_icon")]
112    pub fn guess_icon(&self) -> Icon {
113        unsafe {
114            from_glib_full(ffi::g_unix_mount_point_guess_icon(mut_override(
115                self.to_glib_none().0,
116            )))
117        }
118    }
119
120    /// Guesses the name of a Unix mount point.
121    ///
122    /// The result is a translated string.
123    ///
124    /// # Returns
125    ///
126    /// a newly allocated translated string
127    #[doc(alias = "g_unix_mount_point_guess_name")]
128    pub fn guess_name(&self) -> glib::GString {
129        unsafe {
130            from_glib_full(ffi::g_unix_mount_point_guess_name(mut_override(
131                self.to_glib_none().0,
132            )))
133        }
134    }
135
136    /// Guesses the symbolic icon of a Unix mount point.
137    ///
138    /// # Returns
139    ///
140    /// a [`Icon`][crate::Icon]
141    #[doc(alias = "g_unix_mount_point_guess_symbolic_icon")]
142    pub fn guess_symbolic_icon(&self) -> Icon {
143        unsafe {
144            from_glib_full(ffi::g_unix_mount_point_guess_symbolic_icon(mut_override(
145                self.to_glib_none().0,
146            )))
147        }
148    }
149
150    /// Checks if a Unix mount point is a loopback device.
151    ///
152    /// # Returns
153    ///
154    /// true if the mount point is a loopback device; false otherwise
155    #[doc(alias = "g_unix_mount_point_is_loopback")]
156    pub fn is_loopback(&self) -> bool {
157        unsafe {
158            from_glib(ffi::g_unix_mount_point_is_loopback(mut_override(
159                self.to_glib_none().0,
160            )))
161        }
162    }
163
164    /// Checks if a Unix mount point is read only.
165    ///
166    /// # Returns
167    ///
168    /// true if a mount point is read only; false otherwise
169    #[doc(alias = "g_unix_mount_point_is_readonly")]
170    pub fn is_readonly(&self) -> bool {
171        unsafe {
172            from_glib(ffi::g_unix_mount_point_is_readonly(mut_override(
173                self.to_glib_none().0,
174            )))
175        }
176    }
177
178    /// Checks if a Unix mount point is mountable by the user.
179    ///
180    /// # Returns
181    ///
182    /// true if the mount point is user mountable; false otherwise
183    #[doc(alias = "g_unix_mount_point_is_user_mountable")]
184    pub fn is_user_mountable(&self) -> bool {
185        unsafe {
186            from_glib(ffi::g_unix_mount_point_is_user_mountable(mut_override(
187                self.to_glib_none().0,
188            )))
189        }
190    }
191
192    /// Gets a `GioUnix::MountPoint` for a given mount path.
193    ///
194    /// If @time_read is set, it will be filled with a Unix timestamp for checking if
195    /// the mount points have changed since with
196    /// `mount_points_changed_since()`.
197    ///
198    /// If more mount points have the same mount path, the last matching mount point
199    /// is returned.
200    /// ## `mount_path`
201    /// path for a possible Unix mount point
202    ///
203    /// # Returns
204    ///
205    /// a `GioUnix::MountPoint`, or `NULL`
206    ///    if no match is found
207    ///
208    /// ## `time_read`
209    /// return location for a timestamp
210    #[cfg(feature = "v2_66")]
211    #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
212    #[doc(alias = "g_unix_mount_point_at")]
213    pub fn at(mount_path: impl AsRef<std::path::Path>) -> (Option<UnixMountPoint>, u64) {
214        unsafe {
215            let mut time_read = std::mem::MaybeUninit::uninit();
216            let ret = from_glib_full(ffi::g_unix_mount_point_at(
217                mount_path.as_ref().to_glib_none().0,
218                time_read.as_mut_ptr(),
219            ));
220            (ret, time_read.assume_init())
221        }
222    }
223}
224
225impl PartialEq for UnixMountPoint {
226    #[inline]
227    fn eq(&self, other: &Self) -> bool {
228        self.compare(other) == 0
229    }
230}
231
232impl Eq for UnixMountPoint {}
233
234impl PartialOrd for UnixMountPoint {
235    #[inline]
236    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
237        Some(self.cmp(other))
238    }
239}
240
241impl Ord for UnixMountPoint {
242    #[inline]
243    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
244        self.compare(other).cmp(&0)
245    }
246}
247
248unsafe impl Send for UnixMountPoint {}
249unsafe impl Sync for UnixMountPoint {}