rabbitmq-backup-core 0.1.0

Core engine for RabbitMQ backup and restore operations
Documentation
//! Error types for the RabbitMQ backup core library.

use thiserror::Error;

/// Result type alias using the library's Error type.
pub type Result<T> = std::result::Result<T, Error>;

/// Main error type for the RabbitMQ backup library.
#[derive(Error, Debug)]
pub enum Error {
    /// AMQP protocol error
    #[error("AMQP error: {0}")]
    Amqp(String),

    /// Stream protocol error
    #[error("Stream protocol error: {0}")]
    Stream(String),

    /// Management API error
    #[error("Management API error: {0}")]
    ManagementApi(String),

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

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

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

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

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

    /// IO error
    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),

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

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

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

impl From<serde_json::Error> for Error {
    fn from(err: serde_json::Error) -> Self {
        Error::Serialization(err.to_string())
    }
}

impl From<serde_yaml::Error> for Error {
    fn from(err: serde_yaml::Error) -> Self {
        Error::Serialization(err.to_string())
    }
}

impl From<sqlx::Error> for Error {
    fn from(err: sqlx::Error) -> Self {
        Error::Checkpoint(err.to_string())
    }
}