[−][src]Struct async_resol_vbus::LiveDataStream
A Stream
/Sink
wrapper for RESOL VBus Data
items encoded in the
live / wire representation.
It also contains methods to communicate with a VBus device to get or set values etc.
Methods
impl<R: Read + Unpin, W: Write + Unpin> LiveDataStream<R, W>
[src]
pub fn new(
reader: R,
writer: W,
channel: u8,
self_address: u16
) -> LiveDataStream<R, W>
[src]
reader: R,
writer: W,
channel: u8,
self_address: u16
) -> LiveDataStream<R, W>
Create a new LiveDataStream
.
pub fn into_inner(self) -> (R, W)
[src]
Consume self
and return the underlying I/O pair.
pub async fn receive<'_, F>(
&'_ mut self,
timeout_ms: u64,
filter: F
) -> Result<Option<Data>> where
F: Fn(&Data) -> bool,
[src]
&'_ mut self,
timeout_ms: u64,
filter: F
) -> Result<Option<Data>> where
F: Fn(&Data) -> bool,
Receive data from the VBus.
This methods waits for timeout_ms
milliseconds for incoming
VBus data. Every time a valid Data
is received over the VBus
the filter
function is called with that Data
as its argument.
The function returns a bool
whether the provided Data
is the
data it was waiting for.
If the filter
function returns true
, the respective Data
is used to return from the receive
method.
If the filter
function did not find the matching data within
timeout_ms
milliseconds, the receive
method returns with
None
.
pub async fn transceive<'_, F>(
&'_ mut self,
tx_data: Data,
max_tries: usize,
initial_timeout_ms: u64,
timeout_increment_ms: u64,
filter: F
) -> Result<Option<Data>> where
F: Fn(&Data) -> bool,
[src]
&'_ mut self,
tx_data: Data,
max_tries: usize,
initial_timeout_ms: u64,
timeout_increment_ms: u64,
filter: F
) -> Result<Option<Data>> where
F: Fn(&Data) -> bool,
Send data to the VBus and wait for a reply.
This method sends the tx_data
to the VBus and waits for up to
initial_timeout_ms
milliseconds for a reply.
Every time a valid Data
is received over the VBus the filter
function is called with that Data
as its argument. The function
returns a bool
whether the provided Data
is the reply it was
waiting for.
If the filter
function returns true
, the respective Data
is used to return from the transceive
method.
If the filter
function did not find the matching reply within
initial_timeout_ms
milliseconds, the tx_data
is send again up
max_tries
times, increasing the timeout by timeout_increment_ms
milliseconds every time.
After max_tries
without a matching reply the transceive
method
returns with None
.
pub async fn receive_any_data<'_>(
&'_ mut self,
timeout_ms: u64
) -> Result<Option<Data>>
[src]
&'_ mut self,
timeout_ms: u64
) -> Result<Option<Data>>
Wait for any VBus data.
pub async fn wait_for_free_bus<'_>(&'_ mut self) -> Result<Option<Datagram>>
[src]
Wait for a datagram that offers VBus control.
pub async fn release_bus<'_>(&'_ mut self, address: u16) -> Result<Option<Data>>
[src]
Give back bus control to the regular VBus master.
pub async fn get_value_by_index<'_>(
&'_ mut self,
address: u16,
index: i16,
subindex: u8
) -> Result<Option<Datagram>>
[src]
&'_ mut self,
address: u16,
index: i16,
subindex: u8
) -> Result<Option<Datagram>>
Get a value by its index.
pub async fn set_value_by_index<'_>(
&'_ mut self,
address: u16,
index: i16,
subindex: u8,
value: i32
) -> Result<Option<Datagram>>
[src]
&'_ mut self,
address: u16,
index: i16,
subindex: u8,
value: i32
) -> Result<Option<Datagram>>
Set a value by its index.
pub async fn get_value_id_hash_by_index<'_>(
&'_ mut self,
address: u16,
index: i16
) -> Result<Option<Datagram>>
[src]
&'_ mut self,
address: u16,
index: i16
) -> Result<Option<Datagram>>
Get a value's ID hash by its index.
pub async fn get_value_index_by_id_hash<'_>(
&'_ mut self,
address: u16,
id_hash: i32
) -> Result<Option<Datagram>>
[src]
&'_ mut self,
address: u16,
id_hash: i32
) -> Result<Option<Datagram>>
Get a value's index by its ID hash.
pub async fn get_caps1<'_>(
&'_ mut self,
address: u16
) -> Result<Option<Datagram>>
[src]
&'_ mut self,
address: u16
) -> Result<Option<Datagram>>
Get the capabilities (part 1) from a VBus device.
pub async fn begin_bulk_value_transaction<'_>(
&'_ mut self,
address: u16,
tx_timeout: i32
) -> Result<Option<Datagram>>
[src]
&'_ mut self,
address: u16,
tx_timeout: i32
) -> Result<Option<Datagram>>
Begin a bulk value transaction.
pub async fn commit_bulk_value_transaction<'_>(
&'_ mut self,
address: u16
) -> Result<Option<Datagram>>
[src]
&'_ mut self,
address: u16
) -> Result<Option<Datagram>>
Commit a bulk value transaction.
pub async fn rollback_bulk_value_transaction<'_>(
&'_ mut self,
address: u16
) -> Result<Option<Datagram>>
[src]
&'_ mut self,
address: u16
) -> Result<Option<Datagram>>
Rollback a bulk value transaction.
pub async fn set_bulk_value_by_index<'_>(
&'_ mut self,
address: u16,
index: i16,
subindex: u8,
value: i32
) -> Result<Option<Datagram>>
[src]
&'_ mut self,
address: u16,
index: i16,
subindex: u8,
value: i32
) -> Result<Option<Datagram>>
Set a value by its index while inside a bulk value transaction.
Trait Implementations
Auto Trait Implementations
impl<R, W> RefUnwindSafe for LiveDataStream<R, W> where
R: RefUnwindSafe,
W: RefUnwindSafe,
R: RefUnwindSafe,
W: RefUnwindSafe,
impl<R, W> Send for LiveDataStream<R, W> where
R: Send,
W: Send,
R: Send,
W: Send,
impl<R, W> Sync for LiveDataStream<R, W> where
R: Sync,
W: Sync,
R: Sync,
W: Sync,
impl<R, W> Unpin for LiveDataStream<R, W>
impl<R, W> UnwindSafe for LiveDataStream<R, W> where
R: UnwindSafe,
W: UnwindSafe,
R: UnwindSafe,
W: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,