1 // Take a look at the license at the top of the repository in the LICENSE file.
2 
3 use crate::Icon;
4 use crate::UnixMountEntry;
5 use glib::translate::*;
6 use glib::GString;
7 use std::cmp;
8 use std::mem;
9 
10 impl UnixMountEntry {
11     #[doc(alias = "g_unix_mount_at")]
12     #[doc(alias = "new_at")]
for_mount_path<P: AsRef<std::path::Path>>( mount_path: P, ) -> (Option<UnixMountEntry>, u64)13     pub fn for_mount_path<P: AsRef<std::path::Path>>(
14         mount_path: P,
15     ) -> (Option<UnixMountEntry>, u64) {
16         unsafe {
17             let mut time_read = mem::MaybeUninit::uninit();
18             let ret = from_glib_full(ffi::g_unix_mount_at(
19                 mount_path.as_ref().to_glib_none().0,
20                 time_read.as_mut_ptr(),
21             ));
22             let time_read = time_read.assume_init();
23             (ret, time_read)
24         }
25     }
26 
27     #[cfg(any(feature = "v2_52", feature = "dox"))]
28     #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_52")))]
29     #[doc(alias = "g_unix_mount_for")]
30     #[doc(alias = "new_for")]
for_file_path<P: AsRef<std::path::Path>>(file_path: P) -> (Option<UnixMountEntry>, u64)31     pub fn for_file_path<P: AsRef<std::path::Path>>(file_path: P) -> (Option<UnixMountEntry>, u64) {
32         unsafe {
33             let mut time_read = mem::MaybeUninit::uninit();
34             let ret = from_glib_full(ffi::g_unix_mount_for(
35                 file_path.as_ref().to_glib_none().0,
36                 time_read.as_mut_ptr(),
37             ));
38             let time_read = time_read.assume_init();
39             (ret, time_read)
40         }
41     }
42 
43     #[doc(alias = "g_unix_mounts_get")]
44     #[doc(alias = "get_mounts")]
mounts() -> (Vec<UnixMountEntry>, u64)45     pub fn mounts() -> (Vec<UnixMountEntry>, u64) {
46         unsafe {
47             let mut time_read = mem::MaybeUninit::uninit();
48             let ret = FromGlibPtrContainer::from_glib_full(ffi::g_unix_mounts_get(
49                 time_read.as_mut_ptr(),
50             ));
51             let time_read = time_read.assume_init();
52             (ret, time_read)
53         }
54     }
55 
56     #[doc(alias = "g_unix_mount_compare")]
compare(&self, mount2: &UnixMountEntry) -> i3257     pub fn compare(&self, mount2: &UnixMountEntry) -> i32 {
58         unsafe {
59             ffi::g_unix_mount_compare(
60                 mut_override(self.to_glib_none().0),
61                 mut_override(mount2.to_glib_none().0),
62             )
63         }
64     }
65 
66     #[doc(alias = "g_unix_mount_get_device_path")]
67     #[doc(alias = "get_device_path")]
device_path(&self) -> std::path::PathBuf68     pub fn device_path(&self) -> std::path::PathBuf {
69         unsafe {
70             from_glib_none(ffi::g_unix_mount_get_device_path(mut_override(
71                 self.to_glib_none().0,
72             )))
73         }
74     }
75 
76     #[doc(alias = "g_unix_mount_get_fs_type")]
77     #[doc(alias = "get_fs_type")]
fs_type(&self) -> GString78     pub fn fs_type(&self) -> GString {
79         unsafe {
80             from_glib_none(ffi::g_unix_mount_get_fs_type(mut_override(
81                 self.to_glib_none().0,
82             )))
83         }
84     }
85 
86     #[doc(alias = "g_unix_mount_get_mount_path")]
unix_mount_get_mount_path(&self) -> std::path::PathBuf87     pub fn unix_mount_get_mount_path(&self) -> std::path::PathBuf {
88         unsafe {
89             from_glib_none(ffi::g_unix_mount_get_mount_path(mut_override(
90                 self.to_glib_none().0,
91             )))
92         }
93     }
94 
95     #[cfg(any(feature = "v2_58", feature = "dox"))]
96     #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))]
97     #[doc(alias = "g_unix_mount_get_options")]
98     #[doc(alias = "get_options")]
options(&self) -> Option<GString>99     pub fn options(&self) -> Option<GString> {
100         unsafe {
101             from_glib_none(ffi::g_unix_mount_get_options(mut_override(
102                 self.to_glib_none().0,
103             )))
104         }
105     }
106 
107     #[cfg(any(feature = "v2_60", feature = "dox"))]
108     #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
109     #[doc(alias = "g_unix_mount_get_root_path")]
110     #[doc(alias = "get_root_path")]
root_path(&self) -> Option<std::path::PathBuf>111     pub fn root_path(&self) -> Option<std::path::PathBuf> {
112         unsafe {
113             from_glib_none(ffi::g_unix_mount_get_root_path(mut_override(
114                 self.to_glib_none().0,
115             )))
116         }
117     }
118 
119     #[doc(alias = "g_unix_mount_guess_can_eject")]
guess_can_eject(&self) -> bool120     pub fn guess_can_eject(&self) -> bool {
121         unsafe {
122             from_glib(ffi::g_unix_mount_guess_can_eject(mut_override(
123                 self.to_glib_none().0,
124             )))
125         }
126     }
127 
128     #[doc(alias = "g_unix_mount_guess_icon")]
guess_icon(&self) -> Icon129     pub fn guess_icon(&self) -> Icon {
130         unsafe {
131             from_glib_full(ffi::g_unix_mount_guess_icon(mut_override(
132                 self.to_glib_none().0,
133             )))
134         }
135     }
136 
137     #[doc(alias = "g_unix_mount_guess_name")]
guess_name(&self) -> GString138     pub fn guess_name(&self) -> GString {
139         unsafe {
140             from_glib_full(ffi::g_unix_mount_guess_name(mut_override(
141                 self.to_glib_none().0,
142             )))
143         }
144     }
145 
146     #[doc(alias = "g_unix_mount_guess_should_display")]
guess_should_display(&self) -> bool147     pub fn guess_should_display(&self) -> bool {
148         unsafe {
149             from_glib(ffi::g_unix_mount_guess_should_display(mut_override(
150                 self.to_glib_none().0,
151             )))
152         }
153     }
154 
155     #[doc(alias = "g_unix_mount_guess_symbolic_icon")]
guess_symbolic_icon(&self) -> Icon156     pub fn guess_symbolic_icon(&self) -> Icon {
157         unsafe {
158             from_glib_full(ffi::g_unix_mount_guess_symbolic_icon(mut_override(
159                 self.to_glib_none().0,
160             )))
161         }
162     }
163 
164     #[doc(alias = "g_unix_mount_is_readonly")]
is_readonly(&self) -> bool165     pub fn is_readonly(&self) -> bool {
166         unsafe {
167             from_glib(ffi::g_unix_mount_is_readonly(mut_override(
168                 self.to_glib_none().0,
169             )))
170         }
171     }
172 
173     #[doc(alias = "g_unix_mount_is_system_internal")]
is_system_internal(&self) -> bool174     pub fn is_system_internal(&self) -> bool {
175         unsafe {
176             from_glib(ffi::g_unix_mount_is_system_internal(mut_override(
177                 self.to_glib_none().0,
178             )))
179         }
180     }
181 
182     #[doc(alias = "g_unix_mounts_changed_since")]
is_changed_since(time: u64) -> bool183     pub fn is_changed_since(time: u64) -> bool {
184         unsafe { from_glib(ffi::g_unix_mounts_changed_since(time)) }
185     }
186 }
187 
188 impl PartialEq for UnixMountEntry {
189     #[inline]
eq(&self, other: &Self) -> bool190     fn eq(&self, other: &Self) -> bool {
191         self.compare(other) == 0
192     }
193 }
194 
195 impl Eq for UnixMountEntry {}
196 
197 impl PartialOrd for UnixMountEntry {
198     #[inline]
partial_cmp(&self, other: &Self) -> Option<cmp::Ordering>199     fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
200         self.compare(other).partial_cmp(&0)
201     }
202 }
203 
204 impl Ord for UnixMountEntry {
205     #[inline]
cmp(&self, other: &Self) -> cmp::Ordering206     fn cmp(&self, other: &Self) -> cmp::Ordering {
207         self.compare(other).cmp(&0)
208     }
209 }
210