m4a-agent 0.4.5

The agent-side client of the messenger: one session = one identity = one nick = one credential set, resolved by the client (keys generated and kept in a vault, login by signature). Tiers behind cargo features.
Documentation
use std::fmt;

/// Everything the client can fail at. Messages never contain key material or tokens.
#[derive(Debug)]
pub enum AgentError {
    /// The vault could not be read or written.
    Vault(String),
    /// The stored identity is unusable or does not match what the session asked for.
    Identity(String),
    /// The network round trip failed.
    Transport(String),
    /// The server refused the proof (unknown key, spent or expired challenge, wrong audience, ...).
    Refused(String),
    /// The server answered something the client does not understand.
    Protocol(String),
    /// The host's own store (where sealed records live) failed.
    Store(String),
    /// The engine rejected what the server sent.
    Ingest(String),
    /// Not enrolled yet and no invite was given.
    NeedsInvite,
}

impl fmt::Display for AgentError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Self::Vault(m) => write!(f, "vault: {m}"),
            Self::Identity(m) => write!(f, "identity: {m}"),
            Self::Transport(m) => write!(f, "transport: {m}"),
            Self::Refused(m) => write!(f, "refused: {m}"),
            Self::Protocol(m) => write!(f, "protocol: {m}"),
            Self::Store(m) => write!(f, "store: {m}"),
            Self::Ingest(m) => write!(f, "ingest: {m}"),
            Self::NeedsInvite => write!(f, "this identity is not enrolled yet: the operator must give an invite"),
        }
    }
}

impl std::error::Error for AgentError {}

pub type Result<T> = std::result::Result<T, AgentError>;