Skip to main content

Conn

Struct Conn 

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

A mutable, safe reference to the current Mentat store.

Implementations§

Source§

impl Conn

Source

pub fn connect(sqlite: &mut Connection) -> Result<Conn>

Source

pub fn current_schema(&self) -> Arc<Schema> ⓘ

Yield a clone of the current Schema instance.

Source

pub fn current_cache(&self) -> SQLiteAttributeCache

Source

pub fn last_tx_id(&self) -> Entid

Source

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

Query the Mentat store, using the given connection and the current metadata.

Source

pub fn q_once_value_filtered<T>( &self, sqlite: &Connection, query: &str, inputs: T, ) -> Result<(QueryOutput, BTreeSet<Entid>)>
where T: Into<Option<QueryInputs>>,

q_once, plus the attributes it filtered by value (see auto_index).

Source

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

Query the store against a historical basis reconstructed as of transaction tx (inclusive): the value that was current at tx.

Source

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

Query the store seeing only the current datoms transacted after transaction tx (Datomic’s since).

Source

pub fn q_once_temporal<T>( &self, sqlite: &Connection, query: &str, inputs: T, basis: TemporalBound, ) -> Result<QueryOutput>
where T: Into<Option<QueryInputs>>,

Query the store on a historical basis (as-of, since, or both).

Source

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

Query the Mentat store, using the given connection and the current metadata, but without using the cache.

Source

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

Source

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

Source

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

q_explain against a historical basis (None = current).

Source

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

Source

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

Source

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

Source

pub fn lookup_values_for_attribute( &self, sqlite: &Connection, entity: Entid, attribute: &Keyword, ) -> Result<Vec<TypedValue>>

Source

pub fn lookup_value_for_attribute( &self, sqlite: &Connection, entity: Entid, attribute: &Keyword, ) -> Result<Option<TypedValue>>

Source

pub fn begin_read<'m, 'conn>( &'m mut self, sqlite: &'conn mut Connection, ) -> Result<InProgressRead<'m, 'conn>>

Source

pub fn begin_uncached_read<'m, 'conn>( &'m mut self, sqlite: &'conn mut Connection, ) -> Result<InProgressRead<'m, 'conn>>

Source

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.

Source

pub fn transact<B>( &mut self, sqlite: &mut Connection, transaction: B, ) -> Result<TxReport>
where B: Borrow<str>,

Transact entities against the Mentat store, using the given connection and the current metadata.

Source

pub fn transact_speculative<B>( &mut self, sqlite: &mut Connection, transaction: B, ) -> Result<TxReport>
where B: Borrow<str>,

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.

Source

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.

Source

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

Source

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