pub struct RequestChan { /* private fields */ }
Expand description

A handle which is used to communicate with the core of DrMem. When a driver is created, it will be given a handle to be used throughout its life.

This type wraps the mpsc::Sender<> and defines a set of helper methods to send requests and receive replies with the core.

Implementations§

source§

impl RequestChan

source

pub fn new(driver_name: &str, prefix: &Path, req_chan: &Sender<Request>) -> Self

source

pub async fn add_ro_device<T: Into<Value> + TryFrom<Value>>( &self, name: Base, units: Option<&str>, max_history: Option<usize> ) -> Result<(ReportReading<T>, Option<T>)>

Registers a read-only device with the framework. name is the last section of the full device name. Typically a driver will register several devices, each representing a portion of the hardware being controlled. All devices for a given driver instance will have the same prefix; the name parameter is appended to it.

If it returns Ok(), the value is a broadcast channel that the driver uses to announce new values of the associated hardware.

If it returns Err(), the underlying value could be InUse, meaning the device name is already registered. If the error is InternalError, then the core has exited and the RequestChan has been closed. Since the driver can’t report any more updates, it may as well shutdown.

source

pub async fn add_rw_device<T: Into<Value> + TryFrom<Value>>( &self, name: Base, units: Option<&str>, max_history: Option<usize> ) -> Result<(ReportReading<T>, SettingStream<T>, Option<T>)>

Registers a read-write device with the framework. name is the last section of the full device name. Typically a driver will register several devices, each representing a portion of the hardware being controlled. All devices for a given driver instance will have the same prefix; the name parameter is appended to it.

If it returns Ok(), the value is a pair containing a broadcast channel that the driver uses to announce new values of the associated hardware and a receive channel for incoming settings to be applied to the hardware.

If it returns Err(), the underlying value could be InUse, meaning the device name is already registered. If the error is InternalError, then the core has exited and the RequestChan has been closed. Since the driver can’t report any more updates or accept new settings, it may as well shutdown.

Trait Implementations§

source§

impl Clone for RequestChan

source§

fn clone(&self) -> RequestChan

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

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 Twhere U: TryFrom<T>,

§

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.