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 + Send + Sync>>
pub async fn new( config: QuicNodeConfig, ) -> Result<Self, Box<dyn Error + Send + Sync>>
Create a new QUIC P2P node
Sourcepub fn get_config(&self) -> &QuicNodeConfig
pub fn get_config(&self) -> &QuicNodeConfig
Get the node configuration
Sourcepub async fn connect_to_bootstrap(
&self,
bootstrap_addr: SocketAddr,
) -> Result<PeerId, NatTraversalError>
pub async fn connect_to_bootstrap( &self, bootstrap_addr: SocketAddr, ) -> Result<PeerId, NatTraversalError>
Connect directly to a bootstrap 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 + Send + Sync>>
pub async fn accept( &self, ) -> Result<(SocketAddr, PeerId), Box<dyn Error + Send + Sync>>
Accept incoming connections
Sourcepub async fn send_to_peer(
&self,
peer_id: &PeerId,
data: &[u8],
) -> Result<(), Box<dyn Error + Send + Sync>>
pub async fn send_to_peer( &self, peer_id: &PeerId, data: &[u8], ) -> Result<(), Box<dyn Error + Send + Sync>>
Send data to a peer
Sourcepub async fn receive(
&self,
) -> Result<(PeerId, Vec<u8>), Box<dyn Error + Send + Sync>>
pub async fn receive( &self, ) -> Result<(PeerId, Vec<u8>), Box<dyn Error + Send + Sync>>
Receive data from peers
Sourcepub fn get_nat_endpoint(
&self,
) -> Result<&NatTraversalEndpoint, Box<dyn Error + Send + Sync>>
pub fn get_nat_endpoint( &self, ) -> Result<&NatTraversalEndpoint, Box<dyn Error + Send + Sync>>
Get access to the NAT traversal endpoint
Sourcepub fn start_stats_task(&self) -> JoinHandle<()>
pub fn start_stats_task(&self) -> JoinHandle<()>
Start periodic statistics reporting
Sourcepub async fn get_nat_stats(
&self,
) -> Result<NatTraversalStatistics, Box<dyn Error + Send + Sync>>
pub async fn get_nat_stats( &self, ) -> Result<NatTraversalStatistics, Box<dyn Error + Send + Sync>>
Get NAT traversal statistics
Sourcepub async fn get_connection_metrics(
&self,
peer_id: &PeerId,
) -> Result<ConnectionMetrics, Box<dyn Error + Send + Sync>>
pub async fn get_connection_metrics( &self, peer_id: &PeerId, ) -> Result<ConnectionMetrics, Box<dyn Error + Send + Sync>>
Get connection metrics for a specific peer
Sourcepub fn public_key_bytes(&self) -> [u8; 32]
pub fn public_key_bytes(&self) -> [u8; 32]
Get this node’s public key bytes
Sourcepub async fn is_peer_authenticated(&self, peer_id: &PeerId) -> bool
pub async fn is_peer_authenticated(&self, peer_id: &PeerId) -> bool
Check if a peer is authenticated
Sourcepub async fn list_authenticated_peers(&self) -> Vec<PeerId>
pub async fn list_authenticated_peers(&self) -> Vec<PeerId>
Get list of authenticated peers
Sourcepub fn get_metrics_collector(
&self,
) -> Result<Arc<MetricsCollector>, &'static str>
pub fn get_metrics_collector( &self, ) -> Result<Arc<MetricsCollector>, &'static str>
Get the metrics collector for Prometheus export
Trait Implementations§
Source§impl Clone for QuicP2PNode
impl Clone for QuicP2PNode
Source§fn clone(&self) -> QuicP2PNode
fn clone(&self) -> QuicP2PNode
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto 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