Trait TableSchema

Source
pub trait TableSchema:
    Send
    + Sync
    + 'static {
    type P: PartitionKey;
    type S: SortKey;
    type E: Entry<Self::P, Self::S>;
    type Filter: Clone + Serialize + for<'de> Deserialize<'de> + Send + Sync + 'static;

    const TABLE_NAME: &'static str;

    // Required method
    fn matches_filter(entry: &Self::E, filter: &Self::Filter) -> bool;

    // Provided method
    fn updated(
        &self,
        _tx: &mut Transaction<'_>,
        _old: Option<&Self::E>,
        _new: Option<&Self::E>,
    ) -> TxOpResult<()> { ... }
}
Expand description

Trait for the schema used in a table

Required Associated Constants§

Source

const TABLE_NAME: &'static str

The name of the table in the database

Required Associated Types§

Source

type P: PartitionKey

The partition key used in that table

Source

type S: SortKey

The sort key used int that table

Source

type E: Entry<Self::P, Self::S>

They type for an entry in that table

Source

type Filter: Clone + Serialize + for<'de> Deserialize<'de> + Send + Sync + 'static

The type for a filter that can be applied to select entries (e.g. filter out deleted entries)

Required Methods§

Source

fn matches_filter(entry: &Self::E, filter: &Self::Filter) -> bool

Provided Methods§

Source

fn updated( &self, _tx: &mut Transaction<'_>, _old: Option<&Self::E>, _new: Option<&Self::E>, ) -> TxOpResult<()>

Actions triggered by data changing in a table. If such actions include updates to the local database that should be applied atomically with the item update itself, a db transaction is provided on which these changes should be done. This function can return a DB error but that’s all.

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§