firefly_iii_rust/requests/
mod.rs

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
use serde::Serialize;
use serde::de::DeserializeOwned;
use std::borrow::Cow;
use std::collections::HashMap;
use crate::http::Method;

/// This trait is the generic implementation for every request
/// we make to the Firefly III API, you can set the Body to `()`
/// in case the request does not send a body.
/// Responses are in the response module.
pub trait Request {
    type Body: Serialize + std::fmt::Debug;
    type Response: DeserializeOwned + Default;
    const METHOD: Method;
    fn endpoint(&self) -> Cow<str>;
    
    fn headers(&self) -> HashMap<String, String> {
        HashMap::new()
    }

    fn body(&self) -> Option<Self::Body> {
        None
    }
}