gcs_rsync/gcp/
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
26
27
28
29
30
31
32
pub mod oauth2;
pub mod storage;
pub mod sync;

#[derive(Debug, Clone)]
pub struct Client {
    pub(self) client: reqwest::Client,
}

#[derive(Debug, serde::Deserialize)]
#[serde(untagged)]
enum DeserializedResponse<T> {
    Success(T),
    Error(serde_json::Value),
}

impl<T> DeserializedResponse<T> {
    pub fn into_result(self) -> Result<T, serde_json::Value> {
        match self {
            DeserializedResponse::Success(x) => Ok(x),
            DeserializedResponse::Error(e) => Err(e),
        }
    }
}

impl Default for Client {
    fn default() -> Self {
        Self {
            client: reqwest::Client::new(),
        }
    }
}