Struct Client

Source
pub struct Client { /* private fields */ }
Expand description

Utility routines for accessing the UDisks service.

It should be used for accessing the UDisks service from a client program.

Implementations§

Source§

impl Client

Source

pub async fn new() -> Result<Self>

Create a new client.

Source

pub async fn new_for_connection(connection: Connection) -> Result<Self>

Creates a new client based on the given zbus::Connection.

Source

pub fn object_manager(&self) -> &ObjectManagerProxy<'_>

Returns the zbus::fdo::ObjectManagerProxy used by the Client.

Source

pub fn manager(&self) -> &ManagerProxy<'_>

Returns a reference to the manager interface.

Source

pub fn object<P: TryInto<OwnedObjectPath>>( &self, object_path: P, ) -> Result<Object, P::Error>

Convenience function for looking up an Object for object_path.

§Errors

Returns an error if the given object path cannot be converted to an zbus::zvariant::OwnedObjectPath

Source

pub async fn jobs_for_object(&self, object: &Object) -> Vec<OwnedObjectPath>

Gets all the job::JobProxy instances for the given object.

If no instances are found, the returned vector is empty.

Source

pub fn job_description_from_operation(&self, operation: &str) -> String

Gets a human-readable and localized text string describing the operation of job.

For known job types, see the documentation for job::JobProxy::operation.

Source

pub async fn job_description(&self, job: &JobProxy<'_>) -> Result<String>

Gets a human-readable and localized text string describing the operation of job.

For known job types, see the documentation for job::JobProxy::operation.

Source

pub async fn block_for_dev( &self, block_device_number: u64, ) -> Option<BlockProxy<'_>>

Gets the block::BlockProxy for the given block_device_number.

If no block is found, None is returned,

Source

pub async fn block_for_label(&self, label: &str) -> Vec<BlockProxy<'_>>

Gets all the block::BlockProxy instances with the given label.

If no instances are found, the returned vector is empty.

Source

pub async fn block_for_uuid(&self, uuid: &str) -> Vec<BlockProxy<'_>>

Gets all the block::BlockProxys for the given uuid.

If no blocks are found, the returned vector is empty.

Source

pub async fn block_for_drive( &self, drive: &DriveProxy<'_>, _physical: bool, ) -> Option<BlockProxy<'_>>

Gets the block::BlockProxy, if exists, for the given drive::DriveProxy

The returned block is for the whole disk drive, so partition::PartitionProxy is never returned.

If physical is set to true, a block that is able to send low-level SCSI commands is returned. If physical is set to false, a block device that can read/write data is returned.

Source

pub async fn drive_for_block( &self, block: &BlockProxy<'_>, ) -> Result<DriveProxy<'static>>

Gets the drive::DriveProxy for the given block::BlockProxy, if any.

§Errors

If no drive is found, zbus::Error::InterfaceNotFound is returned.

Source

pub async fn cleartext_block( &self, block: &BlockProxy<'_>, ) -> Option<BlockProxy<'_>>

If the given block::BlockProxy is an encrypted device, returns the cleartext device.

If no block is found, None is returned.

Source

pub async fn partition_table( &self, partition: &PartitionProxy<'_>, ) -> Result<PartitionTableProxy<'_>>

Returns the partitiontable::PartitionTableProxy for the given partition.

§Errors

Returns an error if it is unable to get the table or the Object for the table.

Source

pub async fn loop_for_block( &self, block: &BlockProxy<'_>, ) -> Result<LoopProxy<'_>>

Returns the loop::LoopProxy for the given block::BlockProxy.

This only works if the block is a loop device, or a partition of a loop device.

§Errors

Returns an error if it is unable to get the loop interface.

Source

pub async fn partitions( &self, table: &PartitionTableProxy<'_>, ) -> Vec<PartitionProxy<'_>>

Source

pub async fn drive_siblings( &self, drive: &DriveProxy<'_>, ) -> Vec<DriveProxy<'_>>

Source

pub async fn block_for_mdraid( &self, mdraid: &MDRaidProxy<'_>, ) -> Option<BlockProxy<'_>>

Returns the RAID device (e.g. /dev/md0) for the given mdraid.

In the case of a split-brain syndrome, it is undefined which RAID device is returned. For example this can happen if /dev/sda and /dev/sdb are components of a two-disk RAID-1 and /dev/md0 and /dev/md1 are two degraded arrays, each one using exactly one of the two devices. Use Client::all_blocks_for_mdraid to get all RAID devices.

If no RAID device is running, Option::None is returned.

Source

pub async fn all_blocks_for_mdraid( &self, mdraid: &MDRaidProxy<'_>, ) -> Vec<BlockProxy<'_>>

Returns all RAID devices (e.g. /dev/md0 and /dev/md1) for the given mdraid.

This is usually only useful split-brain syndrome, and is normally used only to convey the problem in an user interface. See Client::block_for_mdraid for an example.

Source

pub async fn members_for_mdraid( &self, mdraid: &MDRaidProxy<'_>, ) -> Vec<BlockProxy<'_>>

returns the physical block devices that are part of the given raid.

Source

pub async fn mdraid_for_block( &self, block: &BlockProxy<'_>, ) -> Result<MDRaidProxy<'_>>

Returns the mdraid::MDRaidProxy that the given block is the block device for.

§Errors

Returns an error if no mdraid::MDRaidProxy for the block is found, or the block is not a MD-RAID block device.

Source

pub async fn object_info<'a>(&self, object: &'a Object) -> ObjectInfo<'a>

Returns information about the given object for presentation in a user information.

The returned information is localized.

Source

pub async fn partition_info( &self, partition: &PartitionProxy<'_>, ) -> Result<String>

Returns informating about the given partition that is suitable for presentation in an user interface in a single line of text.

The returned string is localized and includes things like the partition type, flags (if any) and name (if any).

§Errors

Returns an errors if it fails to read any of the aforementioned information.

Source

pub fn size_for_display( &self, size: u64, use_pow2: bool, long_str: bool, ) -> String

Utility function to get a human-readable string that represents the given size.

When use_pow2 is set to true power-of-two units are used instead of power-of-ten units. Set long_str to true, to produce a long string.

Source

pub fn id_for_display( &self, usage: &str, ty: &str, version: &str, long_str: bool, ) -> String

Returns a human readable localized string for usage, type and version.

Source

pub fn media_compat_for_display(&self, media_compat: &[&str]) -> Option<String>

Returns a human-readable, localized string of the media described by the given media_compat.

If the media is unknown, Option::None is returned.

Source

pub fn partition_type_infos( &self, partition_table_type: &str, partition_table_subtype: Option<&str>, ) -> Vec<&PartitionTypeInfo>

Returns information about all known partition types for partition_table_type (e.g. dos or gpt) and partition_table_subtype.

If partition_table_subtype is None, it is equivalent to all known types.

Source

pub fn partition_table_subtypes(&self, partition_table_type: &str) -> Vec<&str>

Returns information about all known subtypes for partition_table_type (e.g. dos or gpt) and partition_table_subtype.

Source

pub fn partition_type_for_display( &self, partition_table_type: &str, partition_type: &str, ) -> Option<String>

Returns, if exists, the human-readable localized name of the PartitionTypeInfo.

Source

pub fn partition_type_and_subtype_for_display( &self, partition_table_type: &str, partition_table_subtype: &str, partition_type: &str, ) -> Option<String>

Returns, if existing, the human-readable localized name of the PartitionTypeInfo.

It is similar to Client::partition_type_for_display, but also accounts for the partition_table_subtype, if available. This can be useful for scenarios, where different subtypes are using the same partition type.

Source

pub fn partition_table_type_for_display( &self, partition_table_type: &str, ) -> Option<String>

Returns, if exists, the human-readable localized string for partition_table_type (e.g. dos or gpt).

Source

pub fn partition_table_subtype_for_display( &self, partition_table_type: &str, partition_table_subtype: &str, ) -> Option<String>

Returns a human-readable localized description for partition_table_type (e.g. dos or gpt) and partition_table_subtype (e.g. dos or gpt).

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more