Skip to main content

DbmsContext

Struct DbmsContext 

Source
pub struct DbmsContext<M>
where M: MemoryProvider,
{ /* 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.

§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, initializing the memory manager and loading persisted state.

Source

pub fn flush(&self) -> DbmsResult<()>

Publishes changes made through this context to the memory provider.

Providers without durable storage implement this as a no-op. Active transaction overlays remain uncommitted and are not flushed.

Source

pub fn id(&self) -> ContextId

Returns the stable identity of this context.

Source

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

Registers a table schema, persisting it in stable memory.

Source

pub fn has_table(&self, name: &str) -> bool

Returns whether name resolves to a registered table.

Source

pub fn begin_transaction(&self) -> TransactionId

Begins a new transaction and returns its ID.

The engine does not record who opened the transaction: any code that holds the ID can use, commit, or roll it back. An embedder that serves several identities keeps its own ledger from ID to identity and checks it before every transactional call.

Source

pub fn has_transaction(&self, tx_id: &TransactionId) -> bool

Returns whether tx_id names a transaction that is still open.

Embedders use it to drop ledger entries whose transaction was closed through a path they did not see.

Trait Implementations§

Source§

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

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<M> !Freeze for DbmsContext<M>

§

impl<M> !RefUnwindSafe for DbmsContext<M>

§

impl<M> !Send for DbmsContext<M>

§

impl<M> !Sync for DbmsContext<M>

§

impl<M> Unpin for DbmsContext<M>

§

impl<M> UnsafeUnpin for DbmsContext<M>

§

impl<M> UnwindSafe for DbmsContext<M>

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.