Trait gio::prelude::MountExt

source ·
pub trait MountExt: 'static {
Show 26 methods // Required methods fn can_eject(&self) -> bool; fn can_unmount(&self) -> bool; fn eject_with_operation<P: FnOnce(Result<(), Error>) + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA<MountOperation>>, cancellable: Option<&impl IsA<Cancellable>>, callback: P ); fn eject_with_operation_future( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA<MountOperation> + Clone + 'static> ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>; fn default_location(&self) -> File; fn drive(&self) -> Option<Drive>; fn icon(&self) -> Icon; fn name(&self) -> GString; fn root(&self) -> File; fn sort_key(&self) -> Option<GString>; fn symbolic_icon(&self) -> Icon; fn uuid(&self) -> Option<GString>; fn volume(&self) -> Option<Volume>; fn guess_content_type<P: FnOnce(Result<Vec<GString>, Error>) + 'static>( &self, force_rescan: bool, cancellable: Option<&impl IsA<Cancellable>>, callback: P ); fn guess_content_type_future( &self, force_rescan: bool ) -> Pin<Box_<dyn Future<Output = Result<Vec<GString>, Error>> + 'static>>; fn guess_content_type_sync( &self, force_rescan: bool, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<Vec<GString>, Error>; fn is_shadowed(&self) -> bool; fn remount<P: FnOnce(Result<(), Error>) + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&impl IsA<MountOperation>>, cancellable: Option<&impl IsA<Cancellable>>, callback: P ); fn remount_future( &self, flags: MountMountFlags, mount_operation: Option<&impl IsA<MountOperation> + Clone + 'static> ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>; fn shadow(&self); fn unmount_with_operation<P: FnOnce(Result<(), Error>) + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA<MountOperation>>, cancellable: Option<&impl IsA<Cancellable>>, callback: P ); fn unmount_with_operation_future( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA<MountOperation> + Clone + 'static> ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>; fn unshadow(&self); fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; fn connect_pre_unmount<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId; fn connect_unmounted<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
Expand description

Trait containing all Mount methods.

Implementors

Mount

Required Methods§

source

fn can_eject(&self) -> bool

Checks if self can be ejected.

Returns

true if the self can be ejected.

source

fn can_unmount(&self) -> bool

Checks if self can be unmounted.

Returns

true if the self can be unmounted.

source

fn eject_with_operation<P: FnOnce(Result<(), Error>) + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA<MountOperation>>, cancellable: Option<&impl IsA<Cancellable>>, callback: P )

Ejects a mount. This is an asynchronous operation, and is finished by calling g_mount_eject_with_operation_finish() with the self and AsyncResult data returned in the callback.

flags

flags affecting the unmount if required for eject

mount_operation

a MountOperation or None to avoid user interaction.

cancellable

optional Cancellable object, None to ignore.

callback

a GAsyncReadyCallback, or None.

source

fn eject_with_operation_future( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA<MountOperation> + Clone + 'static> ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>

source

fn default_location(&self) -> File

Gets the default location of self. The default location of the given self is a path that reflects the main entry point for the user (e.g. the home directory, or the root of the volume).

Returns

a File. The returned object should be unreffed with g_object_unref() when no longer needed.

source

fn drive(&self) -> Option<Drive>

Gets the drive for the self.

This is a convenience method for getting the Volume and then using that object to get the Drive.

Returns

a Drive or None if self is not associated with a volume or a drive. The returned object should be unreffed with g_object_unref() when no longer needed.

source

fn icon(&self) -> Icon

Gets the icon for self.

Returns

a Icon. The returned object should be unreffed with g_object_unref() when no longer needed.

source

fn name(&self) -> GString

Gets the name of self.

Returns

the name for the given self. The returned string should be freed with g_free() when no longer needed.

source

fn root(&self) -> File

Gets the root directory on self.

Returns

a File. The returned object should be unreffed with g_object_unref() when no longer needed.

source

fn sort_key(&self) -> Option<GString>

Gets the sort key for self, if any.

Returns

Sorting key for self or None if no such key is available.

source

fn symbolic_icon(&self) -> Icon

Gets the symbolic icon for self.

Returns

a Icon. The returned object should be unreffed with g_object_unref() when no longer needed.

source

fn uuid(&self) -> Option<GString>

Gets the UUID for the self. The reference is typically based on the file system UUID for the mount in question and should be considered an opaque string. Returns None if there is no UUID available.

Returns

the UUID for self or None if no UUID can be computed. The returned string should be freed with g_free() when no longer needed.

source

fn volume(&self) -> Option<Volume>

Gets the volume for the self.

Returns

a Volume or None if self is not associated with a volume. The returned object should be unreffed with g_object_unref() when no longer needed.

source

fn guess_content_type<P: FnOnce(Result<Vec<GString>, Error>) + 'static>( &self, force_rescan: bool, cancellable: Option<&impl IsA<Cancellable>>, callback: P )

Tries to guess the type of content stored on self. Returns one or more textual identifiers of well-known content types (typically prefixed with “x-content/”), e.g. x-content/image-dcf for camera memory cards. See the shared-mime-info specification for more on x-content types.

This is an asynchronous operation (see guess_content_type_sync() for the synchronous version), and is finished by calling g_mount_guess_content_type_finish() with the self and AsyncResult data returned in the callback.

force_rescan

Whether to force a rescan of the content. Otherwise a cached result will be used if available

cancellable

optional Cancellable object, None to ignore

callback

a GAsyncReadyCallback

source

fn guess_content_type_future( &self, force_rescan: bool ) -> Pin<Box_<dyn Future<Output = Result<Vec<GString>, Error>> + 'static>>

source

fn guess_content_type_sync( &self, force_rescan: bool, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<Vec<GString>, Error>

Tries to guess the type of content stored on self. Returns one or more textual identifiers of well-known content types (typically prefixed with “x-content/”), e.g. x-content/image-dcf for camera memory cards. See the shared-mime-info specification for more on x-content types.

This is a synchronous operation and as such may block doing IO; see guess_content_type() for the asynchronous version.

force_rescan

Whether to force a rescan of the content. Otherwise a cached result will be used if available

cancellable

optional Cancellable object, None to ignore

Returns

a None-terminated array of content types or None on error. Caller should free this array with g_strfreev() when done with it.

source

fn is_shadowed(&self) -> bool

Determines if self is shadowed. Applications or libraries should avoid displaying self in the user interface if it is shadowed.

A mount is said to be shadowed if there exists one or more user visible objects (currently Mount objects) with a root that is inside the root of self.

One application of shadow mounts is when exposing a single file system that is used to address several logical volumes. In this situation, a VolumeMonitor implementation would create two Volume objects (for example, one for the camera functionality of the device and one for a SD card reader on the device) with activation URIs gphoto2://[usb:001,002]/store1/ and gphoto2://[usb:001,002]/store2/. When the underlying mount (with root gphoto2://[usb:001,002]/) is mounted, said VolumeMonitor implementation would create two Mount objects (each with their root matching the corresponding volume activation root) that would shadow the original mount.

The proxy monitor in GVfs 2.26 and later, automatically creates and manage shadow mounts (and shadows the underlying mount) if the activation root on a Volume is set.

Returns

true if self is shadowed.

source

fn remount<P: FnOnce(Result<(), Error>) + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&impl IsA<MountOperation>>, cancellable: Option<&impl IsA<Cancellable>>, callback: P )

Remounts a mount. This is an asynchronous operation, and is finished by calling g_mount_remount_finish() with the self and GAsyncResults data returned in the callback.

Remounting is useful when some setting affecting the operation of the volume has been changed, as these may need a remount to take affect. While this is semantically equivalent with unmounting and then remounting not all backends might need to actually be unmounted.

flags

flags affecting the operation

mount_operation

a MountOperation or None to avoid user interaction.

cancellable

optional Cancellable object, None to ignore.

callback

a GAsyncReadyCallback, or None.

source

fn remount_future( &self, flags: MountMountFlags, mount_operation: Option<&impl IsA<MountOperation> + Clone + 'static> ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>

source

fn shadow(&self)

Increments the shadow count on self. Usually used by VolumeMonitor implementations when creating a shadow mount for self, see is_shadowed() for more information. The caller will need to emit the signal::Mount::changed signal on self manually.

source

fn unmount_with_operation<P: FnOnce(Result<(), Error>) + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA<MountOperation>>, cancellable: Option<&impl IsA<Cancellable>>, callback: P )

Unmounts a mount. This is an asynchronous operation, and is finished by calling g_mount_unmount_with_operation_finish() with the self and AsyncResult data returned in the callback.

flags

flags affecting the operation

mount_operation

a MountOperation or None to avoid user interaction.

cancellable

optional Cancellable object, None to ignore.

callback

a GAsyncReadyCallback, or None.

source

fn unmount_with_operation_future( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA<MountOperation> + Clone + 'static> ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>

source

fn unshadow(&self)

Decrements the shadow count on self. Usually used by VolumeMonitor implementations when destroying a shadow mount for self, see is_shadowed() for more information. The caller will need to emit the signal::Mount::changed signal on self manually.

source

fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Emitted when the mount has been changed.

source

fn connect_pre_unmount<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

This signal may be emitted when the Mount is about to be unmounted.

This signal depends on the backend and is only emitted if GIO was used to unmount.

source

fn connect_unmounted<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

This signal is emitted when the Mount have been unmounted. If the recipient is holding references to the object they should release them so the object can be finalized.

Implementors§

source§

impl<O: IsA<Mount>> MountExt for O