Skip to main content

AutoincrementLedger

Struct AutoincrementLedger 

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

Ledger for autoincrement values, used by tables with autoincrement columns.

Implementations§

Source§

impl AutoincrementLedger

Source

pub fn init<TS>(page: Page, mm: &mut impl MemoryAccess) -> MemoryResult<Self>
where TS: TableSchema,

Initialize the AutoincrementLedger for the given table schema, and write it to the given page.

Each autoincrement column in the table schema will be initialized in the registry with the appropriate zero value.

§Errors

Returns MemoryError::ConstraintViolation if the autoincrement columns do not fit the registry encoding (see Self::validate), or any error raised while writing the registry page.

Source

pub fn init_from_snapshot( page: Page, snapshot: &TableSchemaSnapshot, mm: &mut impl MemoryAccess, ) -> MemoryResult<Self>

Initialize the AutoincrementLedger for the table described by snapshot, and write it to the given page.

Snapshot counterpart of Self::init, used when a table is created from a stored TableSchemaSnapshot rather than a compiled TableSchema.

§Errors

Returns MemoryError::ConstraintViolation if an autoincrement column is not an integer or does not fit the registry encoding (see Self::validate_snapshot), or any error raised while writing the registry page.

Source

pub fn validate<TS>() -> MemoryResult<()>
where TS: TableSchema,

Checks that the autoincrement columns of TS fit the registry encoding, so Self::init cannot persist truncated metadata.

Callers should run this before allocating any page for the table.

§Errors

Returns MemoryError::ConstraintViolation if there are more than 255 autoincrement columns or a column name is longer than 255 bytes.

Source

pub fn validate_snapshot(snapshot: &TableSchemaSnapshot) -> MemoryResult<()>

Checks that every autoincrement column of snapshot has an integer type and fits the registry encoding, so Self::init_from_snapshot cannot fail on it.

Callers should run this before allocating any page for the table.

§Errors

Returns MemoryError::ConstraintViolation if an autoincrement column is not an integer, there are more than 255 autoincrement columns, or a column name is longer than 255 bytes.

Source

pub fn load(page: Page, mm: &mut impl MemoryAccess) -> MemoryResult<Self>

Load the AutoincrementLedger from the given page.

Source

pub fn next( &mut self, column: &str, mm: &mut impl MemoryAccess, ) -> MemoryResult<Value>

Returns the next autoincrement Value for the given column, and persists the updated registry to memory.

§Errors

Returns MemoryError::AutoincrementOverflow if the column has reached its maximum value.

Trait Implementations§

Source§

impl Debug for AutoincrementLedger

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