Trait b_table::Schema

source ·
pub trait Schema: Eq + Send + Sync + Sized + Debug {
    type Id: Hash + Eq + Clone + Send + Sync + Debug + Display + 'static;
    type Error: Error + From<Error>;
    type Value: Clone + Eq + Send + Sync + Debug + 'static;
    type Index: IndexSchema<Error = Self::Error, Id = Self::Id, Value = Self::Value> + Send + Sync + 'static;

    // Required methods
    fn key(&self) -> &[Self::Id];
    fn values(&self) -> &[Self::Id];
    fn primary(&self) -> &Self::Index;
    fn auxiliary(&self) -> &[(String, Self::Index)];
    fn validate_key(
        &self,
        key: Vec<Self::Value>
    ) -> Result<Vec<Self::Value>, Self::Error>;
    fn validate_values(
        &self,
        values: Vec<Self::Value>
    ) -> Result<Vec<Self::Value>, Self::Error>;
}
Expand description

The schema of a [Table]

Required Associated Types§

source

type Id: Hash + Eq + Clone + Send + Sync + Debug + Display + 'static

The type of human-readable identifier used by columns and indices in this Schema

source

type Error: Error + From<Error>

The type of validation error used by this Schema

source

type Value: Clone + Eq + Send + Sync + Debug + 'static

The type of column value used by a [Table] with this Schema

source

type Index: IndexSchema<Error = Self::Error, Id = Self::Id, Value = Self::Value> + Send + Sync + 'static

The type of schema used by the indices which compose a [Table] with this Schema

Required Methods§

source

fn key(&self) -> &[Self::Id]

Borrow the names of the columns in the primary key.

source

fn values(&self) -> &[Self::Id]

Borrow the names of the value columns.

source

fn primary(&self) -> &Self::Index

Borrow the schema of the primary index.

source

fn auxiliary(&self) -> &[(String, Self::Index)]

Borrow the schemata of the auxiliary indices. This is ordered so that the first index which matches a given Range will be used.

source

fn validate_key( &self, key: Vec<Self::Value> ) -> Result<Vec<Self::Value>, Self::Error>

Check that the given key is a valid primary key for a [Table] with this Schema.

source

fn validate_values( &self, values: Vec<Self::Value> ) -> Result<Vec<Self::Value>, Self::Error>

Check that the given values are valid for a row in a [Table] with this Schema.

Object Safety§

This trait is not object safe.

Implementors§