armdb 0.11.0

sharded bitcask key-value storage optimized for NVMe
Documentation
//! Shared T10 test fixture (review fix F5, Task 3): a namespace + key + row
//! type, reused by `hook.rs` and `ttl.rs` to prove each `TypedWriteHook` ->
//! `WriteHook` forwarder genuinely delivers a claim end-to-end, not just the
//! `CLAIMS` constant — an adapter that forwards the constant but keeps the
//! trait-default `claim_project` (`Ok(())`, swallowing every claim) passes a
//! constant-only check. Mirrors `counter_tests.rs`'s role for T9's `COUNTS`
//! forwarding, scoped down to what claim forwarding needs (no counter/group
//! fixture here).
//!
//! `pub` rather than `pub(crate)`: `unique_index!` expands to `impl
//! CollectionMeta for $name { type SelfId = $key; }`, and both `CollectionMeta`
//! and the macro's generated struct are `pub` — a `pub(crate)` key type there
//! is `private_interfaces`-denied even though this whole module is
//! `#[cfg(test)]` and not itself `pub`, so nothing here is actually reachable
//! from outside the crate regardless of the items' own visibility.
#![allow(dead_code)]

use std::sync::Arc;

use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};

use crate::armour::Db;
use crate::unique::UniqueIndex;
use crate::{CollectionMeta, FixedConfig, unique_index};

#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromBytes, IntoBytes, Immutable, KnownLayout)]
#[repr(C)]
pub struct ClaimFwdKey([u8; 8]);
crate::impl_key_zerocopy!(
    ClaimFwdKey,
    armour_core::KeyScheme::Typed(&[armour_core::KeyType::Array(8)])
);
impl ClaimFwdKey {
    pub fn new(n: u8) -> Self {
        Self([n; 8])
    }
}

unique_index!(
    ClaimFwdNs,
    key = ClaimFwdKey,
    name = "claim_forwarding_test_ns"
);

#[cfg_attr(feature = "rapira-codec", derive(rapira::Rapira))]
#[derive(
    Clone,
    Copy,
    Debug,
    PartialEq,
    armour_core::GetType,
    FromBytes,
    IntoBytes,
    Immutable,
    KnownLayout,
)]
#[repr(C)]
pub struct ClaimFwdRow(pub u64);

impl CollectionMeta for ClaimFwdRow {
    type SelfId = ClaimFwdKey;
    const NAME: &'static str = "claim_fwd_row";
}

/// Open a fresh namespace collection for one forwarding test. Keeps the
/// backing `Db` and `TempDir` alive alongside the returned handle — this
/// module's own review fix (F7) is that leaking directories is a bug, not a
/// shortcut to copy.
pub fn open_claim_ns() -> (tempfile::TempDir, Arc<Db>, Arc<UniqueIndex<ClaimFwdNs>>) {
    let dir = tempfile::tempdir().expect("tempdir");
    let db = Arc::new(Db::open_test(dir.path()).expect("open db"));
    let ns = db
        .open_unique_index::<ClaimFwdNs>(FixedConfig::test())
        .expect("open namespace");
    (dir, db, ns)
}