anubis-wormhole 1.0.0

A post-quantum secure file transfer tool based on the Magic Wormhole protocol.
Documentation
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum ClientMsg {
    Bind { appid: String, side: String },
    Allocate { },
    Claim { nameplate: String },
    Open { mailbox: String },
    Add { phase: String, body: String }, // hex or base64 body
    Ping,
    Release { nameplate: String },
    Close,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum ServerMsg {
    Welcome { motd: Option<String>, current_cli_version: Option<String>, error: Option<String> },
    NameplateAllocated { nameplate: String },
    Claimed { mailbox: String },
    Message { side: String, phase: String, body: String },
    Nameplates { ids: Vec<String> },
    Pong,
    Error { error: String },
    Released {},
    Closed {},
}

pub fn random_side() -> String {
    // 5-byte hex side, compatible length
    let mut b = [0u8; 5];
    getrandom::getrandom(&mut b).ok();
    b.iter().map(|v| format!("{:02x}", v)).collect()
}