zlayer-store 0.14.1

Centralized domain DB access for ZLayer — generic SQLite JSON adapter and shared storage error type.
Documentation
//! Shared storage error type.
//!
//! `StorageError` is the error returned by every `ZLayer` storage operation.
//! It was moved here verbatim from `zlayer-api::storage::deployments` so that
//! the generic adapter ([`crate::JsonStore`]) and every domain store can
//! share a single error type without depending on `zlayer-api`.

use thiserror::Error;

/// Storage errors
#[derive(Debug, Error)]
pub enum StorageError {
    /// Database error
    #[error("Database error: {0}")]
    Database(String),

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

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

    /// Row already exists (unique constraint violation)
    #[error("Already exists: {0}")]
    AlreadyExists(String),

    /// Other / miscellaneous error (e.g. unknown column, invalid argument)
    #[error("Storage error: {0}")]
    Other(String),

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

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

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