Skip to main content

Device

Struct Device 

Source
pub struct Device<'d, T: Transport> { /* private fields */ }
Expand description

The untyped runtime facade over one device profile. Generated typed clients (moddef-codegen) skip this and use static descriptor tables.

Implementations§

Source§

impl<'d, T: Transport> Device<'d, T>

Source

pub fn new( doc: &'d ModDefDocument, device_id: Option<&str>, transport: T, ) -> Result<Self, Error<T::Error>>

Bind a transport to the named device profile in doc (or the only one).

Source

pub fn from_profile(profile: &'d DeviceProfile, transport: T) -> Self

Source

pub fn profile(&self) -> &'d DeviceProfile

Source

pub fn transport_mut(&mut self) -> &mut T

Source

pub fn into_transport(self) -> T

Source

pub fn points(&self) -> impl Iterator<Item = &'d Point>

All points in block order (spec §32.1).

Source

pub fn point( &self, id: &str, ) -> Result<(&'d Point, &'d RegisterBlock), Error<T::Error>>

Look up a point and its owning block by id.

Source

pub async fn read_point( &mut self, id: &str, ) -> Result<DecodedValue, Error<T::Error>>

Read and decode a single point by id.

Source

pub async fn read_measurand( &mut self, q: &MeasurandQuery<'_>, ) -> Result<DecodedValue, Error<T::Error>>

Read a point by its semantic measurand tuple (spec §26.1).

Source

pub async fn write_point( &mut self, id: &str, v: Value, ) -> Result<(), Error<T::Error>>

Encode and write a value, validating access mode and §11.4 constraints.

Source

pub async fn write_point_str( &mut self, id: &str, s: &str, ) -> Result<(), Error<T::Error>>

Write a string point (STRING_ASCII / STRING_UTF8), §15.

Auto Trait Implementations§

§

impl<'d, T> Freeze for Device<'d, T>
where T: Freeze,

§

impl<'d, T> RefUnwindSafe for Device<'d, T>
where T: RefUnwindSafe,

§

impl<'d, T> Send for Device<'d, T>
where T: Send,

§

impl<'d, T> Sync for Device<'d, T>
where T: Sync,

§

impl<'d, T> Unpin for Device<'d, T>
where T: Unpin,

§

impl<'d, T> UnsafeUnpin for Device<'d, T>
where T: UnsafeUnpin,

§

impl<'d, T> UnwindSafe for Device<'d, T>
where T: UnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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