Skip to main content

TableStore

Struct TableStore 

Source
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

Source

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

Source

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.

Source

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.

Source

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.

Source

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::InvalidArgument if column_count is zero or name contains characters other than alphanumeric, _, or -.
  • VeilidAPIError::NotInitialized before init or after shutdown, or when the existing data fails to decrypt (wrong device encryption key) and wipe_on_invalid_device_encryption_key is disabled.
  • VeilidAPIError::Generic if the table is already open with a smaller column count than requested (close it first), or if the backing-store open fails (::Internal for filesystem-permission failures).
Source

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::NotInitialized before init or after shutdown.
  • VeilidAPIError::InvalidArgument if name contains characters other than alphanumeric, _, or -.
  • VeilidAPIError::Generic if the table is still opened (drop all handles first) or the backing-store delete fails.
Source

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.

Source

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::NotInitialized before init or after shutdown.
  • VeilidAPIError::InvalidArgument if old_name or new_name contains characters other than alphanumeric, _, or -.
  • VeilidAPIError::Generic if new_name already exists or old_name does not exist.

Trait Implementations§

Source§

impl Debug for TableStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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