erebyx-sdk 0.1.1

Rust SDK for EREBYX — persistent AI memory across every AI you use. Encrypted in transit (TLS 1.3) and at rest with envelope encryption (server-held master KEK at v0.1.1); per-user zero-knowledge encryption in v0.2.
Documentation
// SPDX-License-Identifier: MIT OR Apache-2.0
//! Error types for the EREBYX SDK.

use thiserror::Error;

#[derive(Error, Debug)]
pub enum Error {
    #[error("Authentication failed: {0}")]
    AuthenticationFailed(String),

    #[error("Rate limited — retry after {retry_after_secs}s")]
    RateLimit { retry_after_secs: u64 },

    #[error("Memory not found: {0}")]
    NotFound(String),

    #[error("Validation error: {0}")]
    Validation(String),

    #[error("Server error: {status} {message}")]
    Server { status: u16, message: String },

    #[error("Network error: {0}")]
    Network(#[from] reqwest::Error),

    #[error("Serialization error: {0}")]
    Serialization(#[from] serde_json::Error),

    #[error("Configuration error: {0}")]
    Config(String),

    #[error("Circuit open — memory service unavailable, will retry in {cooldown_secs}s")]
    CircuitOpen { cooldown_secs: u64 },
}

impl Error {
    /// Whether this error is transient and the operation should be retried.
    pub fn is_transient(&self) -> bool {
        matches!(
            self,
            Error::RateLimit { .. }
                | Error::Network(_)
                | Error::Server {
                    status: 500..=599,
                    ..
                }
        )
    }

    /// Whether this error should be swallowed (fail-open) by an LLM wrapper.
    ///
    /// Transient infrastructure failures (rate limits, network blips, 5xx
    /// responses, open circuit breaker, malformed-server-JSON) should not
    /// break a chat turn — the model can answer without memory and try
    /// again next call. Caller-side errors (auth, validation, config,
    /// missing resource) are NOT swallowable — the caller must fix them,
    /// retrying won't help.
    pub fn is_swallowable(&self) -> bool {
        matches!(
            self,
            Error::RateLimit { .. }
                | Error::Network(_)
                | Error::Server {
                    status: 500..=599,
                    ..
                }
                | Error::CircuitOpen { .. }
                | Error::Serialization(_)
        )
    }
}