pub struct QuicP2PNode { /* private fields */ }Expand description
QUIC-based P2P node with NAT traversal
Implementations§
Source§impl QuicP2PNode
impl QuicP2PNode
Sourcepub async fn new(config: QuicNodeConfig) -> Result<Self, Box<dyn Error>>
pub async fn new(config: QuicNodeConfig) -> Result<Self, Box<dyn Error>>
Create a new QUIC P2P node
Sourcepub async fn connect_to_peer(
&self,
peer_id: PeerId,
coordinator: SocketAddr,
) -> Result<SocketAddr, NatTraversalError>
pub async fn connect_to_peer( &self, peer_id: PeerId, coordinator: SocketAddr, ) -> Result<SocketAddr, NatTraversalError>
Connect to a peer using NAT traversal
Sourcepub async fn accept(&self) -> Result<(SocketAddr, PeerId), Box<dyn Error>>
pub async fn accept(&self) -> Result<(SocketAddr, PeerId), Box<dyn Error>>
Accept incoming connections
Sourcepub async fn send_to_peer(
&self,
peer_id: &PeerId,
data: &[u8],
) -> Result<(), Box<dyn Error>>
pub async fn send_to_peer( &self, peer_id: &PeerId, data: &[u8], ) -> Result<(), Box<dyn Error>>
Send data to a peer
Sourcepub async fn receive(&self) -> Result<(PeerId, Vec<u8>), Box<dyn Error>>
pub async fn receive(&self) -> Result<(PeerId, Vec<u8>), Box<dyn Error>>
Receive data from peers
Sourcepub fn start_stats_task(&self) -> JoinHandle<()>
pub fn start_stats_task(&self) -> JoinHandle<()>
Start periodic statistics reporting
Auto Trait Implementations§
impl Freeze for QuicP2PNode
impl !RefUnwindSafe for QuicP2PNode
impl Send for QuicP2PNode
impl Sync for QuicP2PNode
impl Unpin for QuicP2PNode
impl !UnwindSafe for QuicP2PNode
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