object-log 0.4.0

A buffered, multiplexing append log over pluggable object storage, with a sequencing seam (opaque payloads, durable-on-return writes, group-commit).
Documentation
use thiserror::Error;

/// Errors returned by the object-log engine, storage adapters, and sequencer.
#[derive(Debug, Error, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum ObjectLogError {
    /// An object key was empty or contained a `..` path component or `\0`.
    #[error("invalid object key: {0}")]
    InvalidObjectKey(String),
    /// The storage layer was unreachable or returned an I/O error.
    #[error("storage unavailable: {0}")]
    StorageUnavailable(String),
    /// A `get_range` request named a byte range outside the object, or inverted.
    #[error("byte range out of bounds: {0}")]
    RangeOutOfBounds(String),
    /// The index referenced an object that is no longer present in storage.
    #[error("missing object: {0}")]
    MissingObject(String),
    /// A produce batch was malformed (e.g. empty, or below the configured floor).
    #[error("invalid produce batch: {0}")]
    InvalidBatch(String),
    /// The sequencer rejected or failed to process a commit/lookup.
    #[error("sequencer error: {0}")]
    Sequencer(String),

    /// The partition's fence epoch moved past the write's epoch, so the write was
    /// not committed. Retrying at the same epoch cannot succeed.
    ///
    /// Produced by a sequencer's [`rejection_error`](crate::Sequencer::rejection_error)
    /// (for example [`ManifestSequencer`](crate::ManifestSequencer)); the engine
    /// never constructs it.
    #[error(
        "partition {partition} is fenced at epoch {current}; the write at epoch {epoch} was not committed"
    )]
    Fenced {
        /// Partition whose fence rejected the write.
        partition: String,
        /// Epoch the write was produced at.
        epoch: u64,
        /// Fence epoch the partition's index holds.
        current: u64,
    },
    /// A conditional batch was definitely not indexed at its expected log head.
    #[error("conditional log head moved from {expected} to {current}")]
    HeadRejected {
        /// Original required next offset.
        expected: i64,
        /// Authoritative next offset that did not match.
        current: i64,
    },
    /// Durable-ops budget admission failed (`BudgetMode::FailClosed` or timed out).
    #[error("durable-ops budget exceeded: {0}")]
    BudgetExceeded(String),
    /// An authenticated native payload exceeds the caller's read limit.
    #[error("native payload length {actual} exceeds read limit {limit}")]
    ReadLimitExceeded {
        /// Authenticated payload length, before data hydration.
        actual: usize,
        /// Caller-supplied maximum payload length.
        limit: usize,
    },
    /// Invalid engine or budget configuration.
    #[error("invalid configuration: {0}")]
    InvalidConfig(String),
}

impl From<std::io::Error> for ObjectLogError {
    fn from(value: std::io::Error) -> Self {
        Self::StorageUnavailable(value.to_string())
    }
}