Skip to main content

DynTable

Trait DynTable 

Source
pub trait DynTable:
    Debug
    + Eq
    + Clone
    + PartialEq {
    // Required methods
    fn name(&self) -> &str;
    fn number_of_columns(&self) -> usize;
    fn write_pk_flags(&self, buf: &mut [u8]);
}
Expand description

A table schema known at runtime (object-safe).

While extremely generic, this trait does not provide much type safety.

Required Methods§

Source

fn name(&self) -> &str

The table name.

Source

fn number_of_columns(&self) -> usize

The number of columns in the table.

Source

fn write_pk_flags(&self, buf: &mut [u8])

Write primary key flags to the buffer.

The buffer must have length equal to number_of_columns(). Each byte represents the 1-based ordinal position of the column in the composite primary key, or 0 if the column is not part of the primary key.

For example, for a table with columns (A, B, C) where (B, A) is the PK (B is the first PK column, A is the second), the buffer should be: [2, 1, 0] - A is 2nd in PK order, B is 1st in PK order, C is not PK.

§Panics

Panics if buf.len() != self.number_of_columns().

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: DynTable> DynTable for &T

Source§

fn name(&self) -> &str

Source§

fn number_of_columns(&self) -> usize

Source§

fn write_pk_flags(&self, buf: &mut [u8])

Implementors§