TableStorage

Struct TableStorage 

Source
pub struct TableStorage<'a, 'txn, T: KVTransaction<'txn>> { /* private fields */ }
Expand description

TableStorage provides CRUD and scan operations over a table backed by a KV store.

The two lifetime parameters serve distinct purposes:

  • 'a: The borrow duration of the transaction reference
  • 'txn: The lifetime parameter of the KVTransaction type itself

This separation is necessary to allow SqlTransaction to return TableStorage instances while maintaining proper lifetime relationships with GATs.

Implementations§

Source§

impl<'a, 'txn, T: KVTransaction<'txn>> TableStorage<'a, 'txn, T>

Source

pub fn new(txn: &'a mut T, table_meta: &TableMetadata) -> Self

Create a new TableStorage wrapper for a given table.

The table_id is obtained from table_meta.table_id.

Source

pub fn insert(&mut self, row_id: u64, row: &[SqlValue]) -> Result<()>

Insert a row by RowID, enforcing primary key and NOT NULL constraints.

Source

pub fn get(&mut self, row_id: u64) -> Result<Option<Vec<SqlValue>>>

Get a row by RowID.

Source

pub fn update(&mut self, row_id: u64, row: &[SqlValue]) -> Result<()>

Update an existing row by RowID.

Source

pub fn delete(&mut self, row_id: u64) -> Result<()>

Delete a row by RowID.

Source

pub fn scan(&mut self) -> Result<TableScanIterator<'_>>

Scan all rows in the table.

Source

pub fn range_scan( &mut self, start_row_id: u64, end_row_id: u64, ) -> Result<TableScanIterator<'_>>

Scan rows in the half-open RowID range [start_row_id, end_row_id].

Source

pub fn next_row_id(&mut self) -> Result<u64>

Get the next auto-increment RowID, incrementing the stored sequence.

Auto Trait Implementations§

§

impl<'a, 'txn, T> Freeze for TableStorage<'a, 'txn, T>

§

impl<'a, 'txn, T> RefUnwindSafe for TableStorage<'a, 'txn, T>
where T: RefUnwindSafe,

§

impl<'a, 'txn, T> Send for TableStorage<'a, 'txn, T>
where T: Send,

§

impl<'a, 'txn, T> Sync for TableStorage<'a, 'txn, T>
where T: Sync,

§

impl<'a, 'txn, T> Unpin for TableStorage<'a, 'txn, T>

§

impl<'a, 'txn, T> !UnwindSafe for TableStorage<'a, 'txn, T>

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,