firefly_iii_rust/requests/
mod.rs

1use serde::Serialize;
2use serde::de::DeserializeOwned;
3use std::borrow::Cow;
4use std::collections::HashMap;
5use crate::http::Method;
6
7/// This trait is the generic implementation for every request
8/// we make to the Firefly III API, you can set the Body to `()`
9/// in case the request does not send a body.
10/// Responses are in the response module.
11pub trait Request {
12    type Body: Serialize + std::fmt::Debug;
13    type Response: DeserializeOwned + Default;
14    const METHOD: Method;
15    fn endpoint(&self) -> Cow<str>;
16    
17    fn headers(&self) -> HashMap<String, String> {
18        HashMap::new()
19    }
20
21    fn body(&self) -> Option<Self::Body> {
22        None
23    }
24}
25