pub struct Po { /* private fields */ }Expand description
A PO node — the main entry point for the protocol.
Wraps all the complexity of QUIC, crypto handshake, and encryption behind a dead-simple API.
Implementations§
Source§impl Po
impl Po
Sourcepub async fn connect(addr: &str) -> Result<Self, PoError>
pub async fn connect(addr: &str) -> Result<Self, PoError>
Connect to a remote PO node.
This will:
- Establish a QUIC connection
- Perform the E2EE handshake (Ed25519 + X25519 + ChaCha20)
- Return a ready-to-use encrypted connection
ⓘ
let mut po = Po::connect("192.168.1.5:4433").await?;
po.send(b"encrypted hello!").await?;Sourcepub async fn bind(port: u16) -> Result<Self, PoError>
pub async fn bind(port: u16) -> Result<Self, PoError>
Listen for an incoming connection on the given port.
This will:
- Start a QUIC listener
- Accept the first incoming connection
- Perform the E2EE handshake
- Return a ready-to-use encrypted connection
ⓘ
let mut po = Po::bind(4433).await?;
let data = po.recv().await?;Sourcepub async fn send(&mut self, data: &[u8]) -> Result<(), PoError>
pub async fn send(&mut self, data: &[u8]) -> Result<(), PoError>
Send encrypted data to the connected peer.
Sourcepub async fn recv(&mut self) -> Result<Option<(u32, Vec<u8>)>, PoError>
pub async fn recv(&mut self) -> Result<Option<(u32, Vec<u8>)>, PoError>
Receive the next message from the connected peer.
Returns Some((channel_id, data)) or None if the connection closed.
Sourcepub fn public_key(&self) -> [u8; 32]
pub fn public_key(&self) -> [u8; 32]
Get our Ed25519 public key bytes (32 bytes).
Sourcepub fn peer_node_id(&self) -> Option<String>
pub fn peer_node_id(&self) -> Option<String>
Get the peer’s node ID (if connected).
Auto Trait Implementations§
impl Freeze for Po
impl RefUnwindSafe for Po
impl Send for Po
impl Sync for Po
impl Unpin for Po
impl UnsafeUnpin for Po
impl UnwindSafe for Po
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