Struct reducer::AsyncDispatcher
source · [−]pub struct AsyncDispatcher<T>(pub T);
Expand description
An adapter for [Sink
]s that behaves as an asynchronous Dispatcher
(requires async
).
Example
use reducer::*;
use futures::channel::mpsc::channel;
use futures::executor::block_on_stream;
use std::thread;
let (tx, rx) = channel(0);
let mut dispatcher = AsyncDispatcher(tx);
thread::spawn(move || {
dispatcher.dispatch(1);
dispatcher.dispatch(1);
dispatcher.dispatch(2);
dispatcher.dispatch(3);
dispatcher.dispatch(5);
dispatcher.dispatch(8);
});
assert_eq!(block_on_stream(rx).collect::<Vec<u8>>(), [1, 1, 2, 3, 5, 8]);
Tuple Fields
0: T
Trait Implementations
sourceimpl<T: Clone> Clone for AsyncDispatcher<T>
impl<T: Clone> Clone for AsyncDispatcher<T>
sourcefn clone(&self) -> AsyncDispatcher<T>
fn clone(&self) -> AsyncDispatcher<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T: Debug> Debug for AsyncDispatcher<T>
impl<T: Debug> Debug for AsyncDispatcher<T>
sourceimpl<T: Default> Default for AsyncDispatcher<T>
impl<T: Default> Default for AsyncDispatcher<T>
sourcefn default() -> AsyncDispatcher<T>
fn default() -> AsyncDispatcher<T>
Returns the “default value” for a type. Read more
sourceimpl<T> Deref for AsyncDispatcher<T>
impl<T> Deref for AsyncDispatcher<T>
sourceimpl<T> DerefMut for AsyncDispatcher<T>
impl<T> DerefMut for AsyncDispatcher<T>
sourceimpl<A, T> Dispatcher<A> for AsyncDispatcher<T> where
T: Sink<A> + Unpin,
impl<A, T> Dispatcher<A> for AsyncDispatcher<T> where
T: Sink<A> + Unpin,
sourceimpl<T> From<T> for AsyncDispatcher<T>
impl<T> From<T> for AsyncDispatcher<T>
sourcefn from(original: T) -> AsyncDispatcher<T>
fn from(original: T) -> AsyncDispatcher<T>
Converts to this type from the input type.
sourceimpl<T: Hash> Hash for AsyncDispatcher<T>
impl<T: Hash> Hash for AsyncDispatcher<T>
sourceimpl<T: PartialEq> PartialEq<AsyncDispatcher<T>> for AsyncDispatcher<T>
impl<T: PartialEq> PartialEq<AsyncDispatcher<T>> for AsyncDispatcher<T>
sourcefn eq(&self, other: &AsyncDispatcher<T>) -> bool
fn eq(&self, other: &AsyncDispatcher<T>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &AsyncDispatcher<T>) -> bool
fn ne(&self, other: &AsyncDispatcher<T>) -> bool
This method tests for !=
.
sourceimpl<A, T> Sink<A> for AsyncDispatcher<T> where
T: Sink<A>,
impl<A, T> Sink<A> for AsyncDispatcher<T> where
T: Sink<A>,
type Error = T::Error
type Error = T::Error
The type of value produced by the sink when an error occurs.
sourcefn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Result<(), Self::Error>>
fn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Result<(), Self::Error>>
Attempts to prepare the Sink
to receive a value. Read more
sourcefn start_send(self: Pin<&mut Self>, action: A) -> Result<(), Self::Error>
fn start_send(self: Pin<&mut Self>, action: A) -> Result<(), Self::Error>
Begin the process of sending a value to the sink.
Each call to this function must be preceded by a successful call to
poll_ready
which returned Poll::Ready(Ok(()))
. Read more
impl<T: Copy> Copy for AsyncDispatcher<T>
impl<T: Eq> Eq for AsyncDispatcher<T>
impl<T> StructuralEq for AsyncDispatcher<T>
impl<T> StructuralPartialEq for AsyncDispatcher<T>
impl<'pin, T> Unpin for AsyncDispatcher<T> where
__AsyncDispatcher<'pin, T>: Unpin,
Auto Trait Implementations
impl<T> RefUnwindSafe for AsyncDispatcher<T> where
T: RefUnwindSafe,
impl<T> Send for AsyncDispatcher<T> where
T: Send,
impl<T> Sync for AsyncDispatcher<T> where
T: Sync,
impl<T> UnwindSafe for AsyncDispatcher<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, Item> SinkExt<Item> for T where
T: Sink<Item> + ?Sized,
impl<T, Item> SinkExt<Item> for T where
T: Sink<Item> + ?Sized,
fn with<U, Fut, F, E>(self, f: F) -> With<Self, Item, U, Fut, F> where
F: FnMut(U) -> Fut,
Fut: Future<Output = Result<Item, E>>,
E: From<Self::Error>,
fn with<U, Fut, F, E>(self, f: F) -> With<Self, Item, U, Fut, F> where
F: FnMut(U) -> Fut,
Fut: Future<Output = Result<Item, E>>,
E: From<Self::Error>,
Composes a function in front of the sink. Read more
fn with_flat_map<U, St, F>(self, f: F) -> WithFlatMap<Self, Item, U, St, F> where
F: FnMut(U) -> St,
St: Stream<Item = Result<Item, Self::Error>>,
fn with_flat_map<U, St, F>(self, f: F) -> WithFlatMap<Self, Item, U, St, F> where
F: FnMut(U) -> St,
St: Stream<Item = Result<Item, Self::Error>>,
Composes a function in front of the sink. Read more
fn sink_map_err<E, F>(self, f: F) -> SinkMapErr<Self, F> where
F: FnOnce(Self::Error) -> E,
fn sink_map_err<E, F>(self, f: F) -> SinkMapErr<Self, F> where
F: FnOnce(Self::Error) -> E,
Transforms the error returned by the sink.
fn sink_err_into<E>(self) -> SinkErrInto<Self, Item, E> where
Self::Error: Into<E>,
fn sink_err_into<E>(self) -> SinkErrInto<Self, Item, E> where
Self::Error: Into<E>,
Map this sink’s error to a different error type using the Into
trait. Read more
fn buffer(self, capacity: usize) -> Buffer<Self, Item>
fn buffer(self, capacity: usize) -> Buffer<Self, Item>
Adds a fixed-size buffer to the current sink. Read more
fn fanout<Si>(self, other: Si) -> Fanout<Self, Si> where
Item: Clone,
Si: Sink<Item, Error = Self::Error>,
fn fanout<Si>(self, other: Si) -> Fanout<Self, Si> where
Item: Clone,
Si: Sink<Item, Error = Self::Error>,
Fanout items to multiple sinks. Read more
fn flush(&mut self) -> Flush<'_, Self, Item> where
Self: Unpin,
fn flush(&mut self) -> Flush<'_, Self, Item> where
Self: Unpin,
Flush the sink, processing all pending items. Read more
fn send(&mut self, item: Item) -> Send<'_, Self, Item> where
Self: Unpin,
fn send(&mut self, item: Item) -> Send<'_, Self, Item> where
Self: Unpin,
A future that completes after the given item has been fully processed into the sink, including flushing. Read more
fn feed(&mut self, item: Item) -> Feed<'_, Self, Item> where
Self: Unpin,
fn feed(&mut self, item: Item) -> Feed<'_, Self, Item> where
Self: Unpin,
A future that completes after the given item has been received by the sink. Read more
fn send_all<St>(&'a mut self, stream: &'a mut St) -> SendAll<'a, Self, St> where
St: TryStream<Ok = Item, Error = Self::Error> + Stream + Unpin + ?Sized,
Self: Unpin,
fn send_all<St>(&'a mut self, stream: &'a mut St) -> SendAll<'a, Self, St> where
St: TryStream<Ok = Item, Error = Self::Error> + Stream + Unpin + ?Sized,
Self: Unpin,
A future that completes after the given stream has been fully processed into the sink, including flushing. Read more
fn left_sink<Si2>(self) -> Either<Self, Si2> where
Si2: Sink<Item, Error = Self::Error>,
fn left_sink<Si2>(self) -> Either<Self, Si2> where
Si2: Sink<Item, Error = Self::Error>,
Wrap this sink in an Either
sink, making it the left-hand variant
of that Either
. Read more
fn right_sink<Si1>(self) -> Either<Si1, Self> where
Si1: Sink<Item, Error = Self::Error>,
fn right_sink<Si1>(self) -> Either<Si1, Self> where
Si1: Sink<Item, Error = Self::Error>,
Wrap this stream in an Either
stream, making it the right-hand variant
of that Either
. Read more
fn poll_ready_unpin(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<(), Self::Error>> where
Self: Unpin,
fn poll_ready_unpin(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<(), Self::Error>> where
Self: Unpin,
fn start_send_unpin(&mut self, item: Item) -> Result<(), Self::Error> where
Self: Unpin,
fn start_send_unpin(&mut self, item: Item) -> Result<(), Self::Error> where
Self: Unpin,
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more