Skip to main content

RedbControlStore

Struct RedbControlStore 

Source
pub struct RedbControlStore { /* private fields */ }
Expand description

The redb-backed ControlStore: one file, three tables.

Cheap to clone; every clone is the same database. redb serialises write transactions internally, so two threads committing at once is a wait and never a lock error — which is why ControlStore::commit_doc has one failure mode (the expectation did not hold) where the reference store had two (that, and somebody else holds the lock).

Implementations§

Source§

impl RedbControlStore

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Open — creating if absent — the control database at path.

Source

pub fn control_db(&self) -> Arc<ControlDb> ⓘ

The handle the runtime growth suspends and resumes. The same Arc the secret store holds.

Source

pub fn in_memory() -> Result<Self>

A control store with no file under it, for tests and for a --dry-run that must not touch the data path.

Source

pub fn secrets(&self) -> RedbSecretStore

The secret store in this same database (2026-08-10).

Handed out from here rather than opened separately, and that is the whole design: redb takes an exclusive file lock, so a second redb::Database over control.redb would fail. One file, one lock, one handle — and the secrets ride the transaction machinery the control plane already has instead of a second durability story beside it.

It is not on ControlStore. That trait is about documents — put_blob / commit_doc / history — and its test decorators (the CAS-ignoring store tests/control_cost.rs proves the retry loop with, and the counting decorator) exist to break exactly those. A secret has none of that shape, so adding it to the trait would make every decorator carry a method it has no opinion about.

Trait Implementations§

Source§

impl Clone for RedbControlStore

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ControlStore for RedbControlStore

Source§

fn put_blob(&self, bytes: &[u8]) -> Result<BlobId>

Store these bytes and return their address. Idempotent: storing the same bytes twice is one row and the same id.
Source§

fn put_blob_unsynced(&self, bytes: &[u8]) -> Result<BlobId>

ControlStore::put_blob for a blob that only a LATER ControlStore::commit_doc makes part of any state (perf twin-apply-fsync, 2026-10-06): the store may keep it without making it durable on its own, because the pointer move that publishes it is durable and persists it — redb’s durable commit persists every earlier commit. Until then it is an unreferenced, content-addressed row nothing can reach, and a crash that takes it takes nothing anybody could see. The default is the durable put_blob. Read more
Source§

fn get_blob(&self, id: &BlobId) -> Result<Option<Vec<u8>>>

The bytes at this address, or None if nothing was ever stored there.
Source§

fn read_doc(&self, name: &str) -> Result<Option<BlobId>>

Which version name is at, or None for a document that has never been written. Read more
Source§

fn commit_doc( &self, name: &str, expected: Option<BlobId>, new: BlobId, ) -> Result<bool>

The compare-and-swap. Move name from expected to new, and append the new version to the audit trail, atomically. Read more
Source§

fn history(&self, name: &str) -> Result<Vec<DocVersion>>

Every version name has had, oldest first (the control plane’s audit trail).
Source§

impl Debug for RedbControlStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more