Trait 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§