Skip to main content

WasmDbmsDatabase

Struct WasmDbmsDatabase 

Source
pub struct WasmDbmsDatabase<'ctx, M>
where M: MemoryProvider,
{ /* private fields */ }
Expand description

The main DBMS database struct, generic over MemoryProvider.

This struct borrows from a DbmsContext and provides all CRUD operations, transaction management, and query execution.

Implementations§

Source§

impl<'ctx, M> WasmDbmsDatabase<'ctx, M>
where M: MemoryProvider,

Source

pub fn oneshot( ctx: &'ctx DbmsContext<M>, schema: impl DatabaseSchema<M> + 'ctx, ) -> Self

Creates a one-shot (non-transactional) database instance.

Source

pub fn from_transaction( ctx: &'ctx DbmsContext<M>, schema: impl DatabaseSchema<M> + 'ctx, transaction_id: TransactionId, ) -> Self

Creates a transactional database instance.

Trait Implementations§

Source§

impl<M> Database for WasmDbmsDatabase<'_, M>
where M: MemoryProvider,

Source§

fn select<T>(&self, query: Query) -> DbmsResult<Vec<T::Record>>
where T: TableSchema,

Runs a typed SELECT for table T and decodes each row into T::Record. Read more
Source§

fn select_raw( &self, table: &str, query: Query, ) -> DbmsResult<Vec<Vec<(ColumnDef, Value)>>>

Runs a SELECT against a table identified by name, returning raw column-value pairs instead of typed records. Read more
Source§

fn select_join( &self, table: &str, query: Query, ) -> DbmsResult<Vec<Vec<(JoinColumnDef, Value)>>>

Runs a join query starting from table, returning rows with JoinColumnDef entries that carry the source table name. Read more
Source§

fn aggregate<T>( &self, query: Query, aggregates: &[AggregateFunction], ) -> DbmsResult<Vec<AggregatedRow>>
where T: TableSchema,

Runs an aggregate query for table T, computing the requested aggregate functions per group. Read more
Source§

fn insert<T>(&self, record: T::Insert) -> DbmsResult<()>
where T: TableSchema, T::Insert: InsertRecord<Schema = T>,

Inserts a single record into table T. Read more
Source§

fn update<T>(&self, patch: T::Update) -> DbmsResult<u64>
where T: TableSchema, T::Update: UpdateRecord<Schema = T>,

Updates rows of table T matching the patch’s where_clause. Read more
Source§

fn delete<T>( &self, behaviour: DeleteBehavior, filter: Option<Filter>, ) -> DbmsResult<u64>
where T: TableSchema,

Deletes rows of table T matching filter. Read more
Source§

fn commit(&mut self) -> DbmsResult<()>

Commits the active transaction, replaying its operations against stable storage under a single write-ahead journal. Read more
Source§

fn rollback(&mut self) -> DbmsResult<()>

Discards every staged operation in the active transaction without touching stable storage, and consumes the transaction handle. Read more
Source§

fn has_drift(&self) -> DbmsResult<bool>

Returns true iff the compiled schema differs from the snapshots persisted in stable memory. Read more
Source§

fn pending_migrations(&self) -> DbmsResult<Vec<MigrationOp>>

Returns the migration ops needed to bring the on-disk schema in line with the compiled schema, without applying anything. Read more
Source§

fn migrate(&mut self, policy: MigrationPolicy) -> DbmsResult<()>

Applies a planned migration under policy. Read more

Auto Trait Implementations§

§

impl<'ctx, M> !RefUnwindSafe for WasmDbmsDatabase<'ctx, M>

§

impl<'ctx, M> !Send for WasmDbmsDatabase<'ctx, M>

§

impl<'ctx, M> !Sync for WasmDbmsDatabase<'ctx, M>

§

impl<'ctx, M> !UnwindSafe for WasmDbmsDatabase<'ctx, M>

§

impl<'ctx, M> Freeze for WasmDbmsDatabase<'ctx, M>
where &'ctx DbmsContext<M>: Freeze, Box<dyn DatabaseSchema<M> + 'ctx>: Freeze,

§

impl<'ctx, M> Unpin for WasmDbmsDatabase<'ctx, M>
where &'ctx DbmsContext<M>: Unpin, Box<dyn DatabaseSchema<M> + 'ctx>: Unpin,

§

impl<'ctx, M> UnsafeUnpin for WasmDbmsDatabase<'ctx, M>
where &'ctx DbmsContext<M>: UnsafeUnpin, Box<dyn DatabaseSchema<M> + 'ctx>: UnsafeUnpin,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.