[−][src]Struct libp2p::core::nodes::network::Network
Implementation of Stream
that handles the nodes.
Methods
impl<TTrans, TInEvent, TOutEvent, TMuxer, THandler, THandlerErr, TConnInfo, TPeerId> Network<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId> where
TConnInfo: Debug + ConnectionInfo<PeerId = TPeerId> + Send + 'static,
THandler: IntoNodeHandler<(TConnInfo, ConnectedPoint)> + Send + 'static,
THandlerErr: Error + Send + 'static,
TMuxer: StreamMuxer,
TPeerId: Eq + Hash + Clone,
TTrans: Transport + Clone,
<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler: NodeHandler,
<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler: Send,
<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler: 'static,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::OutboundOpenInfo: Send,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::OutboundOpenInfo: 'static,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::Substream == SubstreamRef<Arc<TMuxer>>,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::InEvent == TInEvent,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::OutEvent == TOutEvent,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::Error == THandlerErr,
[src]
TConnInfo: Debug + ConnectionInfo<PeerId = TPeerId> + Send + 'static,
THandler: IntoNodeHandler<(TConnInfo, ConnectedPoint)> + Send + 'static,
THandlerErr: Error + Send + 'static,
TMuxer: StreamMuxer,
TPeerId: Eq + Hash + Clone,
TTrans: Transport + Clone,
<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler: NodeHandler,
<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler: Send,
<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler: 'static,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::OutboundOpenInfo: Send,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::OutboundOpenInfo: 'static,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::Substream == SubstreamRef<Arc<TMuxer>>,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::InEvent == TInEvent,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::OutEvent == TOutEvent,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::Error == THandlerErr,
pub fn new(
transport: TTrans,
local_peer_id: TPeerId,
executor: Option<Box<dyn Executor + 'static + Send>>
) -> Network<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId>
[src]
transport: TTrans,
local_peer_id: TPeerId,
executor: Option<Box<dyn Executor + 'static + Send>>
) -> Network<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId>
Creates a new node events stream.
pub fn new_with_incoming_limit(
transport: TTrans,
local_peer_id: TPeerId,
executor: Option<Box<dyn Executor + 'static + Send>>,
incoming_limit: Option<u32>
) -> Network<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId>
[src]
transport: TTrans,
local_peer_id: TPeerId,
executor: Option<Box<dyn Executor + 'static + Send>>,
incoming_limit: Option<u32>
) -> Network<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId>
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<ListenerId, TransportError<<TTrans as Transport>::Error>>
[src]
&mut self,
addr: Multiaddr
) -> Result<ListenerId, TransportError<<TTrans as Transport>::Error>>
Start listening on the given multiaddress.
pub fn remove_listener(&mut self, id: ListenerId) -> Result<(), ()>
[src]
Remove a previously added listener.
Returns Ok(())
if a listener with this ID was in the list.
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 address_translation<'a>(
&'a self,
observed_addr: &'a Multiaddr
) -> impl Iterator<Item = Multiaddr> + 'a where
THandler: 'a,
TMuxer: 'a,
[src]
&'a self,
observed_addr: &'a Multiaddr
) -> impl Iterator<Item = Multiaddr> + 'a where
THandler: 'a,
TMuxer: 'a,
Call this function in order to know which address remotes should dial to access your local node.
When receiving an observed address on a tcp connection that we initiated, the observed address contains our tcp dial port, not our tcp listen port. We know which port we are listening on, thereby we can replace the port within the observed address.
When receiving an observed address on a tcp connection that we did not initiated, the observed address should contain our listening port. In case it differs from our listening port there might be a proxy along the path.
Arguments
observed_addr
- should be an address a remote observes you as, which can be obtained for example with the identify protocol.
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 as Transport>::Error>> where
TConnInfo: Send + 'static,
TInEvent: Send + 'static,
TMuxer: Send + Sync + 'static,
TOutEvent: Send + 'static,
TPeerId: Send + 'static,
TTrans: Transport<Output = (TConnInfo, TMuxer)>,
<TTrans as Transport>::Error: Send,
<TTrans as Transport>::Error: 'static,
<TTrans as Transport>::Dial: Send,
<TTrans as Transport>::Dial: 'static,
<TMuxer as StreamMuxer>::OutboundSubstream: Send,
[src]
&mut self,
addr: Multiaddr,
handler: THandler
) -> Result<(), TransportError<<TTrans as Transport>::Error>> where
TConnInfo: Send + 'static,
TInEvent: Send + 'static,
TMuxer: Send + Sync + 'static,
TOutEvent: Send + 'static,
TPeerId: Send + 'static,
TTrans: Transport<Output = (TConnInfo, TMuxer)>,
<TTrans as Transport>::Error: Send,
<TTrans as Transport>::Error: 'static,
<TTrans as Transport>::Dial: Send,
<TTrans as Transport>::Dial: 'static,
<TMuxer as StreamMuxer>::OutboundSubstream: Send,
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]
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.
#[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 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]
&mut self,
peer_id: TPeerId
) -> Peer<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId>
Grants access to a struct that represents a peer.
pub fn poll(
&'a mut self,
cx: &mut Context
) -> Poll<NetworkEvent<'a, TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId>> where
TConnInfo: Clone,
THandler: IntoNodeHandler<(TConnInfo, ConnectedPoint)> + Send + 'static,
THandlerErr: Error + Send + 'static,
TInEvent: Send + 'static,
TMuxer: Send + Sync + 'static,
TOutEvent: Send + 'static,
TPeerId: AsRef<[u8]> + Send + 'static,
TTrans: Transport<Output = (TConnInfo, TMuxer)>,
<TTrans as Transport>::Error: Send,
<TTrans as Transport>::Error: 'static,
<TTrans as Transport>::Dial: Send,
<TTrans as Transport>::Dial: 'static,
<TTrans as Transport>::ListenerUpgrade: Send,
<TTrans as Transport>::ListenerUpgrade: 'static,
<TMuxer as StreamMuxer>::OutboundSubstream: Send,
<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler: NodeHandler,
<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler: Send,
<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler: 'static,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::Substream == SubstreamRef<Arc<TMuxer>>,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::InEvent == TInEvent,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::OutEvent == TOutEvent,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::Error == THandlerErr,
[src]
&'a mut self,
cx: &mut Context
) -> Poll<NetworkEvent<'a, TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId>> where
TConnInfo: Clone,
THandler: IntoNodeHandler<(TConnInfo, ConnectedPoint)> + Send + 'static,
THandlerErr: Error + Send + 'static,
TInEvent: Send + 'static,
TMuxer: Send + Sync + 'static,
TOutEvent: Send + 'static,
TPeerId: AsRef<[u8]> + Send + 'static,
TTrans: Transport<Output = (TConnInfo, TMuxer)>,
<TTrans as Transport>::Error: Send,
<TTrans as Transport>::Error: 'static,
<TTrans as Transport>::Dial: Send,
<TTrans as Transport>::Dial: 'static,
<TTrans as Transport>::ListenerUpgrade: Send,
<TTrans as Transport>::ListenerUpgrade: 'static,
<TMuxer as StreamMuxer>::OutboundSubstream: Send,
<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler: NodeHandler,
<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler: Send,
<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler: 'static,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::Substream == SubstreamRef<Arc<TMuxer>>,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::InEvent == TInEvent,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::OutEvent == TOutEvent,
<<THandler as IntoNodeHandler<(TConnInfo, ConnectedPoint)>>::Handler as NodeHandler>::Error == THandlerErr,
Provides an API similar to Stream
, except that it cannot error.
Trait Implementations
impl<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId> Debug for Network<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId> where
TConnInfo: Debug,
TPeerId: Debug + Eq + Hash,
TTrans: Debug + Transport,
[src]
TConnInfo: Debug,
TPeerId: Debug + Eq + Hash,
TTrans: Debug + Transport,
impl<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId> Unpin for Network<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId> where
TTrans: Transport,
[src]
TTrans: Transport,
Auto Trait Implementations
impl<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo = PeerId, TPeerId = PeerId> !RefUnwindSafe for Network<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId>
impl<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId> Send for Network<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,
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 Network<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo, TPeerId>
impl<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo = PeerId, TPeerId = PeerId> !UnwindSafe for Network<TTrans, TInEvent, TOutEvent, THandler, THandlerErr, 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>,