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
48
49
50
51
|
use lockchain::errors::Error as LockError;
use serde::{de::DeserializeOwned, Serialize};
use std::error::Error;
use std::fmt::{Debug, Display};
/// 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>
where
T: Serialize + DeserializeOwned,
{
pub error: Result<(), LockError>,
#[serde(bound(deserialize = "T: Serialize + DeserializeOwned"))]
pub data: Option<T>,
}
// pub trait SerialError: Sized + Error + Serialize + DeserializeOwned + Debug + Display {}
/// A simple message that describes an invalid operation
#[derive(Serialize, Deserialize)]
pub struct OperationFailed {
pub reason: String,
pub error: Box<String>,
}
/// Message that returns a token
#[derive(Serialize, Deserialize)]
pub struct TokenMessage {
pub username: String,
pub token: String,
}
/// **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,
}
|