pub trait SchemaWithPK:
DynTable
+ Clone
+ Hash {
// Required methods
fn number_of_primary_keys(&self) -> usize;
fn primary_key_index(&self, col_idx: usize) -> Option<usize>;
fn extract_pk<S: Clone, B: Clone>(
&self,
values: &impl IndexableValues<Text = S, Binary = B>,
) -> Vec<Value<S, B>>;
}Expand description
Extension trait for schemas with typed primary key extraction.
This trait is NOT object-safe due to the associated type.
Use DynTable with the extract_pk method for dynamic dispatch.
§Type Parameter
The PrimaryKeyValue type varies by schema:
- For
TableSchemaimplementors: derived from<PrimaryKey as NestedColumns>::NestedValues, e.g.,(i64,)or(i64, String) - For
Box<dyn DynTable>:Vec<Value>(runtime, unknown structure)
Required Methods§
Sourcefn number_of_primary_keys(&self) -> usize
fn number_of_primary_keys(&self) -> usize
Returns the number of primary key columns in the schema.
Sourcefn 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.
Sourcefn extract_pk<S: Clone, B: Clone>(
&self,
values: &impl IndexableValues<Text = S, Binary = B>,
) -> Vec<Value<S, B>>
fn extract_pk<S: Clone, B: Clone>( &self, values: &impl IndexableValues<Text = S, Binary = B>, ) -> Vec<Value<S, B>>
Extract primary key values from a full row.
The values slice must have length equal to number_of_columns().
Returns the PK values in column order, typed appropriately.
§Panics
Panics if the values collection is shorter than the schema’s column count.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".