Skip to main content

WasmDbmsDatabase

Struct WasmDbmsDatabase 

Source
pub struct WasmDbmsDatabase<'ctx, M, A = AccessControlList>{ /* private fields */ }
Expand description

The main DBMS database struct, generic over MemoryProvider and AccessControl.

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

Implementations§

Source§

impl<'ctx, M, A> WasmDbmsDatabase<'ctx, M, A>

Source

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

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

Source

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

Creates a transactional database instance.

Source

pub fn granted( &self, id: &A::Id, table: TableFingerprint, required: TablePerms, ) -> bool

Returns whether id is granted required on table.

Source

pub fn granted_admin(&self, id: &A::Id) -> bool

Returns whether id carries the admin bypass flag.

Source

pub fn granted_manage_acl(&self, id: &A::Id) -> bool

Returns whether id carries the manage_acl flag.

Source

pub fn granted_migrate(&self, id: &A::Id) -> bool

Returns whether id carries the migrate flag.

Source

pub fn grant( &self, caller: &A::Id, target: A::Id, grant: PermGrant, ) -> DbmsResult<()>

Applies a grant on behalf of caller. Self-enforces manage_acl.

Source

pub fn revoke( &self, caller: &A::Id, target: &A::Id, revoke: PermRevoke, ) -> DbmsResult<()>

Applies a revoke on behalf of caller. Self-enforces manage_acl.

Source

pub fn remove_identity(&self, caller: &A::Id, target: &A::Id) -> DbmsResult<()>

Removes target from the ACL on behalf of caller. Self-enforces manage_acl.

Source

pub fn identities( &self, caller: &A::Id, ) -> DbmsResult<Vec<(A::Id, IdentityPerms)>>

Returns every identity in the ACL together with its perms, on behalf of caller. Self-enforces manage_acl.

Trait Implementations§

Source§

impl<M, A> Database for WasmDbmsDatabase<'_, M, A>

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, A> Freeze for WasmDbmsDatabase<'ctx, M, A>

§

impl<'ctx, M, A = AccessControlList> !RefUnwindSafe for WasmDbmsDatabase<'ctx, M, A>

§

impl<'ctx, M, A = AccessControlList> !Send for WasmDbmsDatabase<'ctx, M, A>

§

impl<'ctx, M, A = AccessControlList> !Sync for WasmDbmsDatabase<'ctx, M, A>

§

impl<'ctx, M, A> Unpin for WasmDbmsDatabase<'ctx, M, A>

§

impl<'ctx, M, A> UnsafeUnpin for WasmDbmsDatabase<'ctx, M, A>

§

impl<'ctx, M, A = AccessControlList> !UnwindSafe for WasmDbmsDatabase<'ctx, M, A>

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 = 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.