pub struct TableStore { /* private fields */ }Expand description
Veilid Table Storage. Database for storing key value pairs persistently and securely across runs.
Implementations§
Source§impl TableStore
impl TableStore
Sourcepub async fn tick(&self, _lag: Option<TimestampDuration>) -> EyreResult<()>
pub async fn tick(&self, _lag: Option<TimestampDuration>) -> EyreResult<()>
Run the periodic flush and cleanup table maintenance tasks.
No-op before init or after shutdown. Each subtask only runs once its interval has elapsed (60s flush, 600s cleanup), so calling more often is cheap; an actual flush or cleanup run blocks on disk.
Source§impl TableStore
impl TableStore
Sourcepub fn list_all(&self) -> Vec<(String, String)>
pub fn list_all(&self) -> Vec<(String, String)>
List all known tables
Reads cached names locally without blocking on disk; returns empty before init or after shutdown.
Sourcepub async fn delete_all(&self)
pub async fn delete_all(&self)
Delete all known tables
No-op before init or after shutdown. Blocks on deleting each table on disk and flushing.
Sourcepub async fn open(
&self,
name: &str,
column_count: u32,
) -> VeilidAPIResult<TableDB>
pub async fn open( &self, name: &str, column_count: u32, ) -> VeilidAPIResult<TableDB>
Get or create a TableDB database table. If the column count is greater than an existing TableDB’s column count, the database will be upgraded to add the missing columns.
Returns a TableDB handle the caller must drop before the table can be deleted; while any clone is held the table counts as opened. Opening the same name again returns a handle to the same shared database. Blocks on opening the on-disk database.
Same errors as open_pooled.
Sourcepub async fn open_pooled(
&self,
name: &str,
column_count: u32,
concurrency: usize,
) -> VeilidAPIResult<TableDB>
pub async fn open_pooled( &self, name: &str, column_count: u32, concurrency: usize, ) -> VeilidAPIResult<TableDB>
Get or create a TableDB table, opening a pool of concurrency database connections for it.
Like open, upgrades the table if column_count exceeds the existing column count.
Returns a TableDB handle the caller must drop before the table can be deleted; while any clone is held the table counts as opened. Opening the same name again returns a handle to the same shared database. Blocks on opening the on-disk database.
Errors with:
VeilidAPIError::InvalidArgumentifcolumn_countis zero ornamecontains characters other than alphanumeric,_, or-.VeilidAPIError::NotInitializedbefore init or after shutdown, or when the existing data fails to decrypt (wrong device encryption key) andwipe_on_invalid_device_encryption_keyis disabled.VeilidAPIError::Genericif the table is already open with a smaller column count than requested (close it first), or if the backing-store open fails (::Internalfor filesystem-permission failures).
Sourcepub async fn delete(&self, name: &str) -> VeilidAPIResult<bool>
pub async fn delete(&self, name: &str) -> VeilidAPIResult<bool>
Delete a TableDB table by name
Errors if the table is still opened; the caller must drop all TableDB handles for it first. Blocks on the on-disk delete and flush.
Returns Ok(false) if no table by that name exists. Errors with:
VeilidAPIError::NotInitializedbefore init or after shutdown.VeilidAPIError::InvalidArgumentifnamecontains characters other than alphanumeric,_, or-.VeilidAPIError::Genericif the table is still opened (drop all handles first) or the backing-store delete fails.
Sourcepub async fn info(&self, name: &str) -> VeilidAPIResult<Option<TableInfo>>
pub async fn info(&self, name: &str) -> VeilidAPIResult<Option<TableInfo>>
Get column and key-count information for a table, or None if it does not exist.
Opens the table to read it; blocks on the on-disk open and key-count reads.
Errors with VeilidAPIError::NotInitialized before init or after shutdown, the same errors as open (the table is opened to read it), or VeilidAPIError::Generic if a column-count or key-count read fails.
Sourcepub async fn rename(
&self,
old_name: &str,
new_name: &str,
) -> VeilidAPIResult<()>
pub async fn rename( &self, old_name: &str, new_name: &str, ) -> VeilidAPIResult<()>
Rename a TableDB table
Blocks on flushing the renamed name table to disk.
Errors with:
VeilidAPIError::NotInitializedbefore init or after shutdown.VeilidAPIError::InvalidArgumentifold_nameornew_namecontains characters other than alphanumeric,_, or-.VeilidAPIError::Genericifnew_namealready exists orold_namedoes not exist.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for TableStore
impl !RefUnwindSafe for TableStore
impl !UnwindSafe for TableStore
impl Send for TableStore
impl Sync for TableStore
impl Unpin for TableStore
impl UnsafeUnpin for TableStore
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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