pub struct TableDef {
pub name: String,
pub columns: Vec<ColumnDef>,
pub primary_key: Vec<String>,
pub indexes: Vec<IndexDef>,
pub constraints: Vec<Constraint>,
pub version: u32,
pub created_at: u64,
pub updated_at: u64,
}Expand description
Table definition containing all metadata
Fields§
§name: StringTable name (unique within database)
columns: Vec<ColumnDef>Column definitions in order
primary_key: Vec<String>Primary key column names (can be composite)
indexes: Vec<IndexDef>Index definitions
constraints: Vec<Constraint>Table-level constraints
version: u32Schema version (for migrations)
created_at: u64Creation timestamp
updated_at: u64Last modification timestamp
Implementations§
Source§impl TableDef
impl TableDef
Sourcepub fn add_column(self, column: ColumnDef) -> TableDef
pub fn add_column(self, column: ColumnDef) -> TableDef
Add a column to the table
Sourcepub fn primary_key(self, columns: Vec<String>) -> TableDef
pub fn primary_key(self, columns: Vec<String>) -> TableDef
Set primary key columns
Sourcepub fn add_constraint(self, constraint: Constraint) -> TableDef
pub fn add_constraint(self, constraint: Constraint) -> TableDef
Add a constraint
Sourcepub fn get_column(&self, name: &str) -> Option<&ColumnDef>
pub fn get_column(&self, name: &str) -> Option<&ColumnDef>
Get column by name
Sourcepub fn column_index(&self, name: &str) -> Option<usize>
pub fn column_index(&self, name: &str) -> Option<usize>
Get column index by name
Sourcepub fn is_primary_key_column(&self, name: &str) -> bool
pub fn is_primary_key_column(&self, name: &str) -> bool
Check if a column is part of the primary key
Sourcepub fn validate(&self) -> Result<(), TableDefError>
pub fn validate(&self) -> Result<(), TableDefError>
Validate table definition
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialize table definition to bytes.
The RTBL payload byte layout is owned by reddb-file (ADR 0046); this
projects the typed definition into reddb_file::TableDefLayout, mapping
the SQL-level type/index/constraint enums to their on-disk discriminant
bytes. The framing (magic, version, varints, strings) lives in the codec.
Sourcepub fn from_bytes(data: &[u8]) -> Result<TableDef, TableDefError>
pub fn from_bytes(data: &[u8]) -> Result<TableDef, TableDefError>
Deserialize table definition from bytes via the reddb-file codec.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TableDef
impl RefUnwindSafe for TableDef
impl Send for TableDef
impl Sync for TableDef
impl Unpin for TableDef
impl UnsafeUnpin for TableDef
impl UnwindSafe for TableDef
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request