pub struct SimpleTable { /* private fields */ }Expand description
A simple table schema with column names for SQL generation.
This type wraps TableSchema and adds column names, allowing it to be
used for both binary encoding/decoding and SQL statement digestion.
§Example
use sqlite_diff_rs::SimpleTable;
use sqlite_diff_rs::{PatchSet, DiffSetBuilder};
let table = SimpleTable::new("users", &["id", "name"], &[0]);
let mut patchset = PatchSet::<SimpleTable, String, Vec<u8>>::new();
patchset.add_table(&table);
patchset.digest_sql("INSERT INTO users (id, name) VALUES (1, 'Alice')").unwrap();Implementations§
Source§impl SimpleTable
impl SimpleTable
Sourcepub fn column_names(&self) -> &[String]
pub fn column_names(&self) -> &[String]
Get the column names.
Sourcepub fn column_name(&self, index: usize) -> Option<&str>
pub fn column_name(&self, index: usize) -> Option<&str>
Get a column name by index.
Sourcepub fn column_index(&self, name: &str) -> Option<usize>
pub fn column_index(&self, name: &str) -> Option<usize>
Get the column index by name.
Sourcepub fn pk_indices(&self) -> Vec<usize>
pub fn pk_indices(&self) -> Vec<usize>
Get the indices of primary key columns, in PK order.
Sourcepub fn inner(&self) -> &TableSchema<String>
pub fn inner(&self) -> &TableSchema<String>
Get the inner TableSchema.
Trait Implementations§
Source§impl Clone for SimpleTable
impl Clone for SimpleTable
Source§fn clone(&self) -> SimpleTable
fn clone(&self) -> SimpleTable
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 ColumnNames for SimpleTable
impl ColumnNames for SimpleTable
Source§impl Debug for SimpleTable
impl Debug for SimpleTable
Source§impl DynTable for SimpleTable
impl DynTable for SimpleTable
impl Eq for SimpleTable
Source§impl Hash for SimpleTable
impl Hash for SimpleTable
Source§impl NamedColumns for SimpleTable
impl NamedColumns for SimpleTable
Source§impl PartialEq for SimpleTable
impl PartialEq for SimpleTable
Source§impl SchemaWithPK for SimpleTable
impl SchemaWithPK for SimpleTable
Source§fn number_of_primary_keys(&self) -> usize
fn number_of_primary_keys(&self) -> usize
Returns the number of primary key columns in the schema.
Source§fn primary_key_index(&self, col_idx: usize) -> Option<usize>
fn primary_key_index(&self, col_idx: usize) -> Option<usize>
Returns the primary key index of the primary key by the column index.
Source§fn extract_pk<S, B>(
&self,
values: &impl IndexableValues<Text = S, Binary = B>,
) -> Vec<Value<S, B>>
fn extract_pk<S, B>( &self, values: &impl IndexableValues<Text = S, Binary = B>, ) -> Vec<Value<S, B>>
Extract primary key values from a full row. Read more
Auto Trait Implementations§
impl Freeze for SimpleTable
impl RefUnwindSafe for SimpleTable
impl Send for SimpleTable
impl Sync for SimpleTable
impl Unpin for SimpleTable
impl UnsafeUnpin for SimpleTable
impl UnwindSafe for SimpleTable
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.