[][src]Struct libp2p_core::nodes::raw_swarm::RawSwarm

pub struct RawSwarm<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo = PeerId, TPeerId = PeerId> where
    TTrans: Transport
{ /* fields omitted */ }

Implementation of Stream that handles the nodes.

Methods

impl<TTrans, TInEvent, TOutEvent, TMuxer, THandler, THandlerErr, TConnInfo, TPeerId> RawSwarm<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId> where
    TTrans: Transport + Clone,
    TMuxer: StreamMuxer,
    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,
    THandlerErr: Error + Send + 'static,
    TConnInfo: Debug + ConnectionInfo<PeerId = TPeerId> + Send + 'static,
    TPeerId: Eq + Hash + Clone
[src]

pub fn new(transport: TTrans, local_peer_id: TPeerId) -> Self[src]

Creates a new node events stream.

pub fn new_with_incoming_limit(
    transport: TTrans,
    local_peer_id: TPeerId,
    incoming_limit: Option<u32>
) -> Self
[src]

Creates a new node event stream with incoming connections limit.

pub fn transport(&self) -> &TTrans[src]

Returns the transport passed when building this object.

pub fn listen_on(
    &mut self,
    addr: Multiaddr
) -> Result<(), TransportError<TTrans::Error>>
[src]

Start listening on the given multiaddress.

pub fn listen_addrs(&self) -> impl Iterator<Item = &Multiaddr>[src]

Returns an iterator that produces the list of addresses we are listening on.

pub fn incoming_limit(&self) -> Option<u32>[src]

Returns limit on incoming connections.

pub fn nat_traversal<'a>(
    &'a self,
    observed_addr: &'a Multiaddr
) -> impl Iterator<Item = Multiaddr> + 'a where
    TMuxer: 'a,
    THandler: 'a, 
[src]

Call this function in order to know which address remotes should dial in order to access your local node.

observed_addr should be an address a remote observes you as, which can be obtained for example with the identify protocol.

For each listener, calls nat_traversal with the observed address and returns the outcome.

pub fn local_peer_id(&self) -> &TPeerId[src]

Returns the peer id of the local node.

This is the same value as was passed to new().

pub fn dial(
    &mut self,
    addr: Multiaddr,
    handler: THandler
) -> Result<(), TransportError<TTrans::Error>> where
    TTrans: Transport<Output = (TConnInfo, TMuxer)>,
    TTrans::Error: Send + 'static,
    TTrans::Dial: Send + 'static,
    TMuxer: StreamMuxer + Send + Sync + 'static,
    TMuxer::OutboundSubstream: Send,
    TMuxer::Substream: Send,
    TInEvent: Send + 'static,
    TOutEvent: Send + 'static,
    TConnInfo: Send + 'static,
    TPeerId: Send + 'static, 
[src]

Dials a multiaddress without knowing the peer ID we're going to obtain.

The second parameter is the handler to use if we manage to reach a node.

pub fn num_incoming_negotiated(&self) -> usize[src]

Deprecated:

Use incoming_negotiated().count() instead

Returns the number of incoming connections that are currently in the process of being negotiated.

We don't know anything about these connections yet, so all we can do is know how many of them we have.

pub fn incoming_negotiated(&self) -> impl Iterator<Item = IncomingInfo>[src]

Returns the list of incoming connections that are currently in the process of being negotiated. We don't know the PeerId of these nodes yet.

pub fn broadcast_event(&mut self, event: &TInEvent) where
    TInEvent: Clone
[src]

Sends an event to all nodes.

pub fn connected_peers(&self) -> impl Iterator<Item = &TPeerId>[src]

Returns a list of all the peers we are currently connected to.

Calling peer() with each PeerId is guaranteed to produce a PeerConnected.

pub fn pending_connection_peers(&self) -> impl Iterator<Item = &TPeerId>[src]

Returns a list of all the nodes we are currently trying to reach.

Calling peer() with each PeerId is guaranteed to produce a PeerPendingConnect

pub fn unknown_dials(&self) -> impl Iterator<Item = &Multiaddr>[src]

Returns the list of addresses we're currently dialing without knowing the PeerId of.

pub fn peer(
    &mut self,
    peer_id: TPeerId
) -> Peer<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId>
[src]

Grants access to a struct that represents a peer.

pub fn poll(
    &mut self
) -> Async<RawSwarmEvent<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId>> where
    TTrans: Transport<Output = (TConnInfo, TMuxer)>,
    TTrans::Error: Send + 'static,
    TTrans::Dial: Send + 'static,
    TTrans::ListenerUpgrade: Send + 'static,
    TMuxer: StreamMuxer + Send + Sync + 'static,
    TMuxer::OutboundSubstream: Send,
    TMuxer::Substream: Send,
    TInEvent: Send + 'static,
    TOutEvent: 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,
    THandlerErr: Error + Send + 'static,
    TConnInfo: Clone,
    TPeerId: AsRef<[u8]> + Send + 'static, 
[src]

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

Trait Implementations

impl<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId> Debug for RawSwarm<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId> where
    TTrans: Debug + Transport,
    TConnInfo: Debug,
    TPeerId: Debug + Eq + Hash
[src]

Auto Trait Implementations

impl<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId> Send for RawSwarm<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId> where
    TConnInfo: Send,
    THandler: Send,
    THandlerErr: Send,
    TInEvent: Send,
    TOutEvent: Send,
    TPeerId: Send,
    TTrans: Send,
    <TTrans as Transport>::Error: Send,
    <TTrans as Transport>::Listener: Send

impl<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo = PeerId, TPeerId = PeerId> !Sync for RawSwarm<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId>

Blanket Implementations

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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

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

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

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Erased for T