Struct surrealkv::Store

source ·
pub struct Store { /* private fields */ }
Expand description

An MVCC-based transactional key-value store.

The store is closed asynchronously when it is dropped. If you need to guarantee that the store is closed before the program continues, use the close method.

Implementations§

source§

impl Store

source

pub fn new(opts: Options) -> Result<Self>

Creates a new MVCC key-value store with the given options.

source

pub fn begin(&self) -> Result<Transaction>

Begins a new read-write transaction. It creates a new transaction with the core and read-write mode, and sets the read timestamp from the oracle. It returns the transaction.

source

pub fn begin_with_mode(&self, mode: Mode) -> Result<Transaction>

Begins a new transaction with the given mode. It creates a new transaction with the core and the given mode, and sets the read timestamp from the oracle. It returns the transaction.

source

pub fn view(&self, f: impl FnOnce(&mut Transaction) -> Result<()>) -> Result<()>

Executes a function in a read-only transaction. It begins a new read-only transaction and executes the function with the transaction. It returns the result of the function.

source

pub async fn write( self: Arc<Self>, f: impl FnOnce(&mut Transaction) -> Result<()>, ) -> Result<()>

Executes a function in a read-write transaction and commits the transaction. It begins a new read-write transaction, executes the function with the transaction, and commits the transaction. It returns the result of the function.

source

pub async fn close(&self) -> Result<()>

Closes the inner store

source

pub async fn compact(&self) -> Result<()>

Trait Implementations§

source§

impl Default for Store

source§

fn default() -> Store

Returns the “default value” for a type. Read more
source§

impl Drop for Store

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl !Freeze for Store

§

impl !RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl !UnwindSafe 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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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

§

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.