50 lines
2.0 KiB
Rust

use crate::models::client::*;
use crate::models::car_station::*;
use crate::models::car::*;
use crate::models::rent::*;
use async_trait::async_trait;
#[async_trait]
pub trait ClientRepository {
async fn create(&self, client: BindingClient) -> Result<Client, String>;
async fn read(&self, id: u32) -> Result<Client, String>;
async fn read_all(&self) -> Result<Vec<Client>, String>;
async fn update(&self, id: u32, client: BindingClient) -> Result<Client, String>;
async fn delete(&self, id: u32) -> Result<(), String>;
}
#[async_trait]
pub trait CarRepository {
async fn create(&self, car: BindingCar) -> Result<Car, String>;
async fn read(&self, id: u32) -> Result<Car, String>;
async fn read_all(&self) -> Result<Vec<Car>, String>;
async fn update(&self, id: u32, car: BindingCar) -> Result<Car, String>;
async fn delete(&self, id: u32) -> Result<(), String>;
}
#[async_trait]
pub trait CarStationRepository {
async fn create(&self, car_station: BindingCarStation) -> Result<CarStation, String>;
async fn read(&self, id: u32) -> Result<CarStation, String>;
async fn read_all(&self) -> Result<Vec<CarStation>, String>;
async fn update(&self, id: u32, car_station: BindingCarStation) -> Result<CarStation, String>;
async fn delete(&self, id: u32) -> Result<(), String>;
}
#[async_trait]
pub trait RentRepository {
async fn create(&self, rent: BindingRent) -> Result<Rent, String>;
async fn read(&self, id: u32) -> Result<Rent, String>;
async fn read_all(&self) -> Result<Vec<Rent>, String>;
async fn update(&self, id: u32, rent: BindingRent) -> Result<Rent, String>;
async fn delete(&self, id: u32) -> Result<(), String>;
}
#[async_trait]
pub trait OwnerRepository {
async fn create(&self, client: BindingClient) -> Result<Client, String>;
async fn read(&self, id: u32) -> Result<Client, String>;
async fn read_all(&self) -> Result<Vec<Client>, String>;
async fn update(&self, id: u32, client: BindingClient) -> Result<Client, String>;
async fn delete(&self, id: u32) -> Result<(), String>;
}