pub struct Store { /* private fields */ }Expand description
Synthesist / lattice adapter over a project’s claims/ directory.
Writes go through Store::append; reads go through
Store::query. Every append syncs the view before returning so
follow-up reads see the write.
Implementations§
Source§impl Store
impl Store
Sourcepub fn discover() -> Result<Self>
pub fn discover() -> Result<Self>
Open (or initialize) a Store.
Resolution order:
SYNTHESIST_DIRenv var (set by--data-dirin the CLI, or exported directly). Points at the directory CONTAININGclaims/. An explicit override that doesn’t resolve to an existing store is a hard error — silent fallback would mask misconfiguration (e.g. a typo yielding an empty estate).- Parent-directory walk from cwd. Opens the first ancestor
containing
claims/genesis.amc. - If none, initialize a fresh store at
cwd/claims/(unless a v1.synth/main.dbis in scope, in which case we refuse and name the migrator).
Sourcepub fn discover_from(start: &Path) -> Result<Self>
pub fn discover_from(start: &Path) -> Result<Self>
Like [discover] but starts from a given path.
Walk-up order:
- Any ancestor with a
claims/genesis.amc→ open it. - Otherwise, if any ancestor has a v1
.synth/main.db, bail with a prescriptive migration error. Silently creating an empty v2 estate alongside legacy data orphans the user’s work; we refuse. - Otherwise, initialize a fresh v2 estate at
start/claims/.
Sourcepub fn open_at(claims_dir: &Path) -> Result<Self>
pub fn open_at(claims_dir: &Path) -> Result<Self>
Open at an explicit claims/ directory. The directory must
already contain a genesis.amc.
Sourcepub fn discover_for(session: &Option<String>) -> Result<Self>
pub fn discover_for(session: &Option<String>) -> Result<Self>
Discover and scope the asserter with an optional session id.
When a session id is given, subsequent appends assert as
user:local:<user>:<session> — giving us attribution without
cryptographic identity (see IDENTITY.md for the v0.2 roadmap).
Sourcepub fn with_asserter(self, asserted_by: impl Into<String>) -> Self
pub fn with_asserter(self, asserted_by: impl Into<String>) -> Self
Override the asserter prefix. Reserved for tests and for future
callers that set asserter from a parsed Session claim (e.g.
beacon sync, rather than $USER).
Sourcepub fn append(
&mut self,
claim_type: ClaimType,
props: Value,
supersedes: Option<ClaimId>,
) -> Result<ClaimId>
pub fn append( &mut self, claim_type: ClaimType, props: Value, supersedes: Option<ClaimId>, ) -> Result<ClaimId>
Append a typed claim and synchronize the SQLite view.
Both the workflow layer and the substrate are type-agnostic
for validation purposes since claim 0.2.0 / workflow 0.2.0:
per-type schema validation is the consumer’s responsibility,
applied at its API boundary (typically a CLI or library
entrypoint) BEFORE calling this method. Consumers compose
nomograph_claim::validation helpers with their own per-type
validators; see synthesist::schema for a worked example.
This method assumes the caller has already validated props
for the given claim_type.
Sourcepub fn query(&self, sql: &str, params: &[&dyn ToSql]) -> Result<Vec<Value>>
pub fn query(&self, sql: &str, params: &[&dyn ToSql]) -> Result<Vec<Value>>
Run a read-only SQL query over the SQLite view.
Sourcepub fn sync_view(&mut self) -> Result<()>
pub fn sync_view(&mut self) -> Result<()>
Force a view rebuild. Most callers don’t need this; append
syncs automatically.
Sourcepub fn inner(&mut self) -> &mut ClaimStore
pub fn inner(&mut self) -> &mut ClaimStore
Access the underlying claim store (for session handles, compact, merge). Most callers should not need this.
Auto Trait Implementations§
impl !Freeze for Store
impl !RefUnwindSafe for Store
impl Send for Store
impl !Sync for Store
impl Unpin for Store
impl UnsafeUnpin for Store
impl !UnwindSafe for Store
Blanket Implementations§
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more