Struct SqliteStorage

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

A Storage implementation based on an SQLite database.

Implementations§

Source§

impl SqliteStorage

Source

pub async fn open<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Opens a new SQLite database in the given path.

If the database does not already exist it will be created.

use datacake_sqlite::SqliteStorage;

let storage = SqliteStorage::open("./data.db").await.expect("Create database");
Source

pub async fn open_in_memory() -> Result<Self, Error>

Opens a new SQLite database in memory.

use datacake_sqlite::SqliteStorage;

let storage = SqliteStorage::open_in_memory().await.expect("Create database");
Source

pub fn from_handle(handle: StorageHandle) -> Self

Creates a new SqliteStorage instances from an existing storage handle.

Source

pub fn handle(&self) -> StorageHandle

Creates a copy of the storage handle to be used in other sections of code which do not need to be distributed.

WARNING: Any changes made to this will not be reflected in the cluster, it is primarily only provided for ease of reading.

The table state_entries is already created and reserved.

Trait Implementations§

Source§

impl Storage for SqliteStorage

Source§

type Error = Error

Source§

type DocsIter = Box<dyn Iterator<Item = Document>>

Source§

type MetadataIter = Box<dyn Iterator<Item = (u64, HLCTimestamp, bool)>>

Source§

fn get_keyspace_list<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieves all keyspace currently persisted.
Source§

fn iter_metadata<'life0, 'life1, 'async_trait>( &'life0 self, keyspace: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Self::MetadataIter, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieves an iterator producing all values contained within the store. Read more
Source§

fn remove_tombstones<'life0, 'life1, 'async_trait>( &'life0 self, keyspace: &'life1 str, keys: impl 'async_trait + Iterator<Item = Key> + Send, ) -> Pin<Box<dyn Future<Output = Result<(), BulkMutationError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove a set of keys which are marked as tombstones store. Read more
Source§

fn put<'life0, 'life1, 'async_trait>( &'life0 self, keyspace: &'life1 str, doc: Document, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Inserts or updates a document in the persistent store. Read more
Source§

fn multi_put<'life0, 'life1, 'async_trait>( &'life0 self, keyspace: &'life1 str, documents: impl 'async_trait + Iterator<Item = Document> + Send, ) -> Pin<Box<dyn Future<Output = Result<(), BulkMutationError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Inserts or updates a set of documents in the persistent store. Read more
Source§

fn mark_as_tombstone<'life0, 'life1, 'async_trait>( &'life0 self, keyspace: &'life1 str, doc_id: Key, timestamp: HLCTimestamp, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Marks a document in the store as a tombstone. Read more
Source§

fn mark_many_as_tombstone<'life0, 'life1, 'async_trait>( &'life0 self, keyspace: &'life1 str, documents: impl 'async_trait + Iterator<Item = DocumentMetadata> + Send, ) -> Pin<Box<dyn Future<Output = Result<(), BulkMutationError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Marks a set of documents in the store as a tombstone. Read more
Source§

fn get<'life0, 'life1, 'async_trait>( &'life0 self, keyspace: &'life1 str, doc_id: Key, ) -> Pin<Box<dyn Future<Output = Result<Option<Document>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieves a single document belonging to a given keyspace from the store.
Source§

fn multi_get<'life0, 'life1, 'async_trait>( &'life0 self, keyspace: &'life1 str, doc_ids: impl 'async_trait + Iterator<Item = Key> + Send, ) -> Pin<Box<dyn Future<Output = Result<Self::DocsIter, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieves a set of documents belonging to a given keyspace from the store. Read more
Source§

fn put_with_ctx<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, keyspace: &'life1 str, document: Document, _ctx: Option<&'life2 PutContext>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Inserts or updates a document in the persistent store. Read more
Source§

fn multi_put_with_ctx<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, keyspace: &'life1 str, documents: impl Iterator<Item = Document> + Send + 'async_trait, _ctx: Option<&'life2 PutContext>, ) -> Pin<Box<dyn Future<Output = Result<(), BulkMutationError<Self::Error>>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Inserts or updates a set of documents in the persistent store. Read more

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

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to 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