aboutsummaryrefslogtreecommitdiff
path: root/lockchain-http/src/models/responses.rs
blob: ac4e74b0f138ac15e8e3f3b916b4874f295573a8 (plain)
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
use lockchain::errors::Error as LockError;
use serde::{de::DeserializeOwned, Serialize};

/// A generic container that json/error wraps lockchain-types
///
/// This is heavily used in the lockchain-REST API and can be utilised
/// to send both encrypted and cleartext data via the API endpoint, using
/// the same code.
#[derive(Serialize, Deserialize)]
pub struct CarrierMessage<T: Serialize + DeserializeOwned> {
    pub error: Result<(), LockError>,
    #[serde(bound(deserialize = "T: Serialize + DeserializeOwned"))]
    pub data: Option<T>,
}

/// A simple message that describes an invalid operation
#[derive(Serialize, Deserialize)]
pub struct OperationFailed {
    pub reason: String,
    pub code: u32,
}

/// **Returns** Api information
#[derive(Serialize, Deserialize)]
pub struct ApiInformation {
    pub version: String,
    pub providers: Vec<String>,
    pub hostname: Option<String>,
    pub supported: String,
}

/// **Returns** List existing vaults
#[derive(Serialize, Deserialize)]
pub struct VaultList {
    pub vaults: Vec<String>,
    pub count: usize,
}

/// Response to creating a new vault
#[derive(Serialize, Deserialize)]
pub struct VaultCreateResponse {
    pub name: String,
    pub created: bool,
    pub error: Option<String>,
}