Skip to main content

DatabaseHandle

Struct DatabaseHandle 

Source
pub struct DatabaseHandle { /* private fields */ }
Expand description

A lightweight caller-specific handle onto one shared [DatabaseCore] (spec §10.1, S1A-001).

Obtained from crate::manager::DatabaseManager::open_shared. Cloning or dropping a handle has no storage side effects; storage closes when the last core reference drops or Self::shutdown runs.

Implementations§

Source§

impl DatabaseHandle

Source

pub fn identity(&self) -> &HandleIdentity

The identity bound to this handle.

Source

pub fn access(&self) -> HandleAccess

The access restriction bound to this handle.

Source

pub fn shares_core_with(&self, other: &Self) -> bool

Whether two handles reference the exact same process-local core.

Source

pub fn lifecycle_state(&self) -> LifecycleState

The current lifecycle state of the shared core (S1A-004).

Source

pub fn operation_guard(&self) -> Result<OperationGuard>

Admit one operation against the shared core (S1A-004). The RAII guard releases the operation slot on drop; new operations are rejected once the core leaves LifecycleState::Open.

Source

pub fn query( &self, table: &str, query: &Query, projection: Option<&[u16]>, ) -> Result<Vec<Row>>

Execute an authorized native query with live roles, RLS, masks, and column grants.

Source

pub fn count(&self, table: &str) -> Result<u64>

Count rows visible to this handle after live authorization and RLS.

Source

pub fn rows(&self, table: &str) -> Result<Vec<Row>>

Return all rows visible to this handle after RLS and masks.

Source

pub fn create_table(&self, name: &str, schema: Schema) -> Result<u64>

Create a table through this handle’s live principal.

Source

pub fn put(&self, table: &str, cells: Vec<(u16, Value)>) -> Result<Option<i64>>

Atomically insert one row through this handle’s live principal.

Source

pub fn delete(&self, table: &str, row_id: RowId) -> Result<()>

Atomically delete one row through this handle’s live principal.

Source

pub fn create_user(&self, username: &str, password: &str) -> Result<UserEntry>

Create a catalog user. Admin only.

Source

pub fn drop_user(&self, username: &str) -> Result<()>

Drop a catalog user. Admin only.

Source

pub fn create_role(&self, role: &str) -> Result<RoleEntry>

Create a role. Admin only.

Source

pub fn grant_role(&self, username: &str, role: &str) -> Result<()>

Grant a role to a catalog user. Admin only.

Source

pub fn revoke_role(&self, username: &str, role: &str) -> Result<()>

Revoke a role from a catalog user. Admin only.

Source

pub fn grant_permission(&self, role: &str, permission: Permission) -> Result<()>

Grant one permission to a role. Admin only.

Source

pub fn revoke_permission( &self, role: &str, permission: Permission, ) -> Result<()>

Revoke one permission from a role. Admin only.

Source

pub fn shutdown(&self, drain_deadline: Duration) -> Result<()>

Shut the shared core down (spec §10.1, S1A-004): drain in-flight operations within drain_deadline, sync durable state, release the file lock, and mark the core Closed. Every handle — including this one — then rejects further operations. Dropping a handle never closes storage; only this method or the last core drop does.

Trait Implementations§

Source§

impl Debug for DatabaseHandle

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.