pub struct GraphStore { /* private fields */ }Expand description
The store. Clone-able (the underlying redb::Database is held by
Arc and is safe to share across threads — redb is internally
concurrent). Construct one per process; pass clones into worker tasks.
Implementations§
Source§impl GraphStore
impl GraphStore
Sourcepub fn open(root: impl Into<PathBuf>) -> Result<Self>
pub fn open(root: impl Into<PathBuf>) -> Result<Self>
Open or create a store at root. Creates the root, blobs
subtree, and redb index on first call. Idempotent.
Sourcepub fn layout(&self) -> &StoreLayout
pub fn layout(&self) -> &StoreLayout
Read-only view of the layout (paths, kinds). Useful for testing and for GC sweeps that walk the filesystem directly.
Sourcepub fn put(&self, kind: GraphKind, hash: GraphHash, bytes: &[u8]) -> Result<()>
pub fn put(&self, kind: GraphKind, hash: GraphHash, bytes: &[u8]) -> Result<()>
Write a blob. Atomic: blob lands on disk + fsyncs before the
index transaction commits. Idempotent on the same (kind, hash, bytes) triple. If the hash doesn’t match the bytes the call
fails with Error::HashMismatch — protects against caller
mistakes upstream.
Sourcepub fn put_unchecked(
&self,
kind: GraphKind,
lookup_hash: GraphHash,
bytes: &[u8],
) -> Result<()>
pub fn put_unchecked( &self, kind: GraphKind, lookup_hash: GraphHash, bytes: &[u8], ) -> Result<()>
Write a blob under a query-derived lookup key (not the
BLAKE3 of the bytes). Skips the content-hash validation that
Self::put enforces.
Use only when the caller has a deterministic mapping from a
non-content query (e.g. an eval-cache (source_hash, lock_hash)
tuple) to a lookup hash, and the stored bytes are themselves
not the BLAKE3 preimage of that hash. The lookup-hash space
shares the same redb table as content-addressed entries, so
callers MUST ensure their query-derived hashes can’t collide
with arbitrary content (the usual trick: domain-separate by
hashing "my-tier::v1::" + serialized_query).
Most callers should prefer Self::put.
Sourcepub fn contains(&self, kind: GraphKind, hash: GraphHash) -> Result<bool>
pub fn contains(&self, kind: GraphKind, hash: GraphHash) -> Result<bool>
Check whether the index knows about (kind, hash). Cheap; does
not touch the filesystem.
Sourcepub fn lookup(&self, kind: GraphKind, hash: GraphHash) -> Result<IndexEntry>
pub fn lookup(&self, kind: GraphKind, hash: GraphHash) -> Result<IndexEntry>
Look up an entry’s bookkeeping without reading the blob. Used by GC and inspection tools.
Sourcepub fn get(&self, kind: GraphKind, hash: GraphHash) -> Result<MappedBlob>
pub fn get(&self, kind: GraphKind, hash: GraphHash) -> Result<MappedBlob>
mmap the blob bytes for (kind, hash). Caller is trusted to
have already verified the hash (e.g. they just computed it). Use
Self::get_validated for substituter-pulled bytes that must
also pass rkyv’s bytecheck pass.
Sourcepub fn get_validated(
&self,
kind: GraphKind,
hash: GraphHash,
) -> Result<MappedBlob>
pub fn get_validated( &self, kind: GraphKind, hash: GraphHash, ) -> Result<MappedBlob>
Same as Self::get but additionally recomputes the BLAKE3 of
the bytes and rejects on mismatch. Pay this cost for any blob
that arrived from an untrusted source (substituter pull,
cross-host fleet transfer).
Sourcepub fn iter_keys(&self) -> Result<Vec<(GraphKind, GraphHash)>>
pub fn iter_keys(&self) -> Result<Vec<(GraphKind, GraphHash)>>
Iterate every (kind, hash) pair in the index. Backed by a
redb read transaction so the snapshot is consistent at call
time. Used by GC and inspection.
Trait Implementations§
Source§impl Clone for GraphStore
impl Clone for GraphStore
Source§fn clone(&self) -> GraphStore
fn clone(&self) -> GraphStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for GraphStore
impl !UnwindSafe for GraphStore
impl Freeze for GraphStore
impl Send for GraphStore
impl Sync for GraphStore
impl Unpin for GraphStore
impl UnsafeUnpin for GraphStore
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.