coordinode-lsm-tree 5.2.0

Embedded LSM-tree storage engine: BuRR filters, zstd dictionary compression, MVCC, range tombstones, merge operators, K/V separation, AES-256-GCM at rest.
Documentation
// Copyright (c) 2025-present, fjall-rs
// This source code is licensed under both the Apache 2.0 and MIT License
// (found in the LICENSE-* files in the repository)

use crate::sfa::checksum::Checksum;

/// Error type
#[derive(Debug)]
pub enum Error {
    /// IO error
    Io(std::io::Error),

    /// Invalid header
    InvalidHeader,

    /// Unsupported file format version
    InvalidVersion,

    /// Unsupported checksum type
    UnsupportedChecksumType,

    /// Checksum mismatch
    ChecksumMismatch {
        /// The calculated checksum
        got: Checksum,

        /// The expected checksum as defined in the file format
        expected: Checksum,
    },
}

impl std::fmt::Display for Error {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "SfaError: {self:?}")
    }
}

impl From<std::io::Error> for Error {
    fn from(inner: std::io::Error) -> Self {
        Self::Io(inner)
    }
}

impl std::error::Error for Error {
    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
        match self {
            Self::Io(inner) => Some(inner),
            _ => None,
        }
    }
}