openrtc 2.8.8

OpenRTC: a Rust-first P2P runtime for device discovery, signaling, and iroh/QUIC networking.
Documentation
//! Minimal native ticket mesh surface. The caller supplies an initialized,
//! shared OpenRTC Client and keeps it alive for the handle's lifetime.

use std::sync::Arc;

use openrtc::{Client, TicketMesh, TicketMeshOptions};

async fn issue(client: Arc<Client>, share_id: &str) -> anyhow::Result<String> {
    let mesh = TicketMesh::issue(client, share_id, TicketMeshOptions { max_peers: 8 }).await?;
    let invite = mesh.invite();
    let mut peers = mesh.watch_peers();
    let _connected = peers.borrow_and_update().clone();
    mesh.close().await;
    Ok(invite)
}

async fn join(client: Arc<Client>, invite: &str) -> anyhow::Result<()> {
    let mesh = TicketMesh::join(client, invite).await?;
    let mut peers = mesh.watch_peers();
    let _connected = peers.borrow_and_update().clone();
    mesh.close().await;
    Ok(())
}

fn main() {
    let _ = (issue, join);
}