grammpars 0.1.0

Offline conversion between Telegram Desktop tdata, Telethon, and grammers sessions
Documentation
use thiserror::Error;

/// Core error type for the Grammpars library.
#[derive(Debug, Error)]
pub enum OpenteleError {
    /// A filesystem or stream operation failed.
    #[error("I/O Error: {0}")]
    Io(#[from] std::io::Error),

    /// A Telegram Desktop file failed structural validation.
    #[error("TData structure is invalid: {0}")]
    InvalidTData(String),

    /// Encryption, decryption, or key validation failed.
    #[error("Crypto error: {0}")]
    CryptoError(String),

    /// A Qt-compatible value could not be parsed.
    #[error("Qt stream parsing error: {0}")]
    QtParseError(String),

    /// A SQLite operation failed.
    #[error("SQLite database error: {0}")]
    SqliteError(#[from] rusqlite::Error),

    /// The requested platform or format variant is not supported.
    #[error("Unsupported platform or configuration: {0}")]
    Unsupported(String),

    /// A caller supplied an invalid argument.
    #[error("Invalid argument: {0}")]
    InvalidArgument(String),

    /// An input would exceed a defensive allocation limit.
    #[error("Input exceeds the supported size limit: {actual} bytes (maximum {maximum})")]
    SizeLimit {
        /// Size encountered in the input.
        actual: u64,
        /// Maximum accepted size.
        maximum: u64,
    },
}

/// Result type returned by grammpars operations.
pub type Result<T> = std::result::Result<T, OpenteleError>;