trellis-rs 0.10.4

Curated public Rust facade for Trellis clients and services.
Documentation
use std::io;

/// Errors returned by Trellis auth and admin-session helpers.
#[derive(Debug, thiserror::Error)]
pub enum TrellisAuthError {
    /// The supplied contract JSON could not be parsed.
    #[error("invalid contract json: {0}")]
    ContractJson(#[from] serde_json::Error),

    /// Contract digest calculation failed.
    #[error("contract digest error: {0}")]
    ContractDigest(#[from] trellis_contracts::ContractsError),

    /// A configured auth or portal URL was invalid.
    #[error("invalid url: {0}")]
    Url(#[from] url::ParseError),

    /// The HTTP transport used for agent login or bind requests failed.
    #[error("http client error: {0}")]
    Http(#[from] reqwest::Error),

    /// Local filesystem persistence or socket I/O failed.
    #[error("io error: {0}")]
    Io(#[from] io::Error),

    /// The underlying Trellis RPC client returned an error.
    #[error("{0}")]
    TrellisClient(#[from] crate::client::TrellisClientError),

    /// Agent login never completed before the timeout.
    #[error("timed out waiting for agent login")]
    LoginTimedOut,

    /// The detached login flow shut down before completion.
    #[error("agent login was interrupted")]
    LoginInterrupted,

    /// The auth service returned a terminal flow error.
    #[error("auth flow failed: {0}")]
    AuthFlowFailed(String),

    /// The low-level bind endpoint returned a non-success HTTP response.
    #[error("bind failed: {0} {1}")]
    BindHttpFailure(u16, String),

    /// The auth-start endpoint returned a non-success HTTP response.
    #[error("auth request failed: {0} {1}")]
    AuthRequestHttpFailure(u16, String),

    /// The bind endpoint returned a response shape this crate does not understand.
    #[error("unexpected bind status: {0}")]
    UnexpectedBindStatus(String),

    /// The auth-start endpoint returned a response shape this crate does not understand.
    #[error("unexpected auth request status: {0}")]
    UnexpectedAuthRequestStatus(String),

    /// The caller supplied arguments that violate the Trellis auth invariants.
    #[error("invalid argument: {0}")]
    InvalidArgument(String),

    /// A helper wrapped operation finished without a usable successful result.
    #[error("operation failed: {0}")]
    OperationFailed(String),

    /// A device activation wait request returned a non-success HTTP response.
    #[error("device activation wait failed: {0} {1}")]
    DeviceActivationWaitFailure(u16, String),

    /// A device activation start request returned a non-success HTTP response.
    #[error("device activation start failed: {0} {1}")]
    DeviceActivationStartFailure(u16, String),

    /// A device connect-info request returned a non-success HTTP response.
    #[error("device connect info failed: {0} {1}")]
    DeviceConnectInfoFailure(u16, String),

    /// A device connect-info request returned a response status this crate cannot use.
    #[error("unexpected device connect info status: {0}")]
    UnexpectedDeviceConnectInfoStatus(String),

    /// Device activation was explicitly rejected.
    #[error("device activation rejected{0}")]
    DeviceActivationRejected(String),

    /// The authenticated user completed login successfully but lacks admin capability.
    #[error("logged in user is not an admin")]
    NotAdmin,

    /// The current session belongs to a non-user participant.
    #[error("current session is not a user session: participantKind={0}")]
    NotUserSession(String),
}