Struct Transaction

Source
#[non_exhaustive]
pub struct Transaction { /* private fields */ }

Implementations§

Source§

impl Transaction

Source

pub async fn export( &self, ns: &str, db: &str, cfg: Config, chn: Sender<Vec<u8>>, ) -> Result<(), Error>

Writes the full database contents as binary SQL.

Source§

impl Transaction

Source

pub fn new(local: bool, tx: Transactor) -> Transaction

Create a new query store

Source

pub fn inner(self) -> Transactor

Retrieve the underlying transaction

Source

pub fn enclose(self) -> Arc<Transaction>

Enclose this transaction in an Arc

Source

pub async fn lock(&self) -> MutexGuard<'_, Transactor>

Retrieve the underlying transaction

Source

pub fn local(&self) -> bool

Check if the transaction is local or distributed

Source

pub async fn closed(&self) -> bool

Check if the transaction is finished.

If the transaction has been canceled or committed, then this function will return true, and any further calls to functions on this transaction will result in a Error::TxFinished error.

Source

pub async fn cancel(&self) -> Result<(), Error>

Cancel a transaction.

This reverses all changes made within the transaction.

Source

pub async fn commit(&self) -> Result<(), Error>

Commit a transaction.

This attempts to commit all changes made within the transaction.

Source

pub async fn exists<K>( &self, key: K, version: Option<u64>, ) -> Result<bool, Error>
where K: KeyEncode + Debug,

Check if a key exists in the datastore.

Source

pub async fn get<K>( &self, key: K, version: Option<u64>, ) -> Result<Option<Val>, Error>
where K: KeyEncode + Debug,

Fetch a key from the datastore.

Source

pub async fn getm<K>(&self, keys: Vec<K>) -> Result<Vec<Option<Val>>, Error>
where K: KeyEncode + Debug,

Retrieve a batch set of keys from the datastore.

Source

pub async fn getp<K>(&self, key: K) -> Result<Vec<(Key, Val)>, Error>
where K: KeyEncode + Debug,

Retrieve a specific prefix of keys from the datastore.

This function fetches key-value pairs from the underlying datastore in grouped batches.

Source

pub async fn getr<K>( &self, rng: Range<K>, version: Option<u64>, ) -> Result<Vec<(Key, Val)>, Error>
where K: KeyEncode + Debug,

Retrieve a specific range of keys from the datastore.

This function fetches key-value pairs from the underlying datastore in grouped batches.

Source

pub async fn del<K>(&self, key: K) -> Result<(), Error>
where K: KeyEncode + Debug,

Delete a key from the datastore.

Source

pub async fn delc<K, V>(&self, key: K, chk: Option<V>) -> Result<(), Error>
where K: KeyEncode + Debug, V: Into<Val> + Debug,

Delete a key from the datastore if the current value matches a condition.

Source

pub async fn delr<K>(&self, rng: Range<K>) -> Result<(), Error>
where K: KeyEncode + Debug,

Delete a range of keys from the datastore.

This function deletes entries from the underlying datastore in grouped batches.

Source

pub async fn delp<K>(&self, key: K) -> Result<(), Error>
where K: KeyEncode + Debug,

Delete a prefix of keys from the datastore.

This function deletes entries from the underlying datastore in grouped batches.

Source

pub async fn clr<K>(&self, key: K) -> Result<(), Error>
where K: KeyEncode + Debug,

Delete all versions of a key from the datastore.

Source

pub async fn clrc<K, V>(&self, key: K, chk: Option<V>) -> Result<(), Error>
where K: KeyEncode + Debug, V: Into<Val> + Debug,

Delete all versions of a key from the datastore if the current value matches a condition.

Source

pub async fn clrr<K>(&self, rng: Range<K>) -> Result<(), Error>
where K: KeyEncode + Debug,

Delete all versions of a range of keys from the datastore.

This function deletes entries from the underlying datastore in grouped batches.

Source

pub async fn clrp<K>(&self, key: K) -> Result<(), Error>
where K: KeyEncode + Debug,

Delete all versions of a prefix of keys from the datastore.

This function deletes entries from the underlying datastore in grouped batches.

Source

pub async fn set<K, V>( &self, key: K, val: V, version: Option<u64>, ) -> Result<(), Error>
where K: KeyEncode + Debug, V: Into<Val> + Debug,

Insert or update a key in the datastore.

Source

pub async fn replace<K, V>(&self, key: K, val: V) -> Result<(), Error>
where K: KeyEncode + Debug, V: Into<Val> + Debug,

Insert or replace a key in the datastore.

Source

pub async fn put<K, V>( &self, key: K, val: V, version: Option<u64>, ) -> Result<(), Error>
where K: KeyEncode + Debug, V: Into<Val> + Debug,

Insert a key if it doesn’t exist in the datastore.

Source

pub async fn putc<K, V>( &self, key: K, val: V, chk: Option<V>, ) -> Result<(), Error>
where K: KeyEncode + Debug, V: Into<Val> + Debug,

Update a key in the datastore if the current value matches a condition.

Source

pub async fn keys<K>( &self, rng: Range<K>, limit: u32, version: Option<u64>, ) -> Result<Vec<Key>, Error>
where K: KeyEncode + Debug,

Retrieve a specific range of keys from the datastore.

This function fetches the full range of keys, in a single request to the underlying datastore.

Source

pub async fn scan<K>( &self, rng: Range<K>, limit: u32, version: Option<u64>, ) -> Result<Vec<(Key, Val)>, Error>
where K: KeyEncode + Debug,

Retrieve a specific range of keys from the datastore.

This function fetches the full range of key-value pairs, in a single request to the underlying datastore.

Source

pub async fn count<K>(&self, rng: Range<K>) -> Result<usize, Error>
where K: KeyEncode + Debug,

Count the total number of keys within a range in the datastore.

This function fetches the total count, in batches, with multiple requests to the underlying datastore.

Source

pub async fn batch_keys<K>( &self, rng: Range<K>, batch: u32, version: Option<u64>, ) -> Result<Batch<Key>, Error>
where K: KeyEncode + Debug,

Retrieve a batched scan over a specific range of keys in the datastore.

This function fetches the keys in batches, with multiple requests to the underlying datastore.

Source

pub async fn batch_keys_vals<K>( &self, rng: Range<K>, batch: u32, version: Option<u64>, ) -> Result<Batch<(Key, Val)>, Error>
where K: KeyEncode + Debug,

Retrieve a batched scan over a specific range of keys in the datastore.

This function fetches the key-value pairs in batches, with multiple requests to the underlying datastore.

Source

pub async fn batch_keys_vals_versions<K>( &self, rng: Range<K>, batch: u32, ) -> Result<Batch<(Key, Val, Version, bool)>, Error>
where K: KeyEncode + Debug,

Retrieve a batched scan over a specific range of keys in the datastore.

This function fetches the key-value-version pairs in batches, with multiple requests to the underlying datastore.

Source

pub fn stream( &self, rng: Range<Vec<u8>>, version: Option<u64>, limit: Option<usize>, ) -> impl Stream<Item = Result<(Key, Val), Error>> + '_

Retrieve a stream over a specific range of keys in the datastore.

This function fetches the key-value pairs in batches, with multiple requests to the underlying datastore.

Source

pub fn stream_keys( &self, rng: Range<Vec<u8>>, limit: Option<usize>, ) -> impl Stream<Item = Result<Key, Error>> + '_

Source

pub async fn rollback_with_warning(self) -> Self

Warn if this transaction is dropped without proper handling.

Source

pub async fn rollback_with_error(self) -> Self

Error if this transaction is dropped without proper handling.

Source

pub async fn rollback_and_ignore(self) -> Self

Do nothing if this transaction is dropped without proper handling.

Source

pub async fn all_nodes(&self) -> Result<Arc<[Node]>, Error>

Retrieve all nodes belonging to this cluster.

Source

pub async fn all_root_users(&self) -> Result<Arc<[DefineUserStatement]>, Error>

Retrieve all ROOT level users in a datastore.

Source

pub async fn all_root_accesses( &self, ) -> Result<Arc<[DefineAccessStatement]>, Error>

Retrieve all ROOT level accesses in a datastore.

Source

pub async fn all_root_access_grants( &self, ra: &str, ) -> Result<Arc<[AccessGrant]>, Error>

Retrieve all root access grants in a datastore.

Source

pub async fn all_ns(&self) -> Result<Arc<[DefineNamespaceStatement]>, Error>

Retrieve all namespace definitions in a datastore.

Source

pub async fn all_ns_users( &self, ns: &str, ) -> Result<Arc<[DefineUserStatement]>, Error>

Retrieve all namespace user definitions for a specific namespace.

Source

pub async fn all_ns_accesses( &self, ns: &str, ) -> Result<Arc<[DefineAccessStatement]>, Error>

Retrieve all namespace access definitions for a specific namespace.

Source

pub async fn all_ns_access_grants( &self, ns: &str, na: &str, ) -> Result<Arc<[AccessGrant]>, Error>

Retrieve all namespace access grants for a specific namespace.

Source

pub async fn all_db( &self, ns: &str, ) -> Result<Arc<[DefineDatabaseStatement]>, Error>

Retrieve all database definitions for a specific namespace.

Source

pub async fn all_db_users( &self, ns: &str, db: &str, ) -> Result<Arc<[DefineUserStatement]>, Error>

Retrieve all database user definitions for a specific database.

Source

pub async fn all_db_accesses( &self, ns: &str, db: &str, ) -> Result<Arc<[DefineAccessStatement]>, Error>

Retrieve all database access definitions for a specific database.

Source

pub async fn all_db_access_grants( &self, ns: &str, db: &str, da: &str, ) -> Result<Arc<[AccessGrant]>, Error>

Retrieve all database access grants for a specific database.

Source

pub async fn all_db_analyzers( &self, ns: &str, db: &str, ) -> Result<Arc<[DefineAnalyzerStatement]>, Error>

Retrieve all analyzer definitions for a specific database.

Source

pub async fn all_db_functions( &self, ns: &str, db: &str, ) -> Result<Arc<[DefineFunctionStatement]>, Error>

Retrieve all function definitions for a specific database.

Source

pub async fn all_db_params( &self, ns: &str, db: &str, ) -> Result<Arc<[DefineParamStatement]>, Error>

Retrieve all param definitions for a specific database.

Source

pub async fn all_db_models( &self, ns: &str, db: &str, ) -> Result<Arc<[DefineModelStatement]>, Error>

Retrieve all model definitions for a specific database.

Source

pub async fn all_db_configs( &self, ns: &str, db: &str, ) -> Result<Arc<[DefineConfigStatement]>, Error>

Retrieve all model definitions for a specific database.

Source

pub async fn all_tb( &self, ns: &str, db: &str, version: Option<u64>, ) -> Result<Arc<[DefineTableStatement]>, Error>

Retrieve all table definitions for a specific database.

Source

pub async fn all_tb_events( &self, ns: &str, db: &str, tb: &str, ) -> Result<Arc<[DefineEventStatement]>, Error>

Retrieve all event definitions for a specific table.

Source

pub async fn all_tb_fields( &self, ns: &str, db: &str, tb: &str, version: Option<u64>, ) -> Result<Arc<[DefineFieldStatement]>, Error>

Retrieve all field definitions for a specific table.

Source

pub async fn all_tb_indexes( &self, ns: &str, db: &str, tb: &str, ) -> Result<Arc<[DefineIndexStatement]>, Error>

Retrieve all index definitions for a specific table.

Source

pub async fn all_tb_views( &self, ns: &str, db: &str, tb: &str, ) -> Result<Arc<[DefineTableStatement]>, Error>

Retrieve all view definitions for a specific table.

Source

pub async fn all_tb_lives( &self, ns: &str, db: &str, tb: &str, ) -> Result<Arc<[LiveStatement]>, Error>

Retrieve all live definitions for a specific table.

Source

pub async fn get_node(&self, id: Uuid) -> Result<Arc<Node>, Error>

Retrieve a specific node in the cluster.

Source

pub async fn get_root_user( &self, us: &str, ) -> Result<Arc<DefineUserStatement>, Error>

Retrieve a specific root user definition.

Source

pub async fn get_root_access( &self, ra: &str, ) -> Result<Arc<DefineAccessStatement>, Error>

Retrieve a specific root access definition.

Source

pub async fn get_root_access_grant( &self, ac: &str, gr: &str, ) -> Result<Arc<AccessGrant>, Error>

Retrieve a specific root access grant.

Source

pub async fn get_ns( &self, ns: &str, ) -> Result<Arc<DefineNamespaceStatement>, Error>

Retrieve a specific namespace definition.

Source

pub async fn get_ns_user( &self, ns: &str, us: &str, ) -> Result<Arc<DefineUserStatement>, Error>

Retrieve a specific namespace user definition.

Source

pub async fn get_ns_access( &self, ns: &str, na: &str, ) -> Result<Arc<DefineAccessStatement>, Error>

Retrieve a specific namespace access definition.

Source

pub async fn get_ns_access_grant( &self, ns: &str, ac: &str, gr: &str, ) -> Result<Arc<AccessGrant>, Error>

Retrieve a specific namespace access grant.

Source

pub async fn get_db( &self, ns: &str, db: &str, ) -> Result<Arc<DefineDatabaseStatement>, Error>

Retrieve a specific database definition.

Source

pub async fn get_db_user( &self, ns: &str, db: &str, us: &str, ) -> Result<Arc<DefineUserStatement>, Error>

Retrieve a specific user definition from a database.

Source

pub async fn get_db_access( &self, ns: &str, db: &str, da: &str, ) -> Result<Arc<DefineAccessStatement>, Error>

Retrieve a specific database access definition.

Source

pub async fn get_db_access_grant( &self, ns: &str, db: &str, ac: &str, gr: &str, ) -> Result<Arc<AccessGrant>, Error>

Retrieve a specific database access grant.

Source

pub async fn get_db_model( &self, ns: &str, db: &str, ml: &str, vn: &str, ) -> Result<Arc<DefineModelStatement>, Error>

Retrieve a specific model definition from a database.

Source

pub async fn get_db_analyzer( &self, ns: &str, db: &str, az: &str, ) -> Result<Arc<DefineAnalyzerStatement>, Error>

Retrieve a specific analyzer definition.

Source

pub async fn get_db_function( &self, ns: &str, db: &str, fc: &str, ) -> Result<Arc<DefineFunctionStatement>, Error>

Retrieve a specific function definition from a database.

Source

pub async fn get_db_param( &self, ns: &str, db: &str, pa: &str, ) -> Result<Arc<DefineParamStatement>, Error>

Retrieve a specific function definition from a database.

Source

pub async fn get_db_config( &self, ns: &str, db: &str, cg: &str, ) -> Result<Arc<DefineConfigStatement>, Error>

Retrieve a specific config definition from a database.

Source

pub async fn get_tb( &self, ns: &str, db: &str, tb: &str, ) -> Result<Arc<DefineTableStatement>, Error>

Retrieve a specific table definition.

Source

pub async fn get_tb_event( &self, ns: &str, db: &str, tb: &str, ev: &str, ) -> Result<Arc<DefineEventStatement>, Error>

Retrieve an event for a table.

Source

pub async fn get_tb_field( &self, ns: &str, db: &str, tb: &str, fd: &str, ) -> Result<Arc<DefineFieldStatement>, Error>

Retrieve a field for a table.

Source

pub async fn get_tb_index( &self, ns: &str, db: &str, tb: &str, ix: &str, ) -> Result<Arc<DefineIndexStatement>, Error>

Retrieve an index for a table.

Source

pub async fn get_record( &self, ns: &str, db: &str, tb: &str, id: &Id, version: Option<u64>, ) -> Result<Arc<Value>, Error>

Fetch a specific record value.

Source

pub async fn set_record( &self, ns: &str, db: &str, tb: &str, id: &Id, val: Value, ) -> Result<(), Error>

Source

pub fn set_record_cache( &self, ns: &str, db: &str, tb: &str, id: &Id, val: Arc<Value>, ) -> Result<(), Error>

Source

pub async fn del_record( &self, ns: &str, db: &str, tb: &str, id: &Id, ) -> Result<(), Error>

Source

pub async fn get_or_add_ns( &self, ns: &str, strict: bool, ) -> Result<Arc<DefineNamespaceStatement>, Error>

Get or add a namespace with a default configuration, only if we are in dynamic mode.

Source

pub async fn get_or_add_db( &self, ns: &str, db: &str, strict: bool, ) -> Result<Arc<DefineDatabaseStatement>, Error>

Get or add a database with a default configuration, only if we are in dynamic mode.

Source

pub async fn get_or_add_tb( &self, ns: &str, db: &str, tb: &str, strict: bool, ) -> Result<Arc<DefineTableStatement>, Error>

Get or add a table with a default configuration, only if we are in dynamic mode.

Source

pub async fn ensure_ns_db_tb( &self, ns: &str, db: &str, tb: &str, strict: bool, ) -> Result<Arc<DefineTableStatement>, Error>

Ensures that a table, database, and namespace are all fully defined.

Source

pub fn clear(&self)

Clears all keys from the transaction cache.

Trait Implementations§

Source§

impl From<Transaction> for MutableContext

Source§

fn from(txn: Transaction) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> ParallelSend for T
where T: Send,