summaryrefslogtreecommitdiff
path: root/rust/scraper/src/database/mod.rs
blob: d712259bb22185e2e15fde5e9962f6b0ec1d47b0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
pub mod postgres;
pub mod error;

pub use error::DatabaseError;

use proto::touchpad::common::v1;

type Result<T> = std::result::Result<T, DatabaseError>;

#[async_trait::async_trait]
pub trait DatabaseClient {
    async fn get_swimmer(&self, id: u32) -> Result<v1::Swimmer>;
    async fn add_swimmer(&self, swimmer: &v1::Swimmer) -> Result<()>;

    async fn get_team(&self, id: u32) -> Result<v1::Team>;
    async fn add_team(&self, team: &v1::Team) -> Result<()>;

    async fn get_meet(&self, id: u32) -> Result<v1::SwimMeet>;
    async fn add_meet(&self, meet: &v1::SwimMeet) -> Result<()>;

    async fn get_event(&self, id: u32) -> Result<v1::Event>;
    async fn get_event_by_number(&self, meet_id: u32, number: u32) -> Result<v1::Event>;
    async fn add_event(&self, event: &v1::Event) -> Result<()>;
}