pub struct Conn { /* private fields */ }Expand description
A mutable, safe reference to the current Mentat store.
Implementations§
Source§impl Conn
impl Conn
pub fn connect(sqlite: &mut Connection) -> Result<Conn>
Sourcepub fn current_schema(&self) -> Arc<Schema> ⓘ
pub fn current_schema(&self) -> Arc<Schema> ⓘ
Yield a clone of the current Schema instance.
pub fn current_cache(&self) -> SQLiteAttributeCache
pub fn last_tx_id(&self) -> Entid
Sourcepub fn q_once<T>(
&self,
sqlite: &Connection,
query: &str,
inputs: T,
) -> Result<QueryOutput>
pub fn q_once<T>( &self, sqlite: &Connection, query: &str, inputs: T, ) -> Result<QueryOutput>
Query the Mentat store, using the given connection and the current metadata.
Sourcepub fn q_once_value_filtered<T>(
&self,
sqlite: &Connection,
query: &str,
inputs: T,
) -> Result<(QueryOutput, BTreeSet<Entid>)>
pub fn q_once_value_filtered<T>( &self, sqlite: &Connection, query: &str, inputs: T, ) -> Result<(QueryOutput, BTreeSet<Entid>)>
q_once, plus the attributes it filtered by value (see auto_index).
Sourcepub fn q_once_as_of<T>(
&self,
sqlite: &Connection,
query: &str,
inputs: T,
tx: Entid,
) -> Result<QueryOutput>
pub fn q_once_as_of<T>( &self, sqlite: &Connection, query: &str, inputs: T, tx: Entid, ) -> Result<QueryOutput>
Query the store against a historical basis reconstructed as of transaction
tx (inclusive): the value that was current at tx.
Sourcepub fn q_once_since<T>(
&self,
sqlite: &Connection,
query: &str,
inputs: T,
tx: Entid,
) -> Result<QueryOutput>
pub fn q_once_since<T>( &self, sqlite: &Connection, query: &str, inputs: T, tx: Entid, ) -> Result<QueryOutput>
Query the store seeing only the current datoms transacted after
transaction tx (Datomic’s since).
Sourcepub fn q_once_temporal<T>(
&self,
sqlite: &Connection,
query: &str,
inputs: T,
basis: TemporalBound,
) -> Result<QueryOutput>
pub fn q_once_temporal<T>( &self, sqlite: &Connection, query: &str, inputs: T, basis: TemporalBound, ) -> Result<QueryOutput>
Query the store on a historical basis (as-of, since, or both).
Sourcepub fn q_uncached<T>(
&self,
sqlite: &Connection,
query: &str,
inputs: T,
) -> Result<QueryOutput>
pub fn q_uncached<T>( &self, sqlite: &Connection, query: &str, inputs: T, ) -> Result<QueryOutput>
Query the Mentat store, using the given connection and the current metadata, but without using the cache.
pub fn q_prepare<'sqlite, T>( &self, sqlite: &'sqlite Connection, query: &str, inputs: T, ) -> PreparedResult<'sqlite>
pub fn q_explain<T>( &self, sqlite: &Connection, query: &str, inputs: T, ) -> Result<QueryExplanation>
Sourcepub fn q_explain_temporal<T>(
&self,
sqlite: &Connection,
query: &str,
inputs: T,
temporal: Option<TemporalBound>,
) -> Result<QueryExplanation>
pub fn q_explain_temporal<T>( &self, sqlite: &Connection, query: &str, inputs: T, temporal: Option<TemporalBound>, ) -> Result<QueryExplanation>
q_explain against a historical basis (None = current).
pub fn pull_attributes_for_entities<E, A>( &self, sqlite: &Connection, entities: E, attributes: A, ) -> Result<BTreeMap<Entid, ValueRc<StructuredMap>>>
pub fn pull_attributes_for_entity<A>(
&self,
sqlite: &Connection,
entity: Entid,
attributes: A,
) -> Result<StructuredMap>where
A: IntoIterator<Item = Entid>,
Sourcepub fn pull_on(
&self,
sqlite: &Connection,
entity: Entid,
pattern: &str,
basis: Option<TemporalBound>,
) -> Result<StructuredMap>
pub fn pull_on( &self, sqlite: &Connection, entity: Entid, pattern: &str, basis: Option<TemporalBound>, ) -> Result<StructuredMap>
Pull pattern (EDN, e.g. [:person/name {:person/friend [*]}]) for
entity on basis (None = current, else as-of / since).
pub fn lookup_values_for_attribute( &self, sqlite: &Connection, entity: Entid, attribute: &Keyword, ) -> Result<Vec<TypedValue>>
pub fn lookup_value_for_attribute( &self, sqlite: &Connection, entity: Entid, attribute: &Keyword, ) -> Result<Option<TypedValue>>
pub fn begin_read<'m, 'conn>( &'m mut self, sqlite: &'conn mut Connection, ) -> Result<InProgressRead<'m, 'conn>>
pub fn begin_uncached_read<'m, 'conn>( &'m mut self, sqlite: &'conn mut Connection, ) -> Result<InProgressRead<'m, 'conn>>
Sourcepub fn begin_transaction<'m, 'conn>(
&'m mut self,
sqlite: &'conn mut Connection,
) -> Result<InProgress<'m, 'conn>>
pub fn begin_transaction<'m, 'conn>( &'m mut self, sqlite: &'conn mut Connection, ) -> Result<InProgress<'m, 'conn>>
IMMEDIATE means ‘start the transaction now, but don’t exclude readers’. It prevents other
connections from taking immediate or exclusive transactions. This is appropriate for our
writes and InProgress: it means we are ready to write whenever we want to, and nobody else
can start a transaction that’s not DEFERRED, but we don’t need exclusivity yet.
Sourcepub fn transact<B>(
&mut self,
sqlite: &mut Connection,
transaction: B,
) -> Result<TxReport>
pub fn transact<B>( &mut self, sqlite: &mut Connection, transaction: B, ) -> Result<TxReport>
Transact entities against the Mentat store, using the given connection and the current metadata.
Sourcepub fn transact_speculative<B>(
&mut self,
sqlite: &mut Connection,
transaction: B,
) -> Result<TxReport>
pub fn transact_speculative<B>( &mut self, sqlite: &mut Connection, transaction: B, ) -> Result<TxReport>
Speculatively transact transaction and return its TxReport without
persisting anything (Datomic d/with / pg_mentat mentat.with). The
enclosing SQLite transaction is rolled back on drop, so no changes are
committed even though a real IMMEDIATE transaction was opened.
Sourcepub fn cache(
&mut self,
sqlite: &mut Connection,
schema: &Schema,
attribute: &Keyword,
cache_direction: CacheDirection,
cache_action: CacheAction,
) -> Result<()>
pub fn cache( &mut self, sqlite: &mut Connection, schema: &Schema, attribute: &Keyword, cache_direction: CacheDirection, cache_action: CacheAction, ) -> Result<()>
Adds or removes the values of a given attribute to an in-memory cache.
The attribute should be a namespaced string: e.g., :foo/bar.
cache_action determines if the attribute should be added or removed from the cache.
CacheAction::Add is idempotent - each attribute is only added once.
CacheAction::Remove throws an error if the attribute does not currently exist in the cache.
pub fn register_observer(&mut self, key: String, observer: Arc<TxObserver>)
pub fn unregister_observer(&mut self, key: &str)
Auto Trait Implementations§
impl !Freeze for Conn
impl RefUnwindSafe for Conn
impl Send for Conn
impl Sync for Conn
impl Unpin for Conn
impl UnsafeUnpin for Conn
impl UnwindSafe for Conn
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> 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