pub struct HlapiClient { /* private fields */ }Expand description
The HLAPI client
Cloned clients share state, including one internal connection, and an in-progress method on one client will block the others. If you are calling a long-running method on a background thread, it should have its own connection.
Implementations§
Source§impl HlapiClient
impl HlapiClient
Sourcepub fn connect() -> Result<Self, HlapiClientError>
pub fn connect() -> Result<Self, HlapiClientError>
Helper function to connect to the HLAPI bus the way Lua does, trying the bus daemon first and falling back to virtio if that fails.
Sourcepub fn connect_virtio() -> Result<Self, HlapiClientError>
pub fn connect_virtio() -> Result<Self, HlapiClientError>
Helper function to make a connection with the LinuxVirtio transport
Sourcepub fn connect_busd_client() -> Result<Self, HlapiClientError>
pub fn connect_busd_client() -> Result<Self, HlapiClientError>
Helper function to make a connection with the BusdClient transport, autodetecting the
socket path.
Source§impl HlapiClient
impl HlapiClient
Sourcepub const DEFAULT_REQUEST_TIMEOUT: Duration
pub const DEFAULT_REQUEST_TIMEOUT: Duration
The default request timeout for HLAPI requests. 35s is the default for the Lua libraries, so we use it as well.
Sourcepub fn new<C: Codec + Send + 'static>(codec: C) -> Self
pub fn new<C: Codec + Send + 'static>(codec: C) -> Self
Create a new client with the given codec
Sourcepub fn list_devices(&self) -> Result<Vec<DeviceInfo>, HlapiClientError>
pub fn list_devices(&self) -> Result<Vec<DeviceInfo>, HlapiClientError>
List all devices on the bus
Sourcepub fn find_device_by_type<D: DeviceBase>(
&self,
) -> Result<Option<D>, HlapiClientError>
pub fn find_device_by_type<D: DeviceBase>( &self, ) -> Result<Option<D>, HlapiClientError>
Find the first device with the type of the provided wrapper struct. If multiple devices exist, the one returned is the one with the lowest UUID.
GenericDevice will match all device types.
Sourcepub fn find_device_by_names<D: DeviceBase>(
&self,
names: &[&str],
) -> Result<Option<D>, HlapiClientError>
pub fn find_device_by_names<D: DeviceBase>( &self, names: &[&str], ) -> Result<Option<D>, HlapiClientError>
Find the first device with all the given names, as well as the wrapper’s device type. If multiple devices exist, the one returned is the one with the lowest UUID.
An empty name matches all device names, and GenericDevice will match all device types.
Sourcepub fn find_devices_by_type<D: DeviceBase>(
&self,
) -> Result<Vec<D>, HlapiClientError>
pub fn find_devices_by_type<D: DeviceBase>( &self, ) -> Result<Vec<D>, HlapiClientError>
Find all devices with the type of the provided wrapper struct. The returned list is sorted by UUID.
GenericDevice will match all device types.
Sourcepub fn find_devices_by_names<D: DeviceBase>(
&self,
names: &[&str],
) -> Result<Vec<D>, HlapiClientError>
pub fn find_devices_by_names<D: DeviceBase>( &self, names: &[&str], ) -> Result<Vec<D>, HlapiClientError>
Find all devices with all the given names, as well as the wrapper’s device type. The returned list is sorted by UUID.
An empty name matches all device names, and GenericDevice will match all device types.
Sourcepub fn get_device_by_uuid<D: DeviceBase>(
&self,
uuid: Uuid,
) -> Result<Option<D>, HlapiClientError>
pub fn get_device_by_uuid<D: DeviceBase>( &self, uuid: Uuid, ) -> Result<Option<D>, HlapiClientError>
Get the device with the given UUID and type.
GenericDevice will match all device types.
Sourcepub fn set_request_timeout(
&self,
timeout: Option<Duration>,
) -> Result<(), HlapiClientError>
pub fn set_request_timeout( &self, timeout: Option<Duration>, ) -> Result<(), HlapiClientError>
Set how long a request may take before it times out. None means no timeout.
The default value is Self::DEFAULT_REQUEST_TIMEOUT.