Skip to main content

Store

Struct Store 

Source
pub struct Store { /* private fields */ }

Implementations§

Source§

impl Store

Source

pub fn open(path: &str) -> Result<Store>

Open a store at the supplied path, ensuring that it includes the bootstrap schema.

Source

pub fn transact(&mut self, transaction: &str) -> Result<TxReport>

Source

pub fn expand_tx_fns(&mut self, transaction: &str) -> Result<String>

Prepare transaction for the transactor: replace every invocation of a user-defined transaction function ([:my/fn arg ...] on an ident that carries :db/fn) with the tx-data it returns, and define the :db/fn attribute itself the first time a transaction installs a function. Store::transact and Store::with_speculative call this; a host that drives InProgress::transact directly calls it first.

Functions run in the sandboxed mino interpreter (mino feature), see the database as of the start of the transaction, and nest at most MENTAT_TXFN_MAX_DEPTH (default 16) deep. Without the mino feature only the :db/fn attribute bootstrap applies.

Source

pub fn with_speculative(&mut self, transaction: &str) -> Result<TxReport>

Speculatively transact transaction and return its TxReport WITHOUT committing (Datomic d/with). Delegates to Conn::transact_speculative, which opens a real SQLite transaction and rolls it back on drop, so the store is left unchanged. This is the thin &mut Store wrapper the scripting layer needs, since transact_speculative lives on Conn and wants both the Conn and the rusqlite::Connection (both private here).

Source§

impl Store

Source

pub fn sqlite_mut(&mut self) -> &mut Connection

Intended for use from tests.

Source

pub fn sqlite_ref(&self) -> &Connection

A shared borrow of the underlying SQLite connection, for read-only helpers (e.g. mentat_db::debug::datoms) that only need &Connection.

Source§

impl Store

Source

pub fn dismantle(self) -> (Connection, Conn)

Source

pub fn conn(&self) -> &Conn

Source

pub fn begin_read(&mut self) -> Result<InProgressRead<'_, '_>>

Source

pub fn begin_transaction(&mut self) -> Result<InProgress<'_, '_>>

Source

pub fn cache(&mut self, attr: &Keyword, direction: CacheDirection) -> Result<()>

Source

pub fn register_observer(&mut self, key: String, observer: Arc<TxObserver>)

Source

pub fn unregister_observer(&mut self, key: &str)

Source

pub fn last_tx_id(&self) -> Entid

Source

pub fn set_auto_index(&mut self, mode: AutoIndex)

How mentat manages secondary indexes for this Store (see AutoIndex). The default comes from MENTAT_AUTO_INDEX (off/schema/adaptive), else Schema.

Source

pub fn set_index_tuning(&mut self, min_uses: u32, idle: Duration)

Adaptive thresholds: create an index once an attribute is value-filtered by min_uses queries within one tuning period; drop a mentat-created index unused for a whole period and for at least idle.

Source

pub fn tune_indexes(&mut self, dry_run: bool) -> Result<Vec<IndexAction>>

Apply (or, with dry_run, only report) index changes per the current AutoIndex mode. Only ever drops indexes mentat created (listed in mentat_managed_indexes).

Source

pub fn q_once_as_of<T>( &self, query: &str, inputs: T, tx: Entid, ) -> Result<QueryOutput>
where T: Into<Option<QueryInputs>>,

Run a Datalog query against a historical basis reconstructed as of transaction tx (inclusive) – the state that was current at tx.

Source

pub fn q_explain_temporal<T>( &self, query: &str, inputs: T, temporal: Option<TemporalBound>, ) -> Result<QueryExplanation>
where T: Into<Option<QueryInputs>>,

EXPLAIN QUERY PLAN for a query, optionally against a historical basis.

Source

pub fn q_once_since<T>( &self, query: &str, inputs: T, tx: Entid, ) -> Result<QueryOutput>
where T: Into<Option<QueryInputs>>,

Run a Datalog query seeing only datoms transacted after transaction tx (since). Typically used with a history pattern [?e ?a ?v ?tx ?added].

Trait Implementations§

Source§

impl Pullable for Store

Source§

fn pull_attributes_for_entities<E, A>( &self, entities: E, attributes: A, ) -> Result<BTreeMap<Entid, ValueRc<StructuredMap>>>
where E: IntoIterator<Item = Entid>, A: IntoIterator<Item = Entid>,

Source§

fn pull_attributes_for_entity<A>( &self, entity: Entid, attributes: A, ) -> Result<StructuredMap>
where A: IntoIterator<Item = Entid>,

Source§

impl Queryable for Store

Source§

fn q_once<T>(&self, query: &str, inputs: T) -> Result<QueryOutput>
where T: Into<Option<QueryInputs>>,

Source§

fn q_prepare<T>(&self, query: &str, inputs: T) -> PreparedResult<'_>
where T: Into<Option<QueryInputs>>,

Source§

fn q_explain<T>(&self, query: &str, inputs: T) -> Result<QueryExplanation>
where T: Into<Option<QueryInputs>>,

Source§

fn lookup_values_for_attribute<E>( &self, entity: E, attribute: &Keyword, ) -> Result<Vec<TypedValue>>
where E: Into<Entid>,

Source§

fn lookup_value_for_attribute<E>( &self, entity: E, attribute: &Keyword, ) -> Result<Option<TypedValue>>
where E: Into<Entid>,

Auto Trait Implementations§

§

impl !Freeze for Store

§

impl !RefUnwindSafe for Store

§

impl !Sync for Store

§

impl !UnwindSafe for Store

§

impl Send for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
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.