pub struct Stream<T: Clone + Send> { /* private fields */ }
Expand description
Streams allow for streaming values from source to sink.
A Stream implements both a reader (which implements the Stream trait), and a writer (which can be sent to another thread). As new values are written, any pending readers will be woken up to receive the new value.
Implementations§
Source§impl<T: Clone + Send> Stream<T>
impl<T: Clone + Send> Stream<T>
Sourcepub fn new_closed(pulled: Vec<T>) -> Self
pub fn new_closed(pulled: Vec<T>) -> Self
Constructs a new Stream, and immediately closes it with only the passed values.
Sourcepub fn new_open(
pulled: Vec<T>,
source: Box<dyn StreamTrait<Item = T> + Send + 'static>,
) -> Self
pub fn new_open( pulled: Vec<T>, source: Box<dyn StreamTrait<Item = T> + Send + 'static>, ) -> Self
Creates a new Stream, which will lazily pull from the source stream.
Sourcepub fn read(&self) -> StreamRead<T>
pub fn read(&self) -> StreamRead<T>
Returns a [StreamTrait] implementation to poll values out of our Stream.
pub async fn into_single(&self) -> SingleValue<T>
Trait Implementations§
Source§impl<'de, T: Clone + Send + Deserialize<'de>> Deserialize<'de> for Stream<T>
impl<'de, T: Clone + Send + Deserialize<'de>> Deserialize<'de> for Stream<T>
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T: Clone + Send, S: StreamTrait<Item = T> + Send + Unpin + 'static> From<S> for Stream<T>
impl<T: Clone + Send, S: StreamTrait<Item = T> + Send + Unpin + 'static> From<S> for Stream<T>
impl<T: Clone + Eq + Send> Eq for Stream<T>
Auto Trait Implementations§
impl<T> Freeze for Stream<T>
impl<T> RefUnwindSafe for Stream<T>
impl<T> Send for Stream<T>
impl<T> Sync for Stream<T>
impl<T> Unpin for Stream<T>
impl<T> UnwindSafe for Stream<T>
Blanket Implementations§
§impl<T> Any for Twhere
T: Any,
impl<T> Any for Twhere
T: Any,
fn get_type_id(&self) -> TypeId
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more