pub trait ModelInterface {
type Database: SGBD;
type Entity: Unpin + Send + Sync + Serialize + DeserializeOwned;
// Required methods
fn new(database: &Self::Database) -> Self
where Self: Sized;
fn database(&self) -> &Self::Database;
fn table() -> &'static str;
fn fields() -> &'static [&'static str];
fn fetch_all<'c, 'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Entity>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'c: 'async_trait,
'life0: 'async_trait;
fn fetch_all_by_id<'life0, 'async_trait>(
&'life0 self,
id: impl 'async_trait + ToString + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Entity>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn find_by_id<'life0, 'async_trait>(
&'life0 self,
id: impl 'async_trait + ToString + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<Self::Entity, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn create<'life0, 'async_trait>(
&'life0 self,
data: impl 'async_trait + Serialize + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<Self::Entity, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn delete_by_id<'life0, 'async_trait>(
&'life0 self,
id: impl 'async_trait + ToString + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn update_by_id<'life0, 'async_trait>(
&'life0 self,
id: impl 'async_trait + ToString + Send + Sync,
data: impl 'async_trait + Serialize + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<Self::Entity, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Required Associated Types§
Required Methods§
fn database(&self) -> &Self::Database
Sourcefn table() -> &'static str
fn table() -> &'static str
Nom de la table du model, correspondant à un nom de table d’une base de données.
Sourcefn fetch_all<'c, 'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Entity>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'c: 'async_trait,
'life0: 'async_trait,
fn fetch_all<'c, 'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Entity>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'c: 'async_trait,
'life0: 'async_trait,
Récupère tous les résultats de la table Self::table().
Sourcefn fetch_all_by_id<'life0, 'async_trait>(
&'life0 self,
id: impl 'async_trait + ToString + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Entity>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn fetch_all_by_id<'life0, 'async_trait>(
&'life0 self,
id: impl 'async_trait + ToString + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Entity>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Récupère tous les résultats de la table Self::table() en fonction d’un ID.
Sourcefn find_by_id<'life0, 'async_trait>(
&'life0 self,
id: impl 'async_trait + ToString + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<Self::Entity, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn find_by_id<'life0, 'async_trait>(
&'life0 self,
id: impl 'async_trait + ToString + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<Self::Entity, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Cherche dans la table de la base de donnée s’il existe l’ID passé en
argument. En supposant qu’il existe un champ id dans la table.
Sourcefn create<'life0, 'async_trait>(
&'life0 self,
data: impl 'async_trait + Serialize + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<Self::Entity, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create<'life0, 'async_trait>(
&'life0 self,
data: impl 'async_trait + Serialize + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<Self::Entity, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Ajoute une entité en base de données.
Sourcefn delete_by_id<'life0, 'async_trait>(
&'life0 self,
id: impl 'async_trait + ToString + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete_by_id<'life0, 'async_trait>(
&'life0 self,
id: impl 'async_trait + ToString + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Supprime une entité en base de données en fonction d’un ID.
Sourcefn update_by_id<'life0, 'async_trait>(
&'life0 self,
id: impl 'async_trait + ToString + Send + Sync,
data: impl 'async_trait + Serialize + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<Self::Entity, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update_by_id<'life0, 'async_trait>(
&'life0 self,
id: impl 'async_trait + ToString + Send + Sync,
data: impl 'async_trait + Serialize + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<Self::Entity, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Modifie les champs d’une table en base de données.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".