[][src]Struct libp2p_core::nodes::collection::CollectionStream

pub struct CollectionStream<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr> { /* fields omitted */ }

Implementation of Stream that handles a collection of nodes.

Methods

impl<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr> CollectionStream<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr>
[src]

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 = (PeerId, TMuxer), Error = TReachErr> + Send + 'static,
    THandler: IntoNodeHandler + 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, 
[src]

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<(), InterruptError>
[src]

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]

Sends an event to all nodes.

pub fn peer_mut(&mut self, id: &PeerId) -> Option<PeerMut<TInEvent>>
[src]

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: &PeerId) -> 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 = &PeerId>
[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
) -> Async<CollectionEvent<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr>>
[src]

Provides an API similar to Stream, except that it cannot error.

Note: we use a regular poll method instead of implementing Stream in order to remove the Err variant, but also because we want the CollectionStream to stay borrowed if necessary.

Trait Implementations

impl<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr> Debug for CollectionStream<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr>
[src]

Auto Trait Implementations

impl<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr> Send for CollectionStream<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr> where
    THandler: Send,
    THandlerErr: Send,
    TInEvent: Send,
    TOutEvent: Send,
    TReachErr: Send

impl<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr> !Sync for CollectionStream<TInEvent, TOutEvent, THandler, TReachErr, THandlerErr>

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same for T

type Output = T

Should always be Self

impl<T> Erased for T