armdb 0.14.2

sharded bitcask key-value storage optimized for NVMe
Documentation
//! Application-facing outcome type for batch Tree operations (`update_many`).
//! See `docs/superpowers/specs/26-06-24-armdb-batch-tree-ops.md`.
//!
//! The *control* type lives in [`crate::upsert`]: a batch closure returns the
//! same [`Upsert`](crate::Upsert) decision as a single-key `upsert`, so the
//! crate has one write-decision vocabulary rather than two.

/// Renamed to [`Upsert`](crate::Upsert) in 0.8.0, so one decision type covers
/// both `upsert` and `update_many`.
///
/// The `Set` variant is now `Put`; `Keep` and `Delete` are unchanged. The alias
/// keeps signatures naming the type compiling — call sites naming the variant
/// must be updated.
#[deprecated(
    since = "0.8.0",
    note = "renamed to `Upsert`; the `Set` variant is now `Put`"
)]
pub type BatchWrite<T> = crate::upsert::Upsert<T>;

/// What actually happened to one key — a self-sufficient application event
/// channel (`old` + `new` are present here, so duplicating an `on_write` hook is
/// optional).
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Applied<T> {
    /// [`Upsert::Put`](crate::Upsert::Put) was applied. `old = Some(..)` on
    /// overwrite, `None` on insert.
    Written { old: Option<T>, new: T },
    /// `Keep`, or `Delete` against an absent key.
    Kept,
    /// `Delete` against an existing key; carries the removed value.
    Deleted(T),
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::Upsert;

    #[test]
    fn batch_types_construct_and_compare() {
        let w: Upsert<u32> = Upsert::Put(7);
        assert_eq!(w, Upsert::Put(7));
        assert_ne!(w, Upsert::Keep);

        let a: Applied<u32> = Applied::Written { old: None, new: 7 };
        assert_eq!(a, Applied::Written { old: None, new: 7 });
        assert_eq!(Applied::<u32>::Kept, Applied::Kept);
        assert_eq!(Applied::Deleted(3u32), Applied::Deleted(3));
    }

    /// The deprecated alias still resolves to the same type.
    #[test]
    #[allow(deprecated)]
    fn deprecated_alias_is_the_new_type() {
        let w: BatchWrite<u32> = Upsert::Put(7);
        assert_eq!(w, Upsert::Put(7));
    }
}