1use core::fmt::Debug as DebugImpl;
2use serde::{Deserialize, Serialize};
3use std::error::Error;
4
5pub trait Params
7where
8 Self: Into<String> + Clone + Copy + DebugImpl + PartialEq + Default,
9{
10}
11
12pub trait Client<P>
14where
15 P: Params,
16 Self: Default,
17{
18 const BASE_URL: &'static str;
20 type Response: for<'de> Deserialize<'de> + Serialize + Clone + DebugImpl + PartialEq;
22
23 fn get(&self, params: P) -> Result<Self::Response, Box<dyn Error>>;
25}
26
27#[cfg(test)]
28mod tests
29{
30 use super::*;
31 use crate::clients::apod::{Apod, ApodParams};
32
33 #[test]
34 fn test_apod()
35 {
36 let apod = Apod::default();
37 let res = apod.get(ApodParams::default());
38 match res
39 {
40 Ok(json) => println!("{:#?}", json),
41 Err(e) =>
42 {
43 println!("{:#?}", e);
44 panic!();
45 }
46 }
47 }
48}