pub struct TableSchema { /* private fields */ }Expand description
What a table promises about its rows.
Implementations§
Source§impl TableSchema
impl TableSchema
Sourcepub fn new(columns: impl IntoIterator<Item = Column>) -> Self
pub fn new(columns: impl IntoIterator<Item = Column>) -> Self
A strict schema: the listed columns and nothing else.
Strict is the default because it is the one that catches mistakes — a non-strict table quietly accepts a misspelled column name and stores it as an unschematised extra.
Sourcepub fn non_strict(self) -> Self
pub fn non_strict(self) -> Self
Allows rows to carry columns the schema does not mention.
Sourcepub fn with_unique_keys(self, unique: bool) -> Self
pub fn with_unique_keys(self, unique: bool) -> Self
Promises that no two rows share a key.
Only meaningful when the schema has key columns; the cluster enforces it on write.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Checks what the cluster would otherwise reject with error 314.
Every rule here was watched being enforced by a cluster; catching them locally turns a round trip and a nested error document into one sentence naming the column.
§Errors
Returns the reason the schema is invalid.
Trait Implementations§
Source§impl Clone for TableSchema
impl Clone for TableSchema
Source§fn clone(&self) -> TableSchema
fn clone(&self) -> TableSchema
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TableSchema
impl Debug for TableSchema
impl Eq for TableSchema
Source§impl PartialEq for TableSchema
impl PartialEq for TableSchema
impl StructuralPartialEq for TableSchema
Auto Trait Implementations§
impl Freeze for TableSchema
impl RefUnwindSafe for TableSchema
impl Send for TableSchema
impl Sync for TableSchema
impl Unpin for TableSchema
impl UnsafeUnpin for TableSchema
impl UnwindSafe for TableSchema
Blanket Implementations§
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
Mutably borrows from an owned value. Read more