Struct libp2p_core::nodes::node::NodeStream
source · pub struct NodeStream<TMuxer, TUserData>where
TMuxer: StreamMuxer,{ /* private fields */ }Expand description
Implementation of Stream that handles a node.
The stream will receive substreams and can be used to open new outgoing substreams. Destroying
the NodeStream will not close the existing substreams.
The stream will close once both the inbound and outbound channels are closed, and no more outbound substream attempt is pending.
Implementations
sourceimpl<TMuxer, TUserData> NodeStream<TMuxer, TUserData>where
TMuxer: StreamMuxer,
impl<TMuxer, TUserData> NodeStream<TMuxer, TUserData>where
TMuxer: StreamMuxer,
sourcepub fn open_substream(&mut self, user_data: TUserData) -> Result<(), TUserData>
pub fn open_substream(&mut self, user_data: TUserData) -> Result<(), TUserData>
Starts the process of opening a new outbound substream.
Returns an error if the outbound side of the muxer is closed.
After calling this method, polling the stream should eventually produce either an
OutboundSubstream event or an OutboundClosed event containing the user data that has
been passed to this method.
sourcepub fn is_inbound_open(&self) -> bool
pub fn is_inbound_open(&self) -> bool
Returns true if the inbound channel of the muxer is open.
If true is returned, more inbound substream will be produced.
sourcepub fn is_outbound_open(&self) -> bool
pub fn is_outbound_open(&self) -> bool
Returns true if the outbound channel of the muxer is open.
If true is returned, more outbound substream can be opened. Otherwise, calling
open_substream will return an Err.
sourcepub fn close(self) -> Vec<TUserData>
pub fn close(self) -> Vec<TUserData>
Destroys the node stream and returns all the pending outbound substreams.
sourcepub fn cancel_outgoing(&mut self) -> Vec<TUserData>
pub fn cancel_outgoing(&mut self) -> Vec<TUserData>
Destroys all outbound streams and returns the corresponding user data.
sourcepub fn shutdown_all(&mut self)
pub fn shutdown_all(&mut self)
Trigger node shutdown.
After this, NodeStream::poll will eventually produce None, when both endpoints are
closed.
Trait Implementations
sourceimpl<TMuxer, TUserData> Debug for NodeStream<TMuxer, TUserData>where
TMuxer: StreamMuxer,
impl<TMuxer, TUserData> Debug for NodeStream<TMuxer, TUserData>where
TMuxer: StreamMuxer,
sourceimpl<TMuxer, TUserData> Drop for NodeStream<TMuxer, TUserData>where
TMuxer: StreamMuxer,
impl<TMuxer, TUserData> Drop for NodeStream<TMuxer, TUserData>where
TMuxer: StreamMuxer,
sourceimpl<TMuxer, TUserData> Stream for NodeStream<TMuxer, TUserData>where
TMuxer: StreamMuxer,
impl<TMuxer, TUserData> Stream for NodeStream<TMuxer, TUserData>where
TMuxer: StreamMuxer,
sourcefn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error>
fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error>
None if
the stream is finished. Read moresourcefn wait(self) -> Wait<Self>where
Self: Sized,
fn wait(self) -> Wait<Self>where
Self: Sized,
sourcefn into_future(self) -> StreamFuture<Self>where
Self: Sized,
fn into_future(self) -> StreamFuture<Self>where
Self: Sized,
Future. Read moresourcefn 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,
sourcefn 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,
sourcefn 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 moresourcefn 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 moresourcefn 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 moresourcefn collect(self) -> Collect<Self>where
Self: Sized,
fn collect(self) -> Collect<Self>where
Self: Sized,
sourcefn 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,
sourcefn 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 moresourcefn 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 moresourcefn 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,
sourcefn 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 moresourcefn 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 moresourcefn 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 moresourcefn 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 moresourcefn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
sourcefn 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 nowsourcefn 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,
sourcefn 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,
sourcefn peekable(self) -> Peekable<Self>where
Self: Sized,
fn peekable(self) -> Peekable<Self>where
Self: Sized,
peek method. Read more