Struct Hostname1Proxy
pub struct Hostname1Proxy<'p>(Proxy<'p>);Expand description
Client for the org.freedesktop.hostname1 interface of systemd-hostnamed.
The interface reads and changes the hostname and other machine metadata. The service starts on demand and exits when idle.
The service doesn’t signal edits to the configuration files or direct
sethostname calls. It also changes IconName silently when SetChassis
runs. For this reason the proxy never caches the properties that can change
and reads them from the bus on each call.
Most setters take an interactive flag. When it is true, polkit may ask
the user to authenticate.
Upstream documentation: https://www.freedesktop.org/software/systemd/man/latest/org.freedesktop.hostname1.html.
Tuple Fields§
§0: Proxy<'p>Implementations§
§impl<'p> Hostname1Proxy<'p>
impl<'p> Hostname1Proxy<'p>
pub async fn new(conn: &Connection) -> Result<Hostname1Proxy<'p>>
pub async fn new(conn: &Connection) -> Result<Hostname1Proxy<'p>>
Creates a new proxy with the default service and path.
pub fn builder(conn: &Connection) -> Builder<'p, Self>
pub fn builder(conn: &Connection) -> Builder<'p, Self>
Returns a customizable builder for this proxy.
pub fn into_inner(self) -> Proxy<'p>
pub fn into_inner(self) -> Proxy<'p>
Consumes self, returning the underlying zbus::Proxy.
pub fn inner(&self) -> &Proxy<'p>
pub fn inner(&self) -> &Proxy<'p>
The reference to the underlying zbus::Proxy.
pub fn inner_mut(&mut self) -> &mut Proxy<'p>
pub fn inner_mut(&mut self) -> &mut Proxy<'p>
The mutable reference to the underlying zbus::Proxy.
pub async fn set_hostname(
&self,
hostname: &str,
interactive: bool,
) -> Result<()>
pub async fn set_hostname( &self, hostname: &str, interactive: bool, ) -> Result<()>
Sets the runtime hostname, which applies when no static hostname exists.
Use a plain lowercase ASCII name without spaces or special characters. An empty string clears the runtime hostname.
pub async fn set_static_hostname(
&self,
hostname: &str,
interactive: bool,
) -> Result<()>
pub async fn set_static_hostname( &self, hostname: &str, interactive: bool, ) -> Result<()>
Sets the static hostname stored in /etc/hostname.
An empty string deletes the entry in /etc/hostname. This name has
priority over all other sources. The kernel hostname usually follows it.
pub async fn set_pretty_hostname(
&self,
hostname: &str,
interactive: bool,
) -> Result<()>
pub async fn set_pretty_hostname( &self, hostname: &str, interactive: bool, ) -> Result<()>
Sets the pretty hostname, a free-form UTF-8 name for display.
pub async fn set_icon_name(&self, icon: &str, interactive: bool) -> Result<()>
pub async fn set_icon_name(&self, icon: &str, interactive: bool) -> Result<()>
Sets the icon name, following the XDG icon naming specification.
An empty string turns the automatic icon choice back on.
pub async fn set_chassis(
&self,
chassis: &Chassis,
interactive: bool,
) -> Result<()>
pub async fn set_chassis( &self, chassis: &Chassis, interactive: bool, ) -> Result<()>
Sets the chassis type.
Pass Chassis::Unset to turn automatic detection back on.
pub async fn set_deployment(
&self,
deployment: &str,
interactive: bool,
) -> Result<()>
pub async fn set_deployment( &self, deployment: &str, interactive: bool, ) -> Result<()>
Sets the deployment environment, for example production.
pub async fn set_location(
&self,
location: &str,
interactive: bool,
) -> Result<()>
pub async fn set_location( &self, location: &str, interactive: bool, ) -> Result<()>
Sets the physical location of the machine.
Replaces the machine tags.
Each tag has 1 to 255 characters from ASCII letters, digits, - and
.. An empty list removes all tags.
Added in systemd 261.
Adds and removes machine tags in one step.
The new list is the current list plus add, minus remove, sorted
and without duplicates. Use this instead of reading and then writing
the tags when several programs manage tags.
Added in systemd 262.
pub async fn get_product_uuid(&self, interactive: bool) -> Result<Vec<u8>>
pub async fn get_product_uuid(&self, interactive: bool) -> Result<Vec<u8>>
Returns the product UUID that the firmware reports through DMI.
Only root can read the file directly. The service lets other users ask for it after a polkit check.
pub async fn get_hardware_serial(&self) -> Result<String>
pub async fn get_hardware_serial(&self) -> Result<String>
Returns the hardware serial number from the DMI data.
Added in systemd 251.
pub async fn describe(&self) -> Result<String>
pub async fn describe(&self) -> Result<String>
Returns all properties as one JSON document.
The crate does not parse the document. The keys are not limited to the properties of this interface.
pub async fn get_machine_info(&self, field: &str) -> Result<String>
pub async fn get_machine_info(&self, field: &str) -> Result<String>
Returns one raw field from /etc/machine-info.
The call fails if the name is empty, invalid or not set. Unlike the properties, the result has no fallback values.
Added in systemd 261.
pub async fn static_hostname(&self) -> Result<String>
pub async fn static_hostname(&self) -> Result<String>
The static hostname from /etc/hostname, or an empty string.
pub async fn pretty_hostname(&self) -> Result<String>
pub async fn pretty_hostname(&self) -> Result<String>
The pretty hostname, or an empty string.
pub async fn default_hostname(&self) -> Result<String>
pub async fn default_hostname(&self) -> Result<String>
The default hostname from os-release or the built-in fallback.
pub fn cached_default_hostname(
&self,
) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
pub fn cached_default_hostname( &self, ) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
The default hostname from os-release or the built-in fallback.
Get the cached value of the DefaultHostname property, or None if the property is not cached.
pub async fn hostname_source(&self) -> Result<HostnameSource>
pub async fn hostname_source(&self) -> Result<HostnameSource>
The origin of the current hostname.
pub async fn icon_name(&self) -> Result<String>
pub async fn icon_name(&self) -> Result<String>
The icon name, or a fallback based on the chassis type.
pub async fn chassis(&self) -> Result<Chassis>
pub async fn chassis(&self) -> Result<Chassis>
The chassis type.
The service detects the type from firmware data unless it is set
explicitly. The value is Chassis::Unset if nothing is known.
pub async fn deployment(&self) -> Result<String>
pub async fn deployment(&self) -> Result<String>
The deployment environment, or an empty string.
The machine tags. The list is empty if no tags are set.
Added in systemd 261.
pub async fn kernel_name(&self) -> Result<String>
pub async fn kernel_name(&self) -> Result<String>
The kernel name, for example Linux.
pub fn cached_kernel_name(
&self,
) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
pub fn cached_kernel_name( &self, ) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
The kernel name, for example Linux.
Get the cached value of the KernelName property, or None if the property is not cached.
pub async fn kernel_release(&self) -> Result<String>
pub async fn kernel_release(&self) -> Result<String>
The kernel release, as reported by uname.
pub fn cached_kernel_release(
&self,
) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
pub fn cached_kernel_release( &self, ) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
The kernel release, as reported by uname.
Get the cached value of the KernelRelease property, or None if the property is not cached.
pub async fn kernel_version(&self) -> Result<String>
pub async fn kernel_version(&self) -> Result<String>
The kernel version, as reported by uname.
pub fn cached_kernel_version(
&self,
) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
pub fn cached_kernel_version( &self, ) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
The kernel version, as reported by uname.
Get the cached value of the KernelVersion property, or None if the property is not cached.
pub async fn operating_system_pretty_name(&self) -> Result<String>
pub async fn operating_system_pretty_name(&self) -> Result<String>
The PRETTY_NAME field of os-release.
pub fn cached_operating_system_pretty_name(
&self,
) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
pub fn cached_operating_system_pretty_name( &self, ) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
The PRETTY_NAME field of os-release.
Get the cached value of the OperatingSystemPrettyName property, or None if the property is not cached.
pub async fn operating_system_fancy_name(&self) -> Result<String>
pub async fn operating_system_fancy_name(&self) -> Result<String>
The FANCY_NAME field of os-release.
Added in systemd 260.
pub fn cached_operating_system_fancy_name(
&self,
) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
pub fn cached_operating_system_fancy_name( &self, ) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
The FANCY_NAME field of os-release.
Added in systemd 260.
Get the cached value of the OperatingSystemFancyName property, or None if the property is not cached.
pub async fn operating_system_cpe_name(&self) -> Result<String>
pub async fn operating_system_cpe_name(&self) -> Result<String>
The CPE_NAME field of os-release.
pub fn cached_operating_system_cpe_name(
&self,
) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
pub fn cached_operating_system_cpe_name( &self, ) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
The CPE_NAME field of os-release.
Get the cached value of the OperatingSystemCPEName property, or None if the property is not cached.
pub async fn operating_system_support_end(&self) -> Result<u64>
pub async fn operating_system_support_end(&self) -> Result<u64>
The end of vendor support for the OS.
The value is in microseconds since the UNIX epoch (UTC). It is
u64::MAX if unknown.
Added in systemd 253.
pub fn cached_operating_system_support_end(
&self,
) -> Result<Option<<Result<u64> as ResultAdapter>::Ok>, <Result<u64> as ResultAdapter>::Err>
pub fn cached_operating_system_support_end( &self, ) -> Result<Option<<Result<u64> as ResultAdapter>::Ok>, <Result<u64> as ResultAdapter>::Err>
The end of vendor support for the OS.
The value is in microseconds since the UNIX epoch (UTC). It is
u64::MAX if unknown.
Added in systemd 253.
Get the cached value of the OperatingSystemSupportEnd property, or None if the property is not cached.
pub fn cached_home_url(
&self,
) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
pub fn cached_home_url( &self, ) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
The HOME_URL field of os-release.
Get the cached value of the HomeURL property, or None if the property is not cached.
pub async fn operating_system_image_id(&self) -> Result<String>
pub async fn operating_system_image_id(&self) -> Result<String>
The OS image name, or an empty string.
Added in systemd 258.
pub fn cached_operating_system_image_id(
&self,
) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
pub fn cached_operating_system_image_id( &self, ) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
The OS image name, or an empty string.
Added in systemd 258.
Get the cached value of the OperatingSystemImageID property, or None if the property is not cached.
pub async fn operating_system_image_version(&self) -> Result<String>
pub async fn operating_system_image_version(&self) -> Result<String>
The OS image version, or an empty string.
Added in systemd 258.
pub fn cached_operating_system_image_version(
&self,
) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
pub fn cached_operating_system_image_version( &self, ) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
The OS image version, or an empty string.
Added in systemd 258.
Get the cached value of the OperatingSystemImageVersion property, or None if the property is not cached.
pub async fn hardware_vendor(&self) -> Result<String>
pub async fn hardware_vendor(&self) -> Result<String>
The hardware vendor, or an empty string.
pub fn cached_hardware_vendor(
&self,
) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
pub fn cached_hardware_vendor( &self, ) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
The hardware vendor, or an empty string.
Get the cached value of the HardwareVendor property, or None if the property is not cached.
pub async fn hardware_model(&self) -> Result<String>
pub async fn hardware_model(&self) -> Result<String>
The product model of the hardware, or an empty string.
pub fn cached_hardware_model(
&self,
) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
pub fn cached_hardware_model( &self, ) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
The product model of the hardware, or an empty string.
Get the cached value of the HardwareModel property, or None if the property is not cached.
pub async fn hardware_sku(&self) -> Result<String>
pub async fn hardware_sku(&self) -> Result<String>
The stock keeping unit of the hardware, or an empty string.
It is empty when it equals the model.
Added in systemd 258.
pub fn cached_hardware_sku(
&self,
) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
pub fn cached_hardware_sku( &self, ) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
The stock keeping unit of the hardware, or an empty string.
It is empty when it equals the model.
Added in systemd 258.
Get the cached value of the HardwareSKU property, or None if the property is not cached.
pub async fn hardware_version(&self) -> Result<String>
pub async fn hardware_version(&self) -> Result<String>
The hardware version, or an empty string.
It is empty when it equals the model or the SKU.
Added in systemd 258.
pub fn cached_hardware_version(
&self,
) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
pub fn cached_hardware_version( &self, ) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
The hardware version, or an empty string.
It is empty when it equals the model or the SKU.
Added in systemd 258.
Get the cached value of the HardwareVersion property, or None if the property is not cached.
pub async fn firmware_version(&self) -> Result<String>
pub async fn firmware_version(&self) -> Result<String>
The firmware version, or an empty string.
Added in systemd 251.
pub fn cached_firmware_version(
&self,
) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
pub fn cached_firmware_version( &self, ) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
The firmware version, or an empty string.
Added in systemd 251.
Get the cached value of the FirmwareVersion property, or None if the property is not cached.
pub async fn firmware_vendor(&self) -> Result<String>
pub async fn firmware_vendor(&self) -> Result<String>
The firmware vendor, or an empty string.
Added in systemd 253.
pub fn cached_firmware_vendor(
&self,
) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
pub fn cached_firmware_vendor( &self, ) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
The firmware vendor, or an empty string.
Added in systemd 253.
Get the cached value of the FirmwareVendor property, or None if the property is not cached.
pub async fn firmware_date(&self) -> Result<u64>
pub async fn firmware_date(&self) -> Result<u64>
The firmware build date.
The value is in microseconds since the UNIX epoch (UTC). It is
u64::MAX if unknown.
Added in systemd 253.
pub fn cached_firmware_date(
&self,
) -> Result<Option<<Result<u64> as ResultAdapter>::Ok>, <Result<u64> as ResultAdapter>::Err>
pub fn cached_firmware_date( &self, ) -> Result<Option<<Result<u64> as ResultAdapter>::Ok>, <Result<u64> as ResultAdapter>::Err>
The firmware build date.
The value is in microseconds since the UNIX epoch (UTC). It is
u64::MAX if unknown.
Added in systemd 253.
Get the cached value of the FirmwareDate property, or None if the property is not cached.
pub async fn machine_id(&self) -> Result<Vec<u8>>
pub async fn machine_id(&self) -> Result<Vec<u8>>
The 128 bit machine ID as 16 bytes.
Added in systemd 256.
pub fn cached_machine_id(
&self,
) -> Result<Option<<Result<Vec<u8>> as ResultAdapter>::Ok>, <Result<Vec<u8>> as ResultAdapter>::Err>
pub fn cached_machine_id( &self, ) -> Result<Option<<Result<Vec<u8>> as ResultAdapter>::Ok>, <Result<Vec<u8>> as ResultAdapter>::Err>
The 128 bit machine ID as 16 bytes.
Added in systemd 256.
Get the cached value of the MachineID property, or None if the property is not cached.
pub async fn boot_id(&self) -> Result<Vec<u8>>
pub async fn boot_id(&self) -> Result<Vec<u8>>
The 128 bit boot ID as 16 bytes.
Added in systemd 256.
pub fn cached_boot_id(
&self,
) -> Result<Option<<Result<Vec<u8>> as ResultAdapter>::Ok>, <Result<Vec<u8>> as ResultAdapter>::Err>
pub fn cached_boot_id( &self, ) -> Result<Option<<Result<Vec<u8>> as ResultAdapter>::Ok>, <Result<Vec<u8>> as ResultAdapter>::Err>
The 128 bit boot ID as 16 bytes.
Added in systemd 256.
Get the cached value of the BootID property, or None if the property is not cached.
pub async fn vsock_cid(&self) -> Result<u32>
pub async fn vsock_cid(&self) -> Result<u32>
The local AF_VSOCK context ID.
The value is u32::MAX if the machine has none.
Added in systemd 256.
pub fn cached_vsock_cid(
&self,
) -> Result<Option<<Result<u32> as ResultAdapter>::Ok>, <Result<u32> as ResultAdapter>::Err>
pub fn cached_vsock_cid( &self, ) -> Result<Option<<Result<u32> as ResultAdapter>::Ok>, <Result<u32> as ResultAdapter>::Err>
The local AF_VSOCK context ID.
The value is u32::MAX if the machine has none.
Added in systemd 256.
Get the cached value of the VSockCID property, or None if the property is not cached.
pub async fn chassis_asset_tag(&self) -> Result<String>
pub async fn chassis_asset_tag(&self) -> Result<String>
A unique identifier of the chassis, or an empty string.
Added in systemd 258.
pub fn cached_chassis_asset_tag(
&self,
) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
pub fn cached_chassis_asset_tag( &self, ) -> Result<Option<<Result<String> as ResultAdapter>::Ok>, <Result<String> as ResultAdapter>::Err>
A unique identifier of the chassis, or an empty string.
Added in systemd 258.
Get the cached value of the ChassisAssetTag property, or None if the property is not cached.
Trait Implementations§
§impl<'p> AsMut<Proxy<'p>> for Hostname1Proxy<'p>
impl<'p> AsMut<Proxy<'p>> for Hostname1Proxy<'p>
§impl<'p> AsRef<Proxy<'p>> for Hostname1Proxy<'p>
impl<'p> AsRef<Proxy<'p>> for Hostname1Proxy<'p>
§impl<'p> Clone for Hostname1Proxy<'p>
impl<'p> Clone for Hostname1Proxy<'p>
§fn clone(&self) -> Hostname1Proxy<'p>
fn clone(&self) -> Hostname1Proxy<'p>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more