1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::Icon;
use crate::UnixMountEntry;
use glib::translate::*;
use glib::GString;
use std::cmp;
use std::mem;

impl UnixMountEntry {
    #[doc(alias = "g_unix_mount_at")]
    #[doc(alias = "new_at")]
    pub fn for_mount_path<P: AsRef<std::path::Path>>(
        mount_path: P,
    ) -> (Option<UnixMountEntry>, u64) {
        unsafe {
            let mut time_read = mem::MaybeUninit::uninit();
            let ret = from_glib_full(ffi::g_unix_mount_at(
                mount_path.as_ref().to_glib_none().0,
                time_read.as_mut_ptr(),
            ));
            let time_read = time_read.assume_init();
            (ret, time_read)
        }
    }

    #[doc(alias = "g_unix_mount_for")]
    #[doc(alias = "new_for")]
    pub fn for_file_path<P: AsRef<std::path::Path>>(file_path: P) -> (Option<UnixMountEntry>, u64) {
        unsafe {
            let mut time_read = mem::MaybeUninit::uninit();
            let ret = from_glib_full(ffi::g_unix_mount_for(
                file_path.as_ref().to_glib_none().0,
                time_read.as_mut_ptr(),
            ));
            let time_read = time_read.assume_init();
            (ret, time_read)
        }
    }

    #[doc(alias = "g_unix_mounts_get")]
    #[doc(alias = "get_mounts")]
    pub fn mounts() -> (Vec<UnixMountEntry>, u64) {
        unsafe {
            let mut time_read = mem::MaybeUninit::uninit();
            let ret = FromGlibPtrContainer::from_glib_full(ffi::g_unix_mounts_get(
                time_read.as_mut_ptr(),
            ));
            let time_read = time_read.assume_init();
            (ret, time_read)
        }
    }

    #[doc(alias = "g_unix_mount_compare")]
    pub fn compare(&self, mount2: &UnixMountEntry) -> i32 {
        unsafe {
            ffi::g_unix_mount_compare(
                mut_override(self.to_glib_none().0),
                mut_override(mount2.to_glib_none().0),
            )
        }
    }

    #[doc(alias = "g_unix_mount_get_device_path")]
    #[doc(alias = "get_device_path")]
    pub fn device_path(&self) -> std::path::PathBuf {
        unsafe {
            from_glib_none(ffi::g_unix_mount_get_device_path(mut_override(
                self.to_glib_none().0,
            )))
        }
    }

    #[doc(alias = "g_unix_mount_get_fs_type")]
    #[doc(alias = "get_fs_type")]
    pub fn fs_type(&self) -> GString {
        unsafe {
            from_glib_none(ffi::g_unix_mount_get_fs_type(mut_override(
                self.to_glib_none().0,
            )))
        }
    }

    #[doc(alias = "g_unix_mount_get_mount_path")]
    pub fn unix_mount_get_mount_path(&self) -> std::path::PathBuf {
        unsafe {
            from_glib_none(ffi::g_unix_mount_get_mount_path(mut_override(
                self.to_glib_none().0,
            )))
        }
    }

    #[cfg(any(feature = "v2_58", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))]
    #[doc(alias = "g_unix_mount_get_options")]
    #[doc(alias = "get_options")]
    pub fn options(&self) -> Option<GString> {
        unsafe {
            from_glib_none(ffi::g_unix_mount_get_options(mut_override(
                self.to_glib_none().0,
            )))
        }
    }

    #[cfg(any(feature = "v2_60", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
    #[doc(alias = "g_unix_mount_get_root_path")]
    #[doc(alias = "get_root_path")]
    pub fn root_path(&self) -> Option<std::path::PathBuf> {
        unsafe {
            from_glib_none(ffi::g_unix_mount_get_root_path(mut_override(
                self.to_glib_none().0,
            )))
        }
    }

    #[doc(alias = "g_unix_mount_guess_can_eject")]
    pub fn guess_can_eject(&self) -> bool {
        unsafe {
            from_glib(ffi::g_unix_mount_guess_can_eject(mut_override(
                self.to_glib_none().0,
            )))
        }
    }

    #[doc(alias = "g_unix_mount_guess_icon")]
    pub fn guess_icon(&self) -> Icon {
        unsafe {
            from_glib_full(ffi::g_unix_mount_guess_icon(mut_override(
                self.to_glib_none().0,
            )))
        }
    }

    #[doc(alias = "g_unix_mount_guess_name")]
    pub fn guess_name(&self) -> GString {
        unsafe {
            from_glib_full(ffi::g_unix_mount_guess_name(mut_override(
                self.to_glib_none().0,
            )))
        }
    }

    #[doc(alias = "g_unix_mount_guess_should_display")]
    pub fn guess_should_display(&self) -> bool {
        unsafe {
            from_glib(ffi::g_unix_mount_guess_should_display(mut_override(
                self.to_glib_none().0,
            )))
        }
    }

    #[doc(alias = "g_unix_mount_guess_symbolic_icon")]
    pub fn guess_symbolic_icon(&self) -> Icon {
        unsafe {
            from_glib_full(ffi::g_unix_mount_guess_symbolic_icon(mut_override(
                self.to_glib_none().0,
            )))
        }
    }

    #[doc(alias = "g_unix_mount_is_readonly")]
    pub fn is_readonly(&self) -> bool {
        unsafe {
            from_glib(ffi::g_unix_mount_is_readonly(mut_override(
                self.to_glib_none().0,
            )))
        }
    }

    #[doc(alias = "g_unix_mount_is_system_internal")]
    pub fn is_system_internal(&self) -> bool {
        unsafe {
            from_glib(ffi::g_unix_mount_is_system_internal(mut_override(
                self.to_glib_none().0,
            )))
        }
    }

    #[doc(alias = "g_unix_mounts_changed_since")]
    pub fn is_changed_since(time: u64) -> bool {
        unsafe { from_glib(ffi::g_unix_mounts_changed_since(time)) }
    }
}

impl PartialEq for UnixMountEntry {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.compare(other) == 0
    }
}

impl Eq for UnixMountEntry {}

impl PartialOrd for UnixMountEntry {
    #[inline]
    fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
        self.compare(other).partial_cmp(&0)
    }
}

impl Ord for UnixMountEntry {
    #[inline]
    fn cmp(&self, other: &Self) -> cmp::Ordering {
        self.compare(other).cmp(&0)
    }
}