Skip to main content

Module node

Module node 

Source
Expand description

High-level PO node — the “ridiculously easy” API.

§Examples

use po_node::Po;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Server: 2 lines
    let mut server = Po::bind(4433).await?;
    let (peer, data) = server.recv().await?.unwrap();
    println!("Got: {}", String::from_utf8_lossy(&data));

    // Client: 3 lines
    let mut client = Po::connect("127.0.0.1:4433").await?;
    client.send(b"Hello!").await?;
    Ok(())
}

Structs§

Po
A PO node — the main entry point for the protocol.

Enums§

PoError
Errors from the PO node.