pub struct ReadStream<D: Data> { /* private fields */ }
Expand description
A ReadStream
allows operators to pull Message
s from a stream.
Example
The following example shows an operator that prints out messages received from a ReadStream
.
struct PrintMessageOperator<D: Data> {
phantom: PhantomData<D>,
}
impl<D: Data> Sink<(), D> for PrintMessageOperator<D> {
fn run(&mut self, config: &OperatorConfig, read_stream: &mut ReadStream<D>) {
while let Ok(message) = read_stream.read() {
println!("Recieved message: {:?}", message);
}
}
}
The examples in ExtractStream
show how to
pull data from a stream in the driver.
Implementations
sourceimpl<D: Data> ReadStream<D>
impl<D: Data> ReadStream<D>
sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Returns true
if a top watermark message was sent or the ReadStream
failed to set up.
sourcepub fn try_read(&mut self) -> Result<Message<D>, TryReadError>
pub fn try_read(&mut self) -> Result<Message<D>, TryReadError>
Non-blocking read from the ReadStream
.
Returns the Message available on the ReadStream
, or an Empty
if no message is available.
sourcepub fn read(&mut self) -> Result<Message<D>, ReadError>
pub fn read(&mut self) -> Result<Message<D>, ReadError>
Blocking read from the ReadStream
.
Returns the Message available on the ReadStream
.
Trait Implementations
impl<T: Data> Send for ReadStream<T>
impl<T: Data> Sync for ReadStream<T>
Auto Trait Implementations
impl<D> !RefUnwindSafe for ReadStream<D>
impl<D> Unpin for ReadStream<D>
impl<D> !UnwindSafe for ReadStream<D>
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
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more