pub struct SqliteMetadataStore { /* private fields */ }Expand description
SQLite-backed persistent metadata store.
Opens its own rusqlite::Connection to the supplied database path —
the same path the mob’s MobStorage uses, but with a separate handle.
Cross-handle access is safe; meerkat #445’s notify-based event-store
watcher already runs in this configuration. The mobkit_metadata
table is created on init and is independent of meerkat-mob’s own
schema, so opening order doesn’t matter.
Schema:
CREATE TABLE mobkit_metadata (
mob_id TEXT NOT NULL,
key TEXT NOT NULL,
value TEXT NOT NULL,
PRIMARY KEY (mob_id, key)
)The subscription cursor lives at key = "subscription_cursor",
stored as a base-10 string for simple human inspection. Future
metadata fields land here under their own keys.
Implementations§
Source§impl SqliteMetadataStore
impl SqliteMetadataStore
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self, MetadataStoreError>
pub fn open(path: impl AsRef<Path>) -> Result<Self, MetadataStoreError>
Open (or create) a SQLite metadata store at path.
path should typically be the same database the mob’s MobStorage
uses; the table is mobkit_metadata and won’t collide with
meerkat-mob’s own tables.
Sourcepub fn in_memory() -> Result<Self, MetadataStoreError>
pub fn in_memory() -> Result<Self, MetadataStoreError>
Open an in-memory SQLite store (for tests).
Trait Implementations§
Source§impl PersistentMetadataStore for SqliteMetadataStore
impl PersistentMetadataStore for SqliteMetadataStore
Source§fn get_subscription_cursor<'life0, 'life1, 'async_trait>(
&'life0 self,
mob_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<u64>, MetadataStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_subscription_cursor<'life0, 'life1, 'async_trait>(
&'life0 self,
mob_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<u64>, MetadataStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
mob_id. Returns
Ok(None) when no cursor has been written yet (fresh deploy or
in-memory deployment that just started).Source§fn set_subscription_cursor<'life0, 'life1, 'async_trait>(
&'life0 self,
mob_id: &'life1 str,
cursor: u64,
) -> Pin<Box<dyn Future<Output = Result<(), MetadataStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_subscription_cursor<'life0, 'life1, 'async_trait>(
&'life0 self,
mob_id: &'life1 str,
cursor: u64,
) -> Pin<Box<dyn Future<Output = Result<(), MetadataStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
mob_id.Auto Trait Implementations§
impl !Freeze for SqliteMetadataStore
impl RefUnwindSafe for SqliteMetadataStore
impl Send for SqliteMetadataStore
impl Sync for SqliteMetadataStore
impl Unpin for SqliteMetadataStore
impl UnsafeUnpin for SqliteMetadataStore
impl UnwindSafe for SqliteMetadataStore
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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