kvv_efa_api/request/
mod.rs

1pub mod departure_monitor;
2pub mod stop_finder;
3pub mod generic;
4
5pub use departure_monitor::{DepartureMonitorRequest, DepartureMonitorRequestBuilder};
6pub use stop_finder::{StopFinderRequest, StopFinderRequestBuilder};
7//pub use generic::*;
8
9#[cfg(feature = "reqwest")]
10use std::future::Future;
11
12const API_ENDPOINT: &'static str = "https://projekte.kvv-efa.de/sl3-alone/";
13
14pub trait Request: Sized + Clone {
15    type Builder: Default;
16    type Response;
17
18    const REQUEST_TYPE: &'static str;
19
20    fn builder() -> Self::Builder {
21        Self::Builder::default()
22    }
23
24    fn url(&self) -> &String;
25    fn into_url(self) -> String;
26
27    #[cfg(feature = "reqwest")]
28    fn get(self) -> impl Future<Output = Result<Self::Response, reqwest::Error>>;
29}
30
31pub mod types {
32    use std::fmt::Display;
33
34    pub type StationId = i32;
35   
36    #[derive(Clone, Copy, Debug)]
37    pub enum Type {
38        Any,
39        Stop,
40        // TODO: find out other options
41    }
42
43    impl Display for Type {
44        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
45            match self {
46                Self::Stop => write!(f, "stop"),
47                Self::Any => write!(f, "any")
48            }
49        }
50    }
51}
52