[−][src]Struct libp2p_core::nodes::collection::CollectionStream
Implementation of Stream that handles a collection of nodes.
Methods
impl<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TConnInfo, TPeerId> CollectionStream<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TConnInfo, TPeerId> where
TConnInfo: ConnectionInfo<PeerId = TPeerId>,
TPeerId: Eq + Hash, [src]
TConnInfo: ConnectionInfo<PeerId = TPeerId>,
TPeerId: Eq + Hash,
pub fn new(executor: Option<Box<dyn Executor + Send>>) -> Self[src]
Creates a new empty collection. If executor is Some, uses the given executor to spawn
tasks. Otherwise, runs tasks locally.
pub fn add_reach_attempt<TFut, TMuxer>(
&mut self,
future: TFut,
handler: THandler
) -> ReachAttemptId where
TFut: Future<Output = Result<(TConnInfo, TMuxer), TReachErr>> + Send + 'static,
THandler: IntoNodeHandler<TConnInfo> + Send + 'static,
THandler::Handler: NodeHandler<Substream = Substream<TMuxer>, InEvent = TInEvent, OutEvent = TOutEvent, Error = THandlerErr> + Send + 'static,
<THandler::Handler as NodeHandler>::OutboundOpenInfo: Send + 'static,
TReachErr: Error + Send + 'static,
THandlerErr: Error + Send + 'static,
TInEvent: Send + 'static,
TOutEvent: Send + 'static,
TMuxer: StreamMuxer + Send + Sync + 'static,
TMuxer::OutboundSubstream: Send + 'static,
TConnInfo: Send + 'static, [src]
&mut self,
future: TFut,
handler: THandler
) -> ReachAttemptId where
TFut: Future<Output = Result<(TConnInfo, TMuxer), TReachErr>> + Send + 'static,
THandler: IntoNodeHandler<TConnInfo> + Send + 'static,
THandler::Handler: NodeHandler<Substream = Substream<TMuxer>, InEvent = TInEvent, OutEvent = TOutEvent, Error = THandlerErr> + Send + 'static,
<THandler::Handler as NodeHandler>::OutboundOpenInfo: Send + 'static,
TReachErr: Error + Send + 'static,
THandlerErr: Error + Send + 'static,
TInEvent: Send + 'static,
TOutEvent: Send + 'static,
TMuxer: StreamMuxer + Send + Sync + 'static,
TMuxer::OutboundSubstream: Send + 'static,
TConnInfo: Send + 'static,
Adds to the collection a future that tries to reach a remote.
This method spawns a task dedicated to resolving this future and processing the node's events.
pub fn interrupt(
&mut self,
id: ReachAttemptId
) -> Result<InterruptedReachAttempt<TInEvent, TConnInfo, TUserData>, InterruptError>[src]
&mut self,
id: ReachAttemptId
) -> Result<InterruptedReachAttempt<TInEvent, TConnInfo, TUserData>, InterruptError>
Interrupts a reach attempt.
Returns Ok if something was interrupted, and Err if the ID is not or no longer valid.
#[must_use]
pub fn poll_broadcast(&mut self, event: &TInEvent, cx: &mut Context) -> Poll<()> where
TInEvent: Clone, [src]
TInEvent: Clone,
Sends an event to all nodes.
This function is "atomic", in the sense that if Poll::Pending is returned then no event
has been sent to any node yet.
pub fn add_connection<TMuxer>(
&mut self,
conn_info: TConnInfo,
user_data: TUserData,
muxer: TMuxer,
handler: THandler::Handler
) -> CollectionNodeAccept<TConnInfo, TUserData> where
THandler: IntoNodeHandler<TConnInfo> + Send + 'static,
THandler::Handler: NodeHandler<Substream = Substream<TMuxer>, InEvent = TInEvent, OutEvent = TOutEvent, Error = THandlerErr> + Send + 'static,
<THandler::Handler as NodeHandler>::OutboundOpenInfo: Send + 'static,
TReachErr: Error + Send + 'static,
THandlerErr: Error + Send + 'static,
TInEvent: Send + 'static,
TOutEvent: Send + 'static,
TMuxer: StreamMuxer + Send + Sync + 'static,
TMuxer::OutboundSubstream: Send + 'static,
TConnInfo: Clone + Send + 'static,
TPeerId: Clone, [src]
&mut self,
conn_info: TConnInfo,
user_data: TUserData,
muxer: TMuxer,
handler: THandler::Handler
) -> CollectionNodeAccept<TConnInfo, TUserData> where
THandler: IntoNodeHandler<TConnInfo> + Send + 'static,
THandler::Handler: NodeHandler<Substream = Substream<TMuxer>, InEvent = TInEvent, OutEvent = TOutEvent, Error = THandlerErr> + Send + 'static,
<THandler::Handler as NodeHandler>::OutboundOpenInfo: Send + 'static,
TReachErr: Error + Send + 'static,
THandlerErr: Error + Send + 'static,
TInEvent: Send + 'static,
TOutEvent: Send + 'static,
TMuxer: StreamMuxer + Send + Sync + 'static,
TMuxer::OutboundSubstream: Send + 'static,
TConnInfo: Clone + Send + 'static,
TPeerId: Clone,
Adds an existing connection to a node to the collection.
Returns whether we have replaced an existing connection, or not.
pub fn peer_mut(
&mut self,
id: &TPeerId
) -> Option<PeerMut<TInEvent, TUserData, TConnInfo, TPeerId>>[src]
&mut self,
id: &TPeerId
) -> Option<PeerMut<TInEvent, TUserData, TConnInfo, TPeerId>>
Grants access to an object that allows controlling a peer of the collection.
Returns None if we don't have a connection to this peer.
pub fn has_connection(&self, id: &TPeerId) -> bool[src]
Returns true if we are connected to the given peer.
This will return true only after a NodeReached event has been produced by poll().
pub fn connections(&self) -> impl Iterator<Item = &TPeerId>[src]
Returns a list of all the active connections.
Does not include reach attempts that haven't reached any target yet.
pub fn poll(
&mut self,
cx: &mut Context
) -> Poll<CollectionEvent<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TConnInfo, TPeerId>> where
TConnInfo: Clone, [src]
&mut self,
cx: &mut Context
) -> Poll<CollectionEvent<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TConnInfo, TPeerId>> where
TConnInfo: Clone,
Provides an API similar to Stream, except that it cannot error.
Note: we use a regular
pollmethod instead of implementingStreamin order to remove theErrvariant, but also because we want theCollectionStreamto stay borrowed if necessary.
Trait Implementations
impl<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TConnInfo, TPeerId> Debug for CollectionStream<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TConnInfo, TPeerId> where
TConnInfo: Debug, [src]
TConnInfo: Debug,
impl<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TConnInfo, TPeerId> Unpin for CollectionStream<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TConnInfo, TPeerId>[src]
Auto Trait Implementations
impl<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TConnInfo = PeerId, TPeerId = PeerId> !RefUnwindSafe for CollectionStream<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TConnInfo, TPeerId>
impl<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TConnInfo, TPeerId> Send for CollectionStream<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TConnInfo, TPeerId> where
TConnInfo: Send,
THandler: Send,
THandlerErr: Send,
TInEvent: Send,
TOutEvent: Send,
TPeerId: Send,
TReachErr: Send,
TUserData: Send,
TConnInfo: Send,
THandler: Send,
THandlerErr: Send,
TInEvent: Send,
TOutEvent: Send,
TPeerId: Send,
TReachErr: Send,
TUserData: Send,
impl<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TConnInfo = PeerId, TPeerId = PeerId> !Sync for CollectionStream<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TConnInfo, TPeerId>
impl<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TConnInfo = PeerId, TPeerId = PeerId> !UnwindSafe for CollectionStream<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TConnInfo, TPeerId>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,