Trait Sqlable

Source
pub trait Sqlable {
    type Item;
    type Error;
    type Selector;

    // Required methods
    fn count(&self, s: Self::Selector) -> Result<usize, Self::Error>;
    fn select(&self, s: Self::Selector) -> Result<Vec<Self::Item>, Self::Error>;
    fn insert(&mut self, item: Self::Item) -> Result<Self::Item, Self::Error>;
    fn update(
        &mut self,
        s: Self::Selector,
        item: Self::Item,
    ) -> Result<Self::Item, Self::Error>;
    fn delete(&mut self, s: Self::Selector) -> Result<(), Self::Error>;
    fn delete_table(&mut self) -> Result<(), Self::Error>;
}
Expand description

Definition of Sqlable trait to be implemented to allow interaction with SQL tables.

Required Associated Types§

Source

type Item

Defines the struct corresponding to the items in the SQL table

Source

type Error

Defines the struct used for returning errors

Source

type Selector

Defines the struct used for providing selection, filtering to the implementation of the trait

Required Methods§

Source

fn count(&self, s: Self::Selector) -> Result<usize, Self::Error>

Count the number of items in the table meeting the selector requirements

Source

fn select(&self, s: Self::Selector) -> Result<Vec<Self::Item>, Self::Error>

Retrieve the array of items in the table meeting the selector requirements

Source

fn insert(&mut self, item: Self::Item) -> Result<Self::Item, Self::Error>

Insert a new item in the table and returned the inserted item.

Source

fn update( &mut self, s: Self::Selector, item: Self::Item, ) -> Result<Self::Item, Self::Error>

Update items meeting the selector requirements with the values of the provided item. Returns the array of items modified with their updated value

Source

fn delete(&mut self, s: Self::Selector) -> Result<(), Self::Error>

Delete items in the table meeting the selector requirements

Source

fn delete_table(&mut self) -> Result<(), Self::Error>

Delete the table from the database

Implementors§