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
use std::str::FromStr;
use Error;
pub type ObjectId = String;
#[derive(
Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize,
)]
pub struct ObjectVersion(pub u64);
impl FromStr for ObjectVersion {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
track!(s.parse::<u64>().map(ObjectVersion).map_err(Error::from))
}
}
#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct ObjectPrefix(pub String);
#[derive(Debug, Clone, Serialize, Deserialize)]
#[allow(missing_docs)]
pub struct ObjectSummary {
pub id: String,
pub version: ObjectVersion,
}
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct Metadata {
pub version: ObjectVersion,
pub data: Vec<u8>,
}
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct DeleteObjectsByPrefixSummary {
#[serde(with = "prefix_summary_total")]
pub total: u64,
}
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct FragmentsSummary {
pub is_corrupted: bool,
pub found_total: u8,
pub lost_total: u8,
}
mod prefix_summary_total {
use serde::{de, Deserialize, Deserializer, Serializer};
use std::fmt::Display;
use std::str::FromStr;
#[allow(clippy::trivially_copy_pass_by_ref)]
pub fn serialize<S>(x: &u64, s: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
s.serialize_str(&x.to_string())
}
pub fn deserialize<'de, T, D>(deserializer: D) -> Result<T, D::Error>
where
T: FromStr,
T::Err: Display,
D: Deserializer<'de>,
{
String::deserialize(deserializer)?
.parse()
.map_err(de::Error::custom)
}
}