sos-database 0.17.5

Database backend for the Save Our Secrets SDK
Documentation
use sos_core::{commit::CommitHash, AccountId};
use std::path::PathBuf;
use thiserror::Error;

/// Errors generated creating and importing backup archives,
#[derive(Debug, Error)]
pub enum Error {
    /// Archive file already exists.
    #[error("archive file '{0}' already exists")]
    ArchiveFileExists(PathBuf),

    /// Archive file does not exist.
    #[error("archive file '{0}' does not exist")]
    ArchiveFileNotExists(PathBuf),

    /// Error generated when an archive does not contain a
    /// valid manifest file.
    #[error("archive '{0}' manifest does not exist or is invalid")]
    InvalidArchiveManifest(PathBuf),

    /// Error generated when an archive does not contain the
    /// database file.
    #[error("archive '{0}' is missing the database '{1}'")]
    NoDatabaseFile(PathBuf, String),

    /// Error generated attempting to import an account that
    /// does not exist in the source database.
    #[error(
        "import failed, account '{0}' does not exist in the backup archive"
    )]
    ImportSourceNotExists(AccountId),

    /// Error generated attempting to import an account that
    /// already exists in the target database.
    #[error("import failed, account '{0}' already exists")]
    ImportTargetExists(AccountId),

    /// Error generated when the checksum for a database does not
    /// match the manifest.
    #[error("database checksum is invalid, expected '{0}' but computed '{1}' (archive may be corrupt?)")]
    DatabaseChecksum(CommitHash, CommitHash),

    /// Error generated converting to fixed size slice.
    #[error(transparent)]
    TryFromSlice(#[from] std::array::TryFromSliceError),

    /// Errors generated by the database library.
    #[error(transparent)]
    Database(#[from] crate::Error),

    /// Errors generated by the IO module.
    #[error(transparent)]
    Io(#[from] std::io::Error),

    /// Error generated by the JSON library.
    #[error(transparent)]
    Json(#[from] serde_json::Error),

    /// Error generated by the ZIP archive library.
    #[error(transparent)]
    ZipArchive(#[from] sos_archive::Error),

    /// Errors generated by the async sqlite library.
    #[error(transparent)]
    AsyncSqlite(#[from] async_sqlite::Error),

    /// Errors generated by the rusqlite library.
    #[error(transparent)]
    Rusqlite(#[from] async_sqlite::rusqlite::Error),

    /// Errors generated by refinery migration library.
    #[error(transparent)]
    Refinery(#[from] refinery::Error),

    /// Errors generated by the core library.
    #[error(transparent)]
    Core(#[from] sos_core::Error),

    /// Errors generated by the vault library.
    #[error(transparent)]
    Vault(#[from] sos_vault::Error),
}