Skip to main content

DbmsContext

Struct DbmsContext 

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

Owns all mutable DBMS state behind interior-mutable wrappers.

Each component is wrapped in a RefCell so that operations borrowing different components can coexist without requiring &mut self on the context.

The access-control provider A defaults to AccessControlList. Runtimes that do not need ACL can use NoAccessControl.

§Threading

DbmsContext is !Send and !Sync because of the RefCell wrappers. This is intentional: WASM runtimes (both IC canisters and WASI preview 1 modules) execute single-threaded, so interior mutability via RefCell is sufficient and avoids the overhead of synchronization primitives. Embedders that need multi-threaded access should wrap the context in their own synchronization layer.

Implementations§

Source§

impl<M> DbmsContext<M>
where M: MemoryProvider,

Source

pub fn new(memory: M) -> Self

Creates a new DBMS context with the default AccessControlList, initializing the memory manager and loading persisted state.

Source§

impl<M, A> DbmsContext<M, A>

Source

pub fn with_acl(memory: M) -> Self

Creates a new DBMS context with a custom access control provider.

Source

pub fn register_table<T: TableSchema>(&self) -> DbmsResult<TableRegistryPage>

Registers a table schema, persisting it in stable memory.

Source

pub fn acl_add(&self, identity: A::Id) -> DbmsResult<()>

Adds an identity to the access-control list.

Source

pub fn acl_remove(&self, identity: &A::Id) -> DbmsResult<()>

Removes an identity from the access-control list.

Source

pub fn acl_allowed(&self) -> Vec<A::Id>

Returns all identities currently in the access-control list.

Source

pub fn acl_is_allowed(&self, identity: &A::Id) -> bool

Returns whether the given identity is allowed by the ACL.

Source

pub fn begin_transaction(&self, owner: Vec<u8>) -> TransactionId

Begins a new transaction for the given owner identity.

Source

pub fn has_transaction(&self, tx_id: &TransactionId, caller: &[u8]) -> bool

Returns whether the given transaction is owned by the given identity.

Trait Implementations§

Source§

impl<M, A> Debug for DbmsContext<M, A>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<M, A = AccessControlList> !Freeze for DbmsContext<M, A>

§

impl<M, A = AccessControlList> !RefUnwindSafe for DbmsContext<M, A>

§

impl<M, A> Send for DbmsContext<M, A>
where A: Send, M: Send,

§

impl<M, A = AccessControlList> !Sync for DbmsContext<M, A>

§

impl<M, A> Unpin for DbmsContext<M, A>
where A: Unpin, M: Unpin,

§

impl<M, A> UnsafeUnpin for DbmsContext<M, A>
where A: UnsafeUnpin, M: UnsafeUnpin,

§

impl<M, A> UnwindSafe for DbmsContext<M, A>
where A: UnwindSafe, M: UnwindSafe,

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.