pub struct P2pLinkTransport { /* private fields */ }Expand description
A LinkTransport implementation wrapping P2pEndpoint.
This provides a stable abstraction layer for overlay networks to use, decoupling them from specific ant-quic versions.
Implementations§
Source§impl P2pLinkTransport
impl P2pLinkTransport
Sourcepub async fn new(config: P2pConfig) -> Result<Self, EndpointError>
pub async fn new(config: P2pConfig) -> Result<Self, EndpointError>
Create a new LinkTransport from a P2pConfig.
Sourcepub fn from_endpoint(endpoint: Arc<P2pEndpoint>) -> Self
pub fn from_endpoint(endpoint: Arc<P2pEndpoint>) -> Self
Create from an existing P2pEndpoint.
Sourcepub fn endpoint(&self) -> &P2pEndpoint
pub fn endpoint(&self) -> &P2pEndpoint
Get the underlying P2pEndpoint.
Trait Implementations§
Source§impl LinkTransport for P2pLinkTransport
impl LinkTransport for P2pLinkTransport
Source§type Conn = P2pLinkConn
type Conn = P2pLinkConn
The connection type returned by this transport.
Source§fn local_peer(&self) -> PeerId
fn local_peer(&self) -> PeerId
Get our local peer ID.
Source§fn external_address(&self) -> Option<SocketAddr>
fn external_address(&self) -> Option<SocketAddr>
Get our observed external address (if known).
Source§fn peer_table(&self) -> Vec<(PeerId, Capabilities)>
fn peer_table(&self) -> Vec<(PeerId, Capabilities)>
Get the current peer table with capabilities. Read more
Source§fn peer_capabilities(&self, peer: &PeerId) -> Option<Capabilities>
fn peer_capabilities(&self, peer: &PeerId) -> Option<Capabilities>
Get capabilities for a specific peer.
Source§fn accept(&self, _proto: ProtocolId) -> Incoming<Self::Conn>
fn accept(&self, _proto: ProtocolId) -> Incoming<Self::Conn>
Accept incoming connections for a specific protocol.
Source§fn dial(
&self,
peer: PeerId,
_proto: ProtocolId,
) -> BoxFuture<'_, LinkResult<Self::Conn>>
fn dial( &self, peer: PeerId, _proto: ProtocolId, ) -> BoxFuture<'_, LinkResult<Self::Conn>>
Dial a peer to establish a connection. Read more
Source§fn dial_addr(
&self,
addr: SocketAddr,
_proto: ProtocolId,
) -> BoxFuture<'_, LinkResult<Self::Conn>>
fn dial_addr( &self, addr: SocketAddr, _proto: ProtocolId, ) -> BoxFuture<'_, LinkResult<Self::Conn>>
Dial a peer by address (for bootstrap).
Source§fn supported_protocols(&self) -> Vec<ProtocolId>
fn supported_protocols(&self) -> Vec<ProtocolId>
Get the list of protocols we support.
Source§fn register_protocol(&self, proto: ProtocolId)
fn register_protocol(&self, proto: ProtocolId)
Register a protocol as supported.
Source§fn unregister_protocol(&self, proto: ProtocolId)
fn unregister_protocol(&self, proto: ProtocolId)
Unregister a protocol.
Source§fn is_connected(&self, peer: &PeerId) -> bool
fn is_connected(&self, peer: &PeerId) -> bool
Check if we’re connected to a peer.
Source§fn active_connections(&self) -> usize
fn active_connections(&self) -> usize
Get the number of active connections.
Auto Trait Implementations§
impl Freeze for P2pLinkTransport
impl !RefUnwindSafe for P2pLinkTransport
impl Send for P2pLinkTransport
impl Sync for P2pLinkTransport
impl Unpin for P2pLinkTransport
impl !UnwindSafe for P2pLinkTransport
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more