Skip to main content

DbSession

Struct DbSession 

Source
pub struct DbSession<C: CanisterKind> { /* private fields */ }
Expand description

DbSession

Session-scoped database handle with policy (debug, metrics) and execution routing.

Implementations§

Source§

impl<C: CanisterKind> DbSession<C>

Source

pub const fn new_with_hooks( store: &'static LocalKey<StoreRegistry>, entity_runtime_hooks: &'static [EntityRuntimeHooks<C>], ) -> Self

Construct one session facade from store registry and runtime hooks.

Source

pub const fn debug(self) -> Self

Enable debug execution behavior where supported by executors.

Source

pub const fn metrics_sink(self, sink: &'static dyn MetricsSink) -> Self

Attach one metrics sink for all session-executed operations.

Source

pub const fn load<E>(&self) -> FluentLoadQuery<'_, E>
where E: EntityKind<Canister = C>,

Start a fluent load query with default missing-row policy (Ignore).

Source

pub const fn load_with_consistency<E>( &self, consistency: MissingRowPolicy, ) -> FluentLoadQuery<'_, E>
where E: EntityKind<Canister = C>,

Start a fluent load query with explicit missing-row policy.

Source

pub fn delete<E>(&self) -> FluentDeleteQuery<'_, E>
where E: EntityKind<Canister = C>,

Start a fluent delete query with default missing-row policy (Ignore).

Source

pub fn delete_with_consistency<E>( &self, consistency: MissingRowPolicy, ) -> FluentDeleteQuery<'_, E>
where E: EntityKind<Canister = C>,

Start a fluent delete query with explicit missing-row policy.

Source

pub fn execute_query<E>( &self, query: &Query<E>, ) -> Result<EntityResponse<E>, QueryError>
where E: EntityKind<Canister = C> + EntityValue,

Execute one scalar load/delete query and return materialized response rows.

Source

pub fn execute_grouped<E>( &self, query: &Query<E>, cursor_token: Option<&str>, ) -> Result<PagedGroupedExecutionWithTrace, QueryError>
where E: EntityKind<Canister = C> + EntityValue,

Execute one grouped query page with optional grouped continuation cursor.

This is the explicit grouped execution boundary; scalar load APIs reject grouped plans to preserve scalar response contracts.

Source

pub fn insert<E>(&self, entity: E) -> Result<E, InternalError>
where E: EntityKind<Canister = C> + EntityValue,

Insert one entity row.

Source

pub fn insert_many_atomic<E>( &self, entities: impl IntoIterator<Item = E>, ) -> Result<WriteBatchResponse<E>, InternalError>
where E: EntityKind<Canister = C> + EntityValue,

Insert a single-entity-type batch atomically in one commit window.

If any item fails pre-commit validation, no row in the batch is persisted.

This API is not a multi-entity transaction surface.

Source

pub fn insert_many_non_atomic<E>( &self, entities: impl IntoIterator<Item = E>, ) -> Result<WriteBatchResponse<E>, InternalError>
where E: EntityKind<Canister = C> + EntityValue,

Insert a batch with explicitly non-atomic semantics.

WARNING: fail-fast and non-atomic. Earlier inserts may commit before an error.

Source

pub fn replace<E>(&self, entity: E) -> Result<E, InternalError>
where E: EntityKind<Canister = C> + EntityValue,

Replace one existing entity row.

Source

pub fn replace_many_atomic<E>( &self, entities: impl IntoIterator<Item = E>, ) -> Result<WriteBatchResponse<E>, InternalError>
where E: EntityKind<Canister = C> + EntityValue,

Replace a single-entity-type batch atomically in one commit window.

If any item fails pre-commit validation, no row in the batch is persisted.

This API is not a multi-entity transaction surface.

Source

pub fn replace_many_non_atomic<E>( &self, entities: impl IntoIterator<Item = E>, ) -> Result<WriteBatchResponse<E>, InternalError>
where E: EntityKind<Canister = C> + EntityValue,

Replace a batch with explicitly non-atomic semantics.

WARNING: fail-fast and non-atomic. Earlier replaces may commit before an error.

Source

pub fn update<E>(&self, entity: E) -> Result<E, InternalError>
where E: EntityKind<Canister = C> + EntityValue,

Update one existing entity row.

Source

pub fn update_many_atomic<E>( &self, entities: impl IntoIterator<Item = E>, ) -> Result<WriteBatchResponse<E>, InternalError>
where E: EntityKind<Canister = C> + EntityValue,

Update a single-entity-type batch atomically in one commit window.

If any item fails pre-commit validation, no row in the batch is persisted.

This API is not a multi-entity transaction surface.

Source

pub fn update_many_non_atomic<E>( &self, entities: impl IntoIterator<Item = E>, ) -> Result<WriteBatchResponse<E>, InternalError>
where E: EntityKind<Canister = C> + EntityValue,

Update a batch with explicitly non-atomic semantics.

WARNING: fail-fast and non-atomic. Earlier updates may commit before an error.

Source

pub fn insert_view<E>( &self, view: E::ViewType, ) -> Result<E::ViewType, InternalError>
where E: EntityKind<Canister = C> + EntityValue,

Insert one view value and return the stored view.

Source

pub fn replace_view<E>( &self, view: E::ViewType, ) -> Result<E::ViewType, InternalError>
where E: EntityKind<Canister = C> + EntityValue,

Replace one view value and return the stored view.

Source

pub fn update_view<E>( &self, view: E::ViewType, ) -> Result<E::ViewType, InternalError>
where E: EntityKind<Canister = C> + EntityValue,

Update one view value and return the stored view.

Auto Trait Implementations§

§

impl<C> Freeze for DbSession<C>

§

impl<C> !RefUnwindSafe for DbSession<C>

§

impl<C> !Send for DbSession<C>

§

impl<C> !Sync for DbSession<C>

§

impl<C> Unpin for DbSession<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for DbSession<C>

§

impl<C> !UnwindSafe for DbSession<C>

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