Skip to main content

Hostname1Proxy

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>

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>

Returns a customizable builder for this proxy.

pub fn into_inner(self) -> Proxy<'p>

Consumes self, returning the underlying zbus::Proxy.

pub fn inner(&self) -> &Proxy<'p>

The reference to the underlying zbus::Proxy.

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<()>

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<()>

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<()>

Sets the pretty hostname, a free-form UTF-8 name for display.

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<()>

Sets the chassis type.

Pass Chassis::Unset to turn automatic detection back on.

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<()>

Sets the physical location of the machine.

pub async fn set_tags(&self, tags: &[&str]) -> Result<()>

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.

pub async fn add_and_remove_tags( &self, add: &[&str], remove: &[&str], ) -> Result<()>

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>>

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>

Returns the hardware serial number from the DMI data.

Added in systemd 251.

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>

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 hostname(&self) -> Result<String>

The hostname that the kernel uses.

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>

The pretty hostname, or an empty 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>

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>

The origin of the current hostname.

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>

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>

The deployment environment, or an empty string.

pub async fn location(&self) -> Result<String>

The physical location, or an empty string.

pub async fn tags(&self) -> Result<Vec<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>

The kernel name, for example Linux.

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>

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>

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>

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>

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>

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>

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>

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>

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>

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>

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>

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>

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 async fn home_url(&self) -> Result<String>

The HOME_URL field of os-release.

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>

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>

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>

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>

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>

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>

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>

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>

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>

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>

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>

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>

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>

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>

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>

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>

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>

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>

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>>

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>

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>>

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>

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>

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>

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>

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>

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>

§

fn as_mut(&mut self) -> &mut Proxy<'p>

Converts this type into a mutable reference of the (usually inferred) input type.
§

impl<'p> AsRef<Proxy<'p>> for Hostname1Proxy<'p>

§

fn as_ref(&self) -> &Proxy<'p>

Converts this type into a shared reference of the (usually inferred) input type.
§

impl<'p> Clone for Hostname1Proxy<'p>

§

fn clone(&self) -> Hostname1Proxy<'p>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
§

impl<'p> Debug for Hostname1Proxy<'p>

§

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

Formats the value using the given formatter. Read more
§

impl<'a> Defaults for Hostname1Proxy<'a>

§

const INTERFACE: &'static Option<InterfaceName<'static>>

§

const DESTINATION: &'static Option<BusName<'static>>

§

const PATH: &'static Option<ObjectPath<'static>>

§

impl<'p> From<Proxy<'p>> for Hostname1Proxy<'p>

§

fn from(proxy: Proxy<'p>) -> Self

Converts to this type from the input type.
§

impl<'p> ProxyImpl<'p> for Hostname1Proxy<'p>

§

fn builder(conn: &Connection) -> Builder<'p, Self>

Return a customizable builder for this proxy.
§

fn into_inner(self) -> Proxy<'p>

Consume self, returning the underlying zbus::Proxy.
§

fn inner(&self) -> &Proxy<'p>

The reference to the underlying zbus::Proxy.
§

impl<'p> Serialize for Hostname1Proxy<'p>

§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl<'p> Type for Hostname1Proxy<'p>

§

const SIGNATURE: &'static Signature

The signature for the implementing type, in parsed format. Read more

Auto Trait Implementations§

§

impl<'p> !RefUnwindSafe for Hostname1Proxy<'p>

§

impl<'p> !UnwindSafe for Hostname1Proxy<'p>

§

impl<'p> Freeze for Hostname1Proxy<'p>

§

impl<'p> Send for Hostname1Proxy<'p>

§

impl<'p> Sync for Hostname1Proxy<'p>

§

impl<'p> Unpin for Hostname1Proxy<'p>

§

impl<'p> UnsafeUnpin for Hostname1Proxy<'p>

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
§

impl<T> DynamicType for T
where T: Type + ?Sized,

§

fn signature(&self) -> Signature

The type signature for self. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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 = !

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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