[−][src]Struct libp2p_core::nodes::collection::CollectionStream
Implementation of Stream that handles a collection of nodes.
Methods
impl<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TPeerId> CollectionStream<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TPeerId> where
TPeerId: Eq + Hash + Clone, [src]
TPeerId: Eq + Hash + Clone,
pub fn new() -> Self[src]
Creates a new empty collection.
pub fn add_reach_attempt<TFut, TMuxer>(
&mut self,
future: TFut,
handler: THandler
) -> ReachAttemptId where
TFut: Future<Item = (TPeerId, TMuxer), Error = TReachErr> + Send + 'static,
THandler: IntoNodeHandler<TPeerId> + 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,
TPeerId: Send + 'static, [src]
&mut self,
future: TFut,
handler: THandler
) -> ReachAttemptId where
TFut: Future<Item = (TPeerId, TMuxer), Error = TReachErr> + Send + 'static,
THandler: IntoNodeHandler<TPeerId> + 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,
TPeerId: 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, TPeerId, TUserData>, InterruptError>[src]
&mut self,
id: ReachAttemptId
) -> Result<InterruptedReachAttempt<TInEvent, TPeerId, TUserData>, InterruptError>
Interrupts a reach attempt.
Returns Ok if something was interrupted, and Err if the ID is not or no longer valid.
pub fn broadcast_event(&mut self, event: &TInEvent) where
TInEvent: Clone, [src]
TInEvent: Clone,
Sends an event to all nodes.
pub fn peer_mut(
&mut self,
id: &TPeerId
) -> Option<PeerMut<TInEvent, TUserData, TPeerId>>[src]
&mut self,
id: &TPeerId
) -> Option<PeerMut<TInEvent, TUserData, 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]
&self
) -> impl Iterator<Item = &TPeerId>
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
) -> Async<CollectionEvent<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TPeerId>>[src]
&mut self
) -> Async<CollectionEvent<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TPeerId>>
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, TPeerId> Debug for CollectionStream<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TPeerId> where
TPeerId: Debug, [src]
TPeerId: Debug,
Auto Trait Implementations
impl<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TPeerId> Send for CollectionStream<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TPeerId> where
THandler: Send,
THandlerErr: Send,
TInEvent: Send,
TOutEvent: Send,
TPeerId: Send,
TReachErr: Send,
TUserData: Send,
THandler: Send,
THandlerErr: Send,
TInEvent: Send,
TOutEvent: Send,
TPeerId: Send,
TReachErr: Send,
TUserData: Send,
impl<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TPeerId = PeerId> !Sync for CollectionStream<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr, TUserData, TPeerId>
Blanket Implementations
impl<T> From for T[src]
impl<T, U> Into for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>, [src]
U: Into<T>,
type Error = !
try_from)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> Borrow for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Same for T
type Output = T
Should always be Self