[][src]Struct async_resol_vbus::LiveDataStream

pub struct LiveDataStream<R: Read + Unpin, W: Write + Unpin> { /* fields omitted */ }

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]

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]

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]

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]

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]

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]

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]

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]

Get a value's index by its ID hash.

pub async fn get_caps1<'_>(
    &'_ mut self,
    address: u16
) -> Result<Option<Datagram>>
[src]

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]

Begin a bulk value transaction.

pub async fn commit_bulk_value_transaction<'_>(
    &'_ mut self,
    address: u16
) -> Result<Option<Datagram>>
[src]

Commit a bulk value transaction.

pub async fn rollback_bulk_value_transaction<'_>(
    &'_ mut self,
    address: u16
) -> Result<Option<Datagram>>
[src]

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]

Set a value by its index while inside a bulk value transaction.

Trait Implementations

impl<R: Debug + Read + Unpin, W: Debug + Write + Unpin> Debug for LiveDataStream<R, W>[src]

Auto Trait Implementations

impl<R, W> RefUnwindSafe for LiveDataStream<R, W> where
    R: RefUnwindSafe,
    W: RefUnwindSafe

impl<R, W> Send for LiveDataStream<R, W> where
    R: Send,
    W: Send

impl<R, W> Sync for LiveDataStream<R, W> where
    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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.