pub struct NetDbBuilder { /* private fields */ }Expand description
Builder for NetDb.
Implementations§
Source§impl NetDbBuilder
impl NetDbBuilder
Sourcepub fn origin(self, origin_hash: u64) -> NetDbBuilder
pub fn origin(self, origin_hash: u64) -> NetDbBuilder
Set the producer origin_hash stamped on every EventMeta by
the bundled adapters.
Sourcepub fn persistent(self, persistent: bool) -> NetDbBuilder
pub fn persistent(self, persistent: bool) -> NetDbBuilder
When true, every enabled model’s underlying RedEX file uses
persistent: true. Requires the Redex to have been
constructed with with_persistent_dir(...).
Sourcepub fn with_tasks(self) -> NetDbBuilder
pub fn with_tasks(self) -> NetDbBuilder
Include the tasks model.
Sourcepub fn with_memories(self) -> NetDbBuilder
pub fn with_memories(self) -> NetDbBuilder
Include the memories model.
Sourcepub async fn build(self) -> Result<NetDb, NetDbError>
pub async fn build(self) -> Result<NetDb, NetDbError>
Build the NetDb. Opens each enabled model against the
underlying Redex.
§Failure atomicity
If the second adapter open fails, the first adapter is closed
before the error propagates so no orphan fold task outlives
the failed build. The Redex is dropped with the builder on
the error path — callers who want to retry without losing
shared state should construct a new Redex (retry on the
same manager is not available since the builder consumes it
by value).
The atomicity guarantee itself is code-level: the close-on-error block below is the authoritative source of truth. Integration tests exercise the observable error path but cannot directly observe the closed first-adapter after the Redex has been dropped.
Sourcepub async fn build_from_snapshot(
self,
snapshot: &NetDbSnapshot,
) -> Result<NetDb, NetDbError>
pub async fn build_from_snapshot( self, snapshot: &NetDbSnapshot, ) -> Result<NetDb, NetDbError>
Like Self::build, but restore each enabled model from the
corresponding entry in snapshot. A model enabled via
with_*() whose snapshot entry is None in the bundle is
opened from scratch via the normal open path (equivalent to
Self::build for that model).
Same failure-atomicity guarantee as Self::build — a
second-adapter failure closes the first before the error
propagates. See build’s docs for the caveat that the
failing Redex is dropped with the builder.