gio/auto/unix_mount_entry.rs
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 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{ffi, Icon};
use glib::translate::*;
glib::wrapper! {
/// Defines a Unix mount entry (e.g. `/media/cdrom`).
/// This corresponds roughly to a mtab entry.
#[derive(Debug)]
pub struct UnixMountEntry(Boxed<ffi::GUnixMountEntry>);
match fn {
copy => |ptr| ffi::g_unix_mount_entry_copy(mut_override(ptr)),
free => |ptr| ffi::g_unix_mount_entry_free(ptr),
type_ => || ffi::g_unix_mount_entry_get_type(),
}
}
impl UnixMountEntry {
#[doc(alias = "g_unix_mount_entry_compare")]
fn compare(&self, mount2: &UnixMountEntry) -> i32 {
unsafe {
ffi::g_unix_mount_entry_compare(
mut_override(self.to_glib_none().0),
mut_override(mount2.to_glib_none().0),
)
}
}
/// Gets the device path for a unix mount.
///
/// # Returns
///
/// a string containing the device path.
#[doc(alias = "g_unix_mount_entry_get_device_path")]
#[doc(alias = "get_device_path")]
pub fn device_path(&self) -> std::path::PathBuf {
unsafe {
from_glib_none(ffi::g_unix_mount_entry_get_device_path(mut_override(
self.to_glib_none().0,
)))
}
}
/// Gets the filesystem type for the unix mount.
///
/// # Returns
///
/// a string containing the file system type.
#[doc(alias = "g_unix_mount_entry_get_fs_type")]
#[doc(alias = "get_fs_type")]
pub fn fs_type(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::g_unix_mount_entry_get_fs_type(mut_override(
self.to_glib_none().0,
)))
}
}
/// Gets the mount path for a unix mount.
///
/// # Returns
///
/// the mount path for @self.
#[doc(alias = "g_unix_mount_entry_get_mount_path")]
#[doc(alias = "get_mount_path")]
pub fn mount_path(&self) -> std::path::PathBuf {
unsafe {
from_glib_none(ffi::g_unix_mount_entry_get_mount_path(mut_override(
self.to_glib_none().0,
)))
}
}
/// Gets a comma-separated list of mount options for the unix mount. For example,
/// `rw,relatime,seclabel,data=ordered`.
///
/// This is similar to g_unix_mount_point_get_options(), but it takes
/// a #GUnixMountEntry as an argument.
///
/// # Returns
///
/// a string containing the options, or [`None`] if not
/// available.
#[cfg(feature = "v2_58")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
#[doc(alias = "g_unix_mount_entry_get_options")]
#[doc(alias = "get_options")]
pub fn options(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::g_unix_mount_entry_get_options(mut_override(
self.to_glib_none().0,
)))
}
}
/// Gets the root of the mount within the filesystem. This is useful e.g. for
/// mounts created by bind operation, or btrfs subvolumes.
///
/// For example, the root path is equal to "/" for mount created by
/// "mount /dev/sda1 /mnt/foo" and "/bar" for
/// "mount --bind /mnt/foo/bar /mnt/bar".
///
/// # Returns
///
/// a string containing the root, or [`None`] if not supported.
#[cfg(feature = "v2_60")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
#[doc(alias = "g_unix_mount_entry_get_root_path")]
#[doc(alias = "get_root_path")]
pub fn root_path(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::g_unix_mount_entry_get_root_path(mut_override(
self.to_glib_none().0,
)))
}
}
/// Guesses whether a Unix mount can be ejected.
///
/// # Returns
///
/// [`true`] if @self is deemed to be ejectable.
#[doc(alias = "g_unix_mount_entry_guess_can_eject")]
pub fn guess_can_eject(&self) -> bool {
unsafe {
from_glib(ffi::g_unix_mount_entry_guess_can_eject(mut_override(
self.to_glib_none().0,
)))
}
}
/// Guesses the icon of a Unix mount.
///
/// # Returns
///
/// a #GIcon
#[doc(alias = "g_unix_mount_entry_guess_icon")]
pub fn guess_icon(&self) -> Icon {
unsafe {
from_glib_full(ffi::g_unix_mount_entry_guess_icon(mut_override(
self.to_glib_none().0,
)))
}
}
/// Guesses the name of a Unix mount.
/// The result is a translated string.
///
/// # Returns
///
/// A newly allocated string that must
/// be freed with g_free()
#[doc(alias = "g_unix_mount_entry_guess_name")]
pub fn guess_name(&self) -> glib::GString {
unsafe {
from_glib_full(ffi::g_unix_mount_entry_guess_name(mut_override(
self.to_glib_none().0,
)))
}
}
/// Guesses whether a Unix mount should be displayed in the UI.
///
/// # Returns
///
/// [`true`] if @self is deemed to be displayable.
#[doc(alias = "g_unix_mount_entry_guess_should_display")]
pub fn guess_should_display(&self) -> bool {
unsafe {
from_glib(ffi::g_unix_mount_entry_guess_should_display(mut_override(
self.to_glib_none().0,
)))
}
}
/// Guesses the symbolic icon of a Unix mount.
///
/// # Returns
///
/// a #GIcon
#[doc(alias = "g_unix_mount_entry_guess_symbolic_icon")]
pub fn guess_symbolic_icon(&self) -> Icon {
unsafe {
from_glib_full(ffi::g_unix_mount_entry_guess_symbolic_icon(mut_override(
self.to_glib_none().0,
)))
}
}
/// Checks if a unix mount is mounted read only.
///
/// # Returns
///
/// [`true`] if @self is read only.
#[doc(alias = "g_unix_mount_entry_is_readonly")]
pub fn is_readonly(&self) -> bool {
unsafe {
from_glib(ffi::g_unix_mount_entry_is_readonly(mut_override(
self.to_glib_none().0,
)))
}
}
/// Checks if a Unix mount is a system mount. This is the Boolean OR of
/// g_unix_is_system_fs_type(), g_unix_is_system_device_path() and
/// g_unix_is_mount_path_system_internal() on @self’s properties.
///
/// The definition of what a ‘system’ mount entry is may change over time as new
/// file system types and device paths are ignored.
///
/// # Returns
///
/// [`true`] if the unix mount is for a system path.
#[doc(alias = "g_unix_mount_entry_is_system_internal")]
pub fn is_system_internal(&self) -> bool {
unsafe {
from_glib(ffi::g_unix_mount_entry_is_system_internal(mut_override(
self.to_glib_none().0,
)))
}
}
/// Gets a #GUnixMountEntry for a given mount path. If @time_read
/// is set, it will be filled with a unix timestamp for checking
/// if the mounts have changed since with g_unix_mount_entries_changed_since().
///
/// If more mounts have the same mount path, the last matching mount
/// is returned.
///
/// This will return [`None`] if there is no mount point at @mount_path.
/// ## `mount_path`
/// path for a possible unix mount.
///
/// # Returns
///
/// a #GUnixMountEntry.
///
/// ## `time_read`
/// guint64 to contain a timestamp.
#[doc(alias = "g_unix_mount_entry_at")]
#[doc(alias = "at")]
pub fn for_mount_path(
mount_path: impl AsRef<std::path::Path>,
) -> (Option<UnixMountEntry>, u64) {
unsafe {
let mut time_read = std::mem::MaybeUninit::uninit();
let ret = from_glib_full(ffi::g_unix_mount_entry_at(
mount_path.as_ref().to_glib_none().0,
time_read.as_mut_ptr(),
));
(ret, time_read.assume_init())
}
}
/// Gets a #GUnixMountEntry for a given file path. If @time_read
/// is set, it will be filled with a unix timestamp for checking
/// if the mounts have changed since with g_unix_mount_entries_changed_since().
///
/// If more mounts have the same mount path, the last matching mount
/// is returned.
///
/// This will return [`None`] if looking up the mount entry fails, if
/// @file_path doesn’t exist or there is an I/O error.
/// ## `file_path`
/// file path on some unix mount.
///
/// # Returns
///
/// a #GUnixMountEntry.
///
/// ## `time_read`
/// guint64 to contain a timestamp.
#[doc(alias = "g_unix_mount_entry_for")]
#[doc(alias = "for")]
pub fn for_file_path(file_path: impl AsRef<std::path::Path>) -> (Option<UnixMountEntry>, u64) {
unsafe {
let mut time_read = std::mem::MaybeUninit::uninit();
let ret = from_glib_full(ffi::g_unix_mount_entry_for(
file_path.as_ref().to_glib_none().0,
time_read.as_mut_ptr(),
));
(ret, time_read.assume_init())
}
}
}
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<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl Ord for UnixMountEntry {
#[inline]
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.compare(other).cmp(&0)
}
}
unsafe impl Send for UnixMountEntry {}
unsafe impl Sync for UnixMountEntry {}