Skip to main content

KvStorage

Struct KvStorage 

Source
pub struct KvStorage<B, T, C = JsonCodec>
where B: StorageBackend + ?Sized, T: Send + Sync + 'static, C: Codec<T>,
{ /* private fields */ }
Expand description

Key-value tier — buffers per-key pending writes; flush() encodes each value via codec and writes it to the backend. Mirrors TS kvStorage.

Trait Implementations§

Source§

impl<B, T, C> BaseStorageTier for KvStorage<B, T, C>
where B: StorageBackend + ?Sized, T: Send + Sync + 'static, C: Codec<T>,

Source§

fn name(&self) -> &str

Diagnostic tier name (e.g. "snapshot:my-graph"). Surfaces in error messages and Display impls.
Source§

fn debounce_ms(&self) -> Option<u32>

Debounce window in milliseconds. None (default) = sync-through. Graph-layer attach reads this and schedules timed flush() via its own reactive timer (M4.E); the tier itself does NOT drive a timer.
Source§

fn compact_every(&self) -> Option<u32>

Force a flush every Nth accepted write regardless of debounce. None = no cap; Some(N) triggers flush() on the Nth save (or append_entries for log tiers).
Source§

fn flush(&self) -> Result<(), StorageError>

Commit pending writes. Graph calls at wave-close / debounce-fire.
Source§

fn rollback(&self) -> Result<(), StorageError>

Discard pending writes. Graph calls on wave-throw.
Source§

fn list_by_prefix_bytes<'a>( &'a self, prefix: &str, ) -> Box<dyn Iterator<Item = Result<(String, Vec<u8>), StorageError>> + 'a>

Lazily enumerate raw (key, bytes) pairs under a literal byte-prefix (DS-14-storage Q5 lock). Read more
Source§

fn compact(&self) -> Result<(), StorageError>

Force a mode:"full" baseline immediately (Q8 lock). Bypasses compact_every cadence; useful at deploy boundaries, end-of-process drains, or test fixtures. Default impl is a flush() so tiers that don’t write baselines can still implement the method trivially.
Source§

impl<B, T, C> KvStorageTier<T> for KvStorage<B, T, C>
where B: StorageBackend + ?Sized, T: Send + Sync + 'static, C: Codec<T>,

Source§

fn save(&self, key: &str, value: T) -> Result<(), StorageError>

Buffer a key→value mapping pending flush. Repeated save(k, _) before flush overwrites the buffered value for that key. Honors compact_every cadence.
Source§

fn load(&self, key: &str) -> Result<Option<T>, StorageError>

Read the value at key. Returns Ok(None) on miss.
Source§

fn delete(&self, key: &str) -> Result<(), StorageError>

Delete the value at key. Flushes through to the backend immediately (matches TS delete semantics — no debounce).
Source§

fn list(&self, prefix: &str) -> Result<Vec<String>, StorageError>

Enumerate keys under prefix (lex-ASC). Delegates to StorageBackend::list via the tier’s backend.

Auto Trait Implementations§

§

impl<B, T, C = JsonCodec> !Freeze for KvStorage<B, T, C>

§

impl<B, T, C = JsonCodec> !RefUnwindSafe for KvStorage<B, T, C>

§

impl<B, T, C> Send for KvStorage<B, T, C>
where B: ?Sized,

§

impl<B, T, C> Sync for KvStorage<B, T, C>
where B: ?Sized,

§

impl<B, T, C> Unpin for KvStorage<B, T, C>
where C: Unpin, T: Unpin, B: ?Sized,

§

impl<B, T, C> UnsafeUnpin for KvStorage<B, T, C>
where C: UnsafeUnpin, B: ?Sized,

§

impl<B, T, C = JsonCodec> !UnwindSafe for KvStorage<B, T, C>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.