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
impl Client
Sourcepub async fn new_for_connection(connection: Connection) -> Result<Self>
pub async fn new_for_connection(connection: Connection) -> Result<Self>
Creates a new client based on the given zbus::Connection
.
Sourcepub fn object_manager(&self) -> &ObjectManagerProxy<'_>
pub fn object_manager(&self) -> &ObjectManagerProxy<'_>
Returns the zbus::fdo::ObjectManagerProxy
used by the Client.
Sourcepub fn manager(&self) -> &ManagerProxy<'_>
pub fn manager(&self) -> &ManagerProxy<'_>
Returns a reference to the manager interface.
Sourcepub fn object<P: TryInto<OwnedObjectPath>>(
&self,
object_path: P,
) -> Result<Object, P::Error>
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
Sourcepub async fn jobs_for_object(&self, object: &Object) -> Vec<OwnedObjectPath>
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.
Sourcepub fn job_description_from_operation(&self, operation: &str) -> String
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
.
Sourcepub async fn job_description(&self, job: &JobProxy<'_>) -> Result<String>
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
.
Sourcepub async fn block_for_dev(
&self,
block_device_number: u64,
) -> Option<BlockProxy<'_>>
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,
Sourcepub async fn block_for_label(&self, label: &str) -> Vec<BlockProxy<'_>>
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.
Sourcepub async fn block_for_uuid(&self, uuid: &str) -> Vec<BlockProxy<'_>>
pub async fn block_for_uuid(&self, uuid: &str) -> Vec<BlockProxy<'_>>
Gets all the block::BlockProxy
s for the given uuid
.
If no blocks are found, the returned vector is empty.
Sourcepub async fn block_for_drive(
&self,
drive: &DriveProxy<'_>,
_physical: bool,
) -> Option<BlockProxy<'_>>
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.
Sourcepub async fn drive_for_block(
&self,
block: &BlockProxy<'_>,
) -> Result<DriveProxy<'static>>
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.
Sourcepub async fn cleartext_block(
&self,
block: &BlockProxy<'_>,
) -> Option<BlockProxy<'_>>
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.
Sourcepub async fn partition_table(
&self,
partition: &PartitionProxy<'_>,
) -> Result<PartitionTableProxy<'_>>
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.
Sourcepub async fn loop_for_block(
&self,
block: &BlockProxy<'_>,
) -> Result<LoopProxy<'_>>
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.
Sourcepub async fn partitions(
&self,
table: &PartitionTableProxy<'_>,
) -> Vec<PartitionProxy<'_>>
pub async fn partitions( &self, table: &PartitionTableProxy<'_>, ) -> Vec<PartitionProxy<'_>>
Returns all partition::PartitionProxy
of the given partitiontable::PartitionTableProxy
.
Sourcepub async fn drive_siblings(
&self,
drive: &DriveProxy<'_>,
) -> Vec<DriveProxy<'_>>
pub async fn drive_siblings( &self, drive: &DriveProxy<'_>, ) -> Vec<DriveProxy<'_>>
Returns all partition::PartitionProxy
of the given partitiontable::PartitionTableProxy
.
Sourcepub async fn block_for_mdraid(
&self,
mdraid: &MDRaidProxy<'_>,
) -> Option<BlockProxy<'_>>
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.
Sourcepub async fn all_blocks_for_mdraid(
&self,
mdraid: &MDRaidProxy<'_>,
) -> Vec<BlockProxy<'_>>
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.
Sourcepub async fn members_for_mdraid(
&self,
mdraid: &MDRaidProxy<'_>,
) -> Vec<BlockProxy<'_>>
pub async fn members_for_mdraid( &self, mdraid: &MDRaidProxy<'_>, ) -> Vec<BlockProxy<'_>>
returns the physical block devices that are part of the given raid.
Sourcepub async fn mdraid_for_block(
&self,
block: &BlockProxy<'_>,
) -> Result<MDRaidProxy<'_>>
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.
Sourcepub async fn object_info<'a>(&self, object: &'a Object) -> ObjectInfo<'a>
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.
Sourcepub async fn partition_info(
&self,
partition: &PartitionProxy<'_>,
) -> Result<String>
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.
Sourcepub fn size_for_display(
&self,
size: u64,
use_pow2: bool,
long_str: bool,
) -> String
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.
Sourcepub fn id_for_display(
&self,
usage: &str,
ty: &str,
version: &str,
long_str: bool,
) -> String
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
.
Sourcepub fn media_compat_for_display(&self, media_compat: &[&str]) -> Option<String>
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.
Sourcepub fn partition_type_infos(
&self,
partition_table_type: &str,
partition_table_subtype: Option<&str>,
) -> Vec<&PartitionTypeInfo>
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.
Sourcepub fn partition_table_subtypes(&self, partition_table_type: &str) -> Vec<&str>
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
.
Sourcepub fn partition_type_for_display(
&self,
partition_table_type: &str,
partition_type: &str,
) -> Option<String>
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.
Sourcepub fn partition_type_and_subtype_for_display(
&self,
partition_table_type: &str,
partition_table_subtype: &str,
partition_type: &str,
) -> Option<String>
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.
Sourcepub fn partition_table_type_for_display(
&self,
partition_table_type: &str,
) -> Option<String>
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
).