septastic/data_loader/src/traits.rs
Nicholas Orlowsky 55df6bdb16
Some checks failed
Create and publish a Docker image / build-and-push-image (push) Has been cancelled
just add data loader here
2025-09-12 19:34:35 -04:00

23 lines
816 B
Rust

use std::collections::HashMap;
use sqlx::{Postgres, Transaction};
pub trait SeptaJson {}
pub trait FromSeptaJson<T: SeptaJson> {
fn from_septa_json(septa_json: T) -> ::anyhow::Result<Box<Self>>;
}
pub trait FromSeptaJsonAndStations<T: SeptaJson> {
fn from_septa_json(septa_json: T, stop_map: &HashMap<String, i64>) -> ::anyhow::Result<Box<Self>>;
}
pub trait DbObj<T> {
fn create_table(tx: &mut Transaction<'_, Postgres>) -> impl std::future::Future< Output = ::anyhow::Result<()>> + Send;
fn insert(&self, tx: &mut Transaction<'_, Postgres>) -> impl std::future::Future< Output = ::anyhow::Result<()>> + Send;
fn insert_many(s: Vec<T>, tx: &mut Transaction<'_, Postgres>) -> impl std::future::Future< Output = ::anyhow::Result<()>> + Send;
}
pub trait Fetchable<T: SeptaJson> {}