Module node

Module node 

Source
Expand description

Zero-configuration P2P node - THE PRIMARY API

Use Node for the simplest possible P2P experience:

let node = Node::new().await?;

Zero-configuration P2P node

This module provides Node - the simple API for creating P2P nodes that work out of the box with zero configuration. Every node automatically:

  • Uses 100% post-quantum cryptography (ML-KEM-768)
  • Works behind any NAT via native QUIC hole punching
  • Can act as coordinator/relay if environment allows
  • Exposes complete observability via NodeStatus

§Zero Configuration

use ant_quic::Node;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Create a node - that's it!
    let node = Node::new().await?;

    println!("I am: {:?}", node.peer_id());
    println!("Listening on: {:?}", node.local_addr());

    // Check status
    let status = node.status().await;
    println!("NAT type: {}", status.nat_type);
    println!("Can receive direct: {}", status.can_receive_direct);
    println!("Acting as relay: {}", status.is_relaying);

    // Connect to a peer
    let conn = node.connect_addr("quic.saorsalabs.com:9000".parse()?).await?;

    // Accept connections
    let incoming = node.accept().await;

    Ok(())
}

Structs§

Node
Zero-configuration P2P node

Enums§

NodeError
Error type for Node operations