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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
use crate::Sample;
pub const OP_CREATE_CONTAINER: &str = "CreateContainer";
pub const OP_REMOVE_CONTAINER: &str = "RemoveContainer";
pub const OP_REMOVE_OBJECT: &str = "RemoveObject";
pub const OP_LIST_OBJECTS: &str = "ListObjects";
pub const OP_UPLOAD_CHUNK: &str = "UploadChunk";
pub const OP_START_DOWNLOAD: &str = "StartDownload";
pub const OP_START_UPLOAD: &str = "StartUpload";
pub const OP_RECEIVE_CHUNK: &str = "ReceiveChunk";
pub const OP_GET_OBJECT_INFO: &str = "GetObjectInfo";
#[derive(Debug, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct FileChunk {
pub sequence_no: u64,
pub container: String,
pub id: String,
pub total_bytes: u64,
pub chunk_size: u64,
#[serde(with = "serde_bytes")]
#[serde(default)]
pub chunk_bytes: Vec<u8>,
}
impl Sample for FileChunk {
fn sample() -> Self {
FileChunk {
sequence_no: 5,
container: "container".to_string(),
id: "blob".to_string(),
total_bytes: 53400,
chunk_size: 1024,
chunk_bytes: vec![1, 2, 3, 4, 5],
}
}
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Container {
pub id: String,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ContainerList {
#[serde(default)]
pub containers: Vec<Container>,
}
impl Sample for ContainerList {
fn sample() -> Self {
ContainerList {
containers: vec![Container {
id: "container".to_string(),
}],
}
}
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Blob {
pub id: String,
pub container: String,
pub byte_size: u64,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BlobList {
#[serde(default)]
pub blobs: Vec<Blob>,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct StreamRequest {
pub id: String,
pub container: String,
pub chunk_size: u64,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Transfer {
pub blob_id: String,
pub container: String,
pub chunk_size: u64,
pub total_size: u64,
pub total_chunks: u64,
}