Skip to main content

HlapiClient

Struct HlapiClient 

Source
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

Source

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.

Source

pub fn connect_virtio() -> Result<Self, HlapiClientError>

Helper function to make a connection with the LinuxVirtio transport

Source

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

Source

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.

Source

pub fn new<C: Codec + Send + 'static>(codec: C) -> Self

Create a new client with the given codec

Source

pub fn list_devices(&self) -> Result<Vec<DeviceInfo>, HlapiClientError>

List all devices on the bus

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for HlapiClient

Source§

fn clone(&self) -> Self

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

impl Debug for HlapiClient

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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

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.