Skip to main content

Table

Struct Table 

Source
pub struct Table {
    pub id: TableId,
    pub name: String,
    pub columns: Vec<Column>,
    pub column_indices: HashMap<String, usize>,
    pub primary_key_columns: Vec<usize>,
    pub secondary_indexes: Vec<SecondaryIndex>,
    pub check_constraints: Vec<CheckConstraint>,
    pub foreign_keys: Vec<ForeignKeyConstraint>,
    pub root_page_id: u32,
    pub primary_key_index_root_page_id: u32,
}

Fields§

§id: TableId§name: String§columns: Vec<Column>§column_indices: HashMap<String, usize>§primary_key_columns: Vec<usize>§secondary_indexes: Vec<SecondaryIndex>§check_constraints: Vec<CheckConstraint>§foreign_keys: Vec<ForeignKeyConstraint>§root_page_id: u32§primary_key_index_root_page_id: u32

Implementations§

Source§

impl Table

Source

pub fn new( id: TableId, name: String, columns: Vec<Column>, root_page_id: u32, ) -> Result<Self>

Source

pub fn get_column_by_name(&self, name: &str) -> Option<&Column>

Source

pub fn get_column_index(&self, name: &str) -> Option<usize>

Source

pub fn column_count(&self) -> usize

Source

pub fn primary_key_count(&self) -> usize

Source

pub fn validate_row(&self, values: &[Value]) -> Result<()>

Source

pub fn get_primary_key_values(&self, values: &[Value]) -> Result<Vec<Value>>

Source

pub fn row_size(&self) -> usize

Source

pub fn get_secondary_index(&self, name: &str) -> Option<&SecondaryIndex>

Source

pub fn add_secondary_index(&mut self, index: SecondaryIndex) -> Result<()>

Source

pub fn list_named_constraints(&self) -> Vec<NamedConstraint>

Source

pub fn named_constraint(&self, name: &str) -> Option<NamedConstraint>

Source

pub fn add_column(&mut self, column: Column) -> Result<()>

Source

pub fn rename_column(&mut self, old_name: &str, new_name: String) -> Result<()>

Source

pub fn drop_column(&mut self, name: &str) -> Result<usize>

Source

pub fn set_column_default( &mut self, name: &str, default_value: Option<Value>, ) -> Result<()>

Source

pub fn set_column_nullable(&mut self, name: &str, nullable: bool) -> Result<()>

Source

pub fn rewrite_inbound_referenced_column( &mut self, referenced_table: &str, old_name: &str, new_name: &str, )

Source

pub fn add_check_constraint( &mut self, constraint: CheckConstraint, ) -> Result<()>

Source

pub fn add_foreign_key( &mut self, constraint: ForeignKeyConstraint, ) -> Result<()>

Source

pub fn drop_secondary_index(&mut self, name: &str) -> Result<SecondaryIndex>

Source

pub fn drop_named_constraint( &mut self, name: &str, ) -> Result<NamedConstraintKind>

Source

pub fn serialize(&self, buffer: &mut Vec<u8>) -> Result<()>

Source

pub fn deserialize(buffer: &[u8], offset: &mut usize) -> Result<Self>

Source

pub fn to_bytes(&self) -> Result<Vec<u8>>

Convert table to bytes for storage in schema B-tree

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self>

Create table from bytes stored in schema B-tree

Trait Implementations§

Source§

impl Clone for Table

Source§

fn clone(&self) -> Table

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Table

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Table

§

impl RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl UnsafeUnpin for Table

§

impl UnwindSafe for Table

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.