1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
pub mod departure_monitor;
pub mod stop_finder;
pub mod generic;

pub use departure_monitor::{DepartureMonitorRequest, DepartureMonitorRequestBuilder};
pub use stop_finder::{StopFinderRequest, StopFinderRequestBuilder};
//pub use generic::*;

#[cfg(feature = "reqwest")]
use std::future::Future;

const API_ENDPOINT: &'static str = "https://projekte.kvv-efa.de/sl3-alone/";

pub trait Request: Sized + Clone {
    type Builder: Default;
    type Response;

    const REQUEST_TYPE: &'static str;

    fn builder() -> Self::Builder {
        Self::Builder::default()
    }

    fn url(&self) -> &String;
    fn into_url(self) -> String;

    #[cfg(feature = "reqwest")]
    fn get(self) -> impl Future<Output = Result<Self::Response, reqwest::Error>>;
}

pub mod types {
    use std::fmt::Display;

    pub type StationId = i32;
   
    #[derive(Clone, Copy, Debug)]
    pub enum Type {
        Any,
        Stop,
        // TODO: find out other options
    }

    impl Display for Type {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                Self::Stop => write!(f, "stop"),
                Self::Any => write!(f, "any")
            }
        }
    }
}