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>
impl<'d, T: Transport> Device<'d, T>
Sourcepub fn new(
doc: &'d ModDefDocument,
device_id: Option<&str>,
transport: T,
) -> Result<Self, Error<T::Error>>
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).
pub fn from_profile(profile: &'d DeviceProfile, transport: T) -> Self
pub fn profile(&self) -> &'d DeviceProfile
pub fn transport_mut(&mut self) -> &mut T
pub fn into_transport(self) -> T
Sourcepub fn points(&self) -> impl Iterator<Item = &'d Point>
pub fn points(&self) -> impl Iterator<Item = &'d Point>
All points in block order (spec §32.1).
Sourcepub fn point(
&self,
id: &str,
) -> Result<(&'d Point, &'d RegisterBlock), Error<T::Error>>
pub fn point( &self, id: &str, ) -> Result<(&'d Point, &'d RegisterBlock), Error<T::Error>>
Look up a point and its owning block by id.
Sourcepub async fn read_point(
&mut self,
id: &str,
) -> Result<DecodedValue, Error<T::Error>>
pub async fn read_point( &mut self, id: &str, ) -> Result<DecodedValue, Error<T::Error>>
Read and decode a single point by id.
Sourcepub async fn read_measurand(
&mut self,
q: &MeasurandQuery<'_>,
) -> Result<DecodedValue, Error<T::Error>>
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).
Sourcepub async fn write_point(
&mut self,
id: &str,
v: Value,
) -> Result<(), Error<T::Error>>
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.
Sourcepub async fn write_point_str(
&mut self,
id: &str,
s: &str,
) -> Result<(), Error<T::Error>>
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.
Sourcepub async fn run_command<D: Delay>(
&mut self,
id: &str,
params: &[(&str, ParamValue<'_>)],
delay: &mut D,
) -> Result<BTreeMap<&'d str, DecodedValue>, Error<T::Error>>
pub async fn run_command<D: Delay>( &mut self, id: &str, params: &[(&str, ParamValue<'_>)], delay: &mut D, ) -> Result<BTreeMap<&'d str, DecodedValue>, Error<T::Error>>
Execute a §11.7 command: params are the caller’s inputs keyed by
CommandParam.field; the returned map holds results keyed by
CommandResult.field. Steps run strictly in declaration order; a
poll step past its timeout_ms fails with Error::PollTimeout
(elapsed time is accounted by accumulating the delays requested from
delay — no wall clock). Poll conditions and trigger writes use raw
(pre-transform) register values.