[−][src]Struct libp2prs_swarm::Control
The Swarm
controller.
While a Yamux connection makes progress via its next_stream
method,
this controller can be used to concurrently direct the connection,
e.g. to open a new stream to the remote or to close the connection.
Implementations
impl Control
[src]
pub fn peer_in_iter(&self) -> IntoIter<PeerId, usize>
[src]
Return an iterator that contains all input bytes group by peer.
pub fn peer_out_iter(&self) -> IntoIter<PeerId, usize>
[src]
Return an iterator that contains all output bytes group by peer.
pub fn protocol_in_iter(&self) -> IntoIter<String, usize>
[src]
Return an iterator that contains all input bytes group by protocol.
pub fn protocol_out_iter(&self) -> IntoIter<String, usize>
[src]
Return an iterator that contains all output bytes group by protocol.
pub fn get_peers(&self) -> Vec<PeerId>
[src]
Get all peers in the AddrBook of Peerstore.
pub fn get_recv_count_and_size(&self) -> (usize, usize)
[src]
Get recv package count&bytes
pub fn get_sent_count_and_size(&self) -> (usize, usize)
[src]
Get send package count&bytes
pub fn get_protocol_in_and_out(
&self,
protocol_id: &str
) -> (Option<usize>, Option<usize>)
[src]
&self,
protocol_id: &str
) -> (Option<usize>, Option<usize>)
Get recv&send bytes by protocol_id
pub fn get_peer_in_and_out(
&self,
peer_id: &PeerId
) -> (Option<usize>, Option<usize>)
[src]
&self,
peer_id: &PeerId
) -> (Option<usize>, Option<usize>)
Get recv&send bytes by peer_id
pub async fn connect_with_addrs(
&mut self,
peer_id: PeerId,
addrs: Vec<Multiaddr>
) -> Result<(), SwarmError>
[src]
&mut self,
peer_id: PeerId,
addrs: Vec<Multiaddr>
) -> Result<(), SwarmError>
Make a new connection towards the remote peer with addresses specified.
pub async fn new_connection(
&mut self,
peer_id: PeerId
) -> Result<(), SwarmError>
[src]
&mut self,
peer_id: PeerId
) -> Result<(), SwarmError>
Make a new connection towards the remote peer.
It will lookup the peer store for address of the peer, otherwise initiate the routing interface for querying the addresses, if routing is available.
pub async fn new_connection_no_routing(
&mut self,
peer_id: PeerId
) -> Result<(), SwarmError>
[src]
&mut self,
peer_id: PeerId
) -> Result<(), SwarmError>
Make a new connection towards the remote peer, without using routing(Kad-DHT).
pub async fn disconnect(&mut self, peer_id: PeerId) -> Result<(), SwarmError>
[src]
Close connection towards the remote peer.
pub async fn new_stream(
&mut self,
peer_id: PeerId,
pids: Vec<ProtocolId>
) -> Result<Substream, SwarmError>
[src]
&mut self,
peer_id: PeerId,
pids: Vec<ProtocolId>
) -> Result<Substream, SwarmError>
Open a new outbound stream towards the remote peer.
It will lookup the peer store for address of the peer, otherwise initiate the routing interface for address querying, when routing is enabled. In the end, it will open an outgoing sub-stream when the connection is eventually established.
pub async fn new_stream_no_routing(
&mut self,
peer_id: PeerId,
pids: Vec<ProtocolId>
) -> Result<Substream, SwarmError>
[src]
&mut self,
peer_id: PeerId,
pids: Vec<ProtocolId>
) -> Result<Substream, SwarmError>
Open a new outbound stream towards the remote peer, without routing.
pub async fn self_addrs(&mut self) -> Result<Vec<Multiaddr>, SwarmError>
[src]
Retrieve the all listened addresses from Swarm.
All listened addresses on interface and the observed addresses from Identify protocol.
pub async fn retrieve_networkinfo(&mut self) -> Result<NetworkInfo, SwarmError>
[src]
Retrieve network information from Swarm.
pub async fn retrieve_identify_info(
&mut self
) -> Result<IdentifyInfo, SwarmError>
[src]
&mut self
) -> Result<IdentifyInfo, SwarmError>
Retrieve identify information from Swarm.
pub async fn dump_connections(
&mut self,
peer_id: Option<PeerId>
) -> Result<Vec<ConnectionView>, SwarmError>
[src]
&mut self,
peer_id: Option<PeerId>
) -> Result<Vec<ConnectionView>, SwarmError>
pub async fn dump_streams(
&mut self,
peer_id: PeerId
) -> Result<Vec<SubstreamView>, SwarmError>
[src]
&mut self,
peer_id: PeerId
) -> Result<Vec<SubstreamView>, SwarmError>
pub async fn close(&mut self)
[src]
Close the swarm.
pub fn pin(&self, peer_id: &PeerId)
[src]
Pins the peer Id so that GC wouldn't recycle the multiaddr of the peer.
pub fn unpin(&self, peer_id: &PeerId)
[src]
Unpins the peer Id.
pub fn pinned(&self, peer_id: &PeerId) -> bool
[src]
Checks if the peer is currently being pinned in peer store.
pub fn get_key(&self, peer_id: &PeerId) -> Option<PublicKey>
[src]
Gets the public key by peer_id.
pub fn get_addrs(&self, peer_id: &PeerId) -> Option<Vec<Multiaddr>>
[src]
Gets all multiaddr of a peer.
pub fn add_addr(&self, peer_id: &PeerId, addr: Multiaddr, ttl: Duration)
[src]
Adds a address to address_book by peer_id, if exists, update rtt.
pub fn add_addrs(&self, peer_id: &PeerId, addrs: Vec<Multiaddr>, ttl: Duration)
[src]
Adds many new addresses if they're not already in the peer store.
pub fn clear_addrs(&self, peer_id: &PeerId)
[src]
Clears all multiaddr of a peer from the peer store.
pub fn update_addr(&self, peer_id: &PeerId, new_ttl: Duration)
[src]
Updates ttl.
pub fn add_protocols(&self, peer_id: &PeerId, protos: Vec<String>)
[src]
Adds the protocols by peer_id.
pub fn clear_protocols(&self, peer_id: &PeerId)
[src]
Removes the protocols by peer_id.
pub fn get_protocols(&self, peer_id: &PeerId) -> Option<Vec<String>>
[src]
Gets the protocols supported by the specified PeerId.
pub fn first_supported_protocol(
&self,
peer_id: &PeerId,
protos: Vec<String>
) -> Option<String>
[src]
&self,
peer_id: &PeerId,
protos: Vec<String>
) -> Option<String>
Tests if the PeerId supports the given protocols.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Control
[src]
impl Send for Control
[src]
impl Sync for Control
[src]
impl Unpin for Control
[src]
impl !UnwindSafe for Control
[src]
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,
pub 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> Pointable for T
[src]
pub const ALIGN: usize
[src]
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
[src]
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
[src]
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
[src]
pub unsafe fn drop(ptr: usize)
[src]
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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.
pub 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.
pub 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>,