Struct tokio_resol_vbus::LiveDataStream
source · pub struct LiveDataStream<R: AsyncRead, W: AsyncWrite> { /* private fields */ }
Expand description
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.
Implementations§
source§impl<R: AsyncRead, W: AsyncWrite> LiveDataStream<R, W>
impl<R: AsyncRead, W: AsyncWrite> LiveDataStream<R, W>
sourcepub fn new(
reader: R,
writer: W,
channel: u8,
self_address: u16
) -> LiveDataStream<R, W>
pub fn new(
reader: R,
writer: W,
channel: u8,
self_address: u16
) -> LiveDataStream<R, W>
Create a new LiveDataStream
.
sourcepub fn into_inner(self) -> (R, W)
pub fn into_inner(self) -> (R, W)
Consume self
and return the underlying I/O pair.
sourcepub fn receive<F>(
self,
timeout_ms: u64,
filter: F
) -> impl Future<Item = (Self, Option<Data>), Error = Error>where
F: Fn(&Data) -> bool + Send + 'static,
pub fn receive<F>(
self,
timeout_ms: u64,
filter: F
) -> impl Future<Item = (Self, Option<Data>), Error = Error>where
F: Fn(&Data) -> bool + Send + 'static,
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 resolve the receive
method’s Future
.
If the filter
function did not find the matching data within
timeout_ms
milliseconds, the receive
method’s Future
resolves
with (self, None)
.
sourcepub fn transceive<F>(
self,
tx_data: Data,
max_tries: usize,
initial_timeout_ms: u64,
timeout_increment_ms: u64,
filter: F
) -> impl Future<Item = (Self, Option<Data>), Error = Error>where
F: Fn(&Data) -> bool + Send + 'static,
pub fn transceive<F>(
self,
tx_data: Data,
max_tries: usize,
initial_timeout_ms: u64,
timeout_increment_ms: u64,
filter: F
) -> impl Future<Item = (Self, Option<Data>), Error = Error>where
F: Fn(&Data) -> bool + Send + 'static,
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 resolve the transceive
method’s Future
.
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’s
Future
resolves with (self, None)
.
sourcepub fn receive_any_data(
self,
timeout_ms: u64
) -> impl Future<Item = (Self, Option<Data>), Error = Error>
pub fn receive_any_data(
self,
timeout_ms: u64
) -> impl Future<Item = (Self, Option<Data>), Error = Error>
Wait for any VBus data.
sourcepub fn wait_for_free_bus(
self
) -> impl Future<Item = (Self, Option<Datagram>), Error = Error>
pub fn wait_for_free_bus(
self
) -> impl Future<Item = (Self, Option<Datagram>), Error = Error>
Wait for a datagram that offers VBus control.
sourcepub fn release_bus(
self,
address: u16
) -> impl Future<Item = (Self, Option<Data>), Error = Error>
pub fn release_bus(
self,
address: u16
) -> impl Future<Item = (Self, Option<Data>), Error = Error>
Give back bus control to the regular VBus master.
sourcepub fn get_value_by_index(
self,
address: u16,
index: i16,
subindex: u8
) -> impl Future<Item = (Self, Option<Datagram>), Error = Error>
pub fn get_value_by_index(
self,
address: u16,
index: i16,
subindex: u8
) -> impl Future<Item = (Self, Option<Datagram>), Error = Error>
Get a value by its index.
sourcepub fn set_value_by_index(
self,
address: u16,
index: i16,
subindex: u8,
value: i32
) -> impl Future<Item = (Self, Option<Datagram>), Error = Error>
pub fn set_value_by_index(
self,
address: u16,
index: i16,
subindex: u8,
value: i32
) -> impl Future<Item = (Self, Option<Datagram>), Error = Error>
Set a value by its index.
sourcepub fn get_value_id_hash_by_index(
self,
address: u16,
index: i16
) -> impl Future<Item = (Self, Option<Datagram>), Error = Error>
pub fn get_value_id_hash_by_index(
self,
address: u16,
index: i16
) -> impl Future<Item = (Self, Option<Datagram>), Error = Error>
Get a value’s ID hash by its index.
sourcepub fn get_value_index_by_id_hash(
self,
address: u16,
id_hash: i32
) -> impl Future<Item = (Self, Option<Datagram>), Error = Error>
pub fn get_value_index_by_id_hash(
self,
address: u16,
id_hash: i32
) -> impl Future<Item = (Self, Option<Datagram>), Error = Error>
Get a value’s index by its ID hash.
sourcepub fn get_caps1(
self,
address: u16
) -> impl Future<Item = (Self, Option<Datagram>), Error = Error>
pub fn get_caps1(
self,
address: u16
) -> impl Future<Item = (Self, Option<Datagram>), Error = Error>
Get the capabilities (part 1) from a VBus device.
sourcepub fn begin_bulk_value_transaction(
self,
address: u16,
tx_timeout: i32
) -> impl Future<Item = (Self, Option<Datagram>), Error = Error>
pub fn begin_bulk_value_transaction(
self,
address: u16,
tx_timeout: i32
) -> impl Future<Item = (Self, Option<Datagram>), Error = Error>
Begin a bulk value transaction.
sourcepub fn commit_bulk_value_transaction(
self,
address: u16
) -> impl Future<Item = (Self, Option<Datagram>), Error = Error>
pub fn commit_bulk_value_transaction(
self,
address: u16
) -> impl Future<Item = (Self, Option<Datagram>), Error = Error>
Commit a bulk value transaction.
Trait Implementations§
source§impl<R: Debug + AsyncRead, W: Debug + AsyncWrite> Debug for LiveDataStream<R, W>
impl<R: Debug + AsyncRead, W: Debug + AsyncWrite> Debug for LiveDataStream<R, W>
source§impl<R: AsyncRead, W: AsyncWrite> Sink for LiveDataStream<R, W>
impl<R: AsyncRead, W: AsyncWrite> Sink for LiveDataStream<R, W>
source§fn start_send(&mut self, data: Data) -> StartSend<Data, Error>
fn start_send(&mut self, data: Data) -> StartSend<Data, Error>
source§fn poll_complete(&mut self) -> Poll<(), Error>
fn poll_complete(&mut self) -> Poll<(), Error>
source§fn close(&mut self) -> Result<Async<()>, Self::SinkError>
fn close(&mut self) -> Result<Async<()>, Self::SinkError>
source§fn wait(self) -> Wait<Self>where
Self: Sized,
fn wait(self) -> Wait<Self>where
Self: Sized,
source§fn with<U, F, Fut>(self, f: F) -> With<Self, U, F, Fut>where
F: FnMut(U) -> Fut,
Fut: IntoFuture<Item = Self::SinkItem>,
<Fut as IntoFuture>::Error: From<Self::SinkError>,
Self: Sized,
fn with<U, F, Fut>(self, f: F) -> With<Self, U, F, Fut>where
F: FnMut(U) -> Fut,
Fut: IntoFuture<Item = Self::SinkItem>,
<Fut as IntoFuture>::Error: From<Self::SinkError>,
Self: Sized,
source§fn with_flat_map<U, F, St>(self, f: F) -> WithFlatMap<Self, U, F, St>where
F: FnMut(U) -> St,
St: Stream<Item = Self::SinkItem, Error = Self::SinkError>,
Self: Sized,
fn with_flat_map<U, F, St>(self, f: F) -> WithFlatMap<Self, U, F, St>where
F: FnMut(U) -> St,
St: Stream<Item = Self::SinkItem, Error = Self::SinkError>,
Self: Sized,
source§fn sink_map_err<F, E>(self, f: F) -> SinkMapErr<Self, F>where
F: FnOnce(Self::SinkError) -> E,
Self: Sized,
fn sink_map_err<F, E>(self, f: F) -> SinkMapErr<Self, F>where
F: FnOnce(Self::SinkError) -> E,
Self: Sized,
source§fn sink_from_err<E>(self) -> SinkFromErr<Self, E>where
E: From<Self::SinkError>,
Self: Sized,
fn sink_from_err<E>(self) -> SinkFromErr<Self, E>where
E: From<Self::SinkError>,
Self: Sized,
From
for this sink’s
Error
, returning a new sink. Read moresource§fn buffer(self, amt: usize) -> Buffer<Self>where
Self: Sized,
fn buffer(self, amt: usize) -> Buffer<Self>where
Self: Sized,
source§fn flush(self) -> Flush<Self>where
Self: Sized,
fn flush(self) -> Flush<Self>where
Self: Sized,
source§impl<R: AsyncRead, W: AsyncWrite> Stream for LiveDataStream<R, W>
impl<R: AsyncRead, W: AsyncWrite> Stream for LiveDataStream<R, W>
source§fn poll(&mut self) -> Poll<Option<Data>, Error>
fn poll(&mut self) -> Poll<Option<Data>, Error>
None
if
the stream is finished. Read moresource§fn wait(self) -> Wait<Self>where
Self: Sized,
fn wait(self) -> Wait<Self>where
Self: Sized,
source§fn into_future(self) -> StreamFuture<Self>where
Self: Sized,
fn into_future(self) -> StreamFuture<Self>where
Self: Sized,
Future
. Read moresource§fn map_err<U, F>(self, f: F) -> MapErr<Self, F>where
F: FnMut(Self::Error) -> U,
Self: Sized,
fn map_err<U, F>(self, f: F) -> MapErr<Self, F>where
F: FnMut(Self::Error) -> U,
Self: Sized,
source§fn filter<F>(self, f: F) -> Filter<Self, F>where
F: FnMut(&Self::Item) -> bool,
Self: Sized,
fn filter<F>(self, f: F) -> Filter<Self, F>where
F: FnMut(&Self::Item) -> bool,
Self: Sized,
source§fn filter_map<F, B>(self, f: F) -> FilterMap<Self, F>where
F: FnMut(Self::Item) -> Option<B>,
Self: Sized,
fn filter_map<F, B>(self, f: F) -> FilterMap<Self, F>where
F: FnMut(Self::Item) -> Option<B>,
Self: Sized,
source§fn then<F, U>(self, f: F) -> Then<Self, F, U>where
F: FnMut(Result<Self::Item, Self::Error>) -> U,
U: IntoFuture,
Self: Sized,
fn then<F, U>(self, f: F) -> Then<Self, F, U>where
F: FnMut(Result<Self::Item, Self::Error>) -> U,
U: IntoFuture,
Self: Sized,
f
. Read moresource§fn and_then<F, U>(self, f: F) -> AndThen<Self, F, U>where
F: FnMut(Self::Item) -> U,
U: IntoFuture<Error = Self::Error>,
Self: Sized,
fn and_then<F, U>(self, f: F) -> AndThen<Self, F, U>where
F: FnMut(Self::Item) -> U,
U: IntoFuture<Error = Self::Error>,
Self: Sized,
f
. Read moresource§fn or_else<F, U>(self, f: F) -> OrElse<Self, F, U>where
F: FnMut(Self::Error) -> U,
U: IntoFuture<Item = Self::Item>,
Self: Sized,
fn or_else<F, U>(self, f: F) -> OrElse<Self, F, U>where
F: FnMut(Self::Error) -> U,
U: IntoFuture<Item = Self::Item>,
Self: Sized,
f
. Read moresource§fn collect(self) -> Collect<Self>where
Self: Sized,
fn collect(self) -> Collect<Self>where
Self: Sized,
source§fn fold<F, T, Fut>(self, init: T, f: F) -> Fold<Self, F, Fut, T>where
F: FnMut(T, Self::Item) -> Fut,
Fut: IntoFuture<Item = T>,
Self::Error: From<<Fut as IntoFuture>::Error>,
Self: Sized,
fn fold<F, T, Fut>(self, init: T, f: F) -> Fold<Self, F, Fut, T>where
F: FnMut(T, Self::Item) -> Fut,
Fut: IntoFuture<Item = T>,
Self::Error: From<<Fut as IntoFuture>::Error>,
Self: Sized,
source§fn skip_while<P, R>(self, pred: P) -> SkipWhile<Self, P, R>where
P: FnMut(&Self::Item) -> R,
R: IntoFuture<Item = bool, Error = Self::Error>,
Self: Sized,
fn skip_while<P, R>(self, pred: P) -> SkipWhile<Self, P, R>where
P: FnMut(&Self::Item) -> R,
R: IntoFuture<Item = bool, Error = Self::Error>,
Self: Sized,
true
. Read moresource§fn take_while<P, R>(self, pred: P) -> TakeWhile<Self, P, R>where
P: FnMut(&Self::Item) -> R,
R: IntoFuture<Item = bool, Error = Self::Error>,
Self: Sized,
fn take_while<P, R>(self, pred: P) -> TakeWhile<Self, P, R>where
P: FnMut(&Self::Item) -> R,
R: IntoFuture<Item = bool, Error = Self::Error>,
Self: Sized,
true
. Read moresource§fn for_each<F, U>(self, f: F) -> ForEach<Self, F, U>where
F: FnMut(Self::Item) -> U,
U: IntoFuture<Item = (), Error = Self::Error>,
Self: Sized,
fn for_each<F, U>(self, f: F) -> ForEach<Self, F, U>where
F: FnMut(Self::Item) -> U,
U: IntoFuture<Item = (), Error = Self::Error>,
Self: Sized,
source§fn from_err<E>(self) -> FromErr<Self, E>where
E: From<Self::Error>,
Self: Sized,
fn from_err<E>(self) -> FromErr<Self, E>where
E: From<Self::Error>,
Self: Sized,
From
for
this stream’s Error
, returning a new stream. Read moresource§fn take(self, amt: u64) -> Take<Self>where
Self: Sized,
fn take(self, amt: u64) -> Take<Self>where
Self: Sized,
amt
items of the underlying stream. Read moresource§fn skip(self, amt: u64) -> Skip<Self>where
Self: Sized,
fn skip(self, amt: u64) -> Skip<Self>where
Self: Sized,
amt
items of the underlying stream. Read moresource§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll
will never again be called once it has
finished. Read moresource§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
source§fn merge<S>(self, other: S) -> Merge<Self, S>where
S: Stream<Error = Self::Error>,
Self: Sized,
fn merge<S>(self, other: S) -> Merge<Self, S>where
S: Stream<Error = Self::Error>,
Self: Sized,
select
nowsource§fn zip<S>(self, other: S) -> Zip<Self, S>where
S: Stream<Error = Self::Error>,
Self: Sized,
fn zip<S>(self, other: S) -> Zip<Self, S>where
S: Stream<Error = Self::Error>,
Self: Sized,
source§fn chain<S>(self, other: S) -> Chain<Self, S>where
S: Stream<Item = Self::Item, Error = Self::Error>,
Self: Sized,
fn chain<S>(self, other: S) -> Chain<Self, S>where
S: Stream<Item = Self::Item, Error = Self::Error>,
Self: Sized,
source§fn peekable(self) -> Peekable<Self>where
Self: Sized,
fn peekable(self) -> Peekable<Self>where
Self: Sized,
peek
method. Read more