ali_oss/types/
bucket_stat.rs1use anyhow::Ok;
2
3#[derive(Debug, Clone)]
4pub struct BucketStat {
5 pub storage: u64,
6 pub object_count: u64,
7 pub multipart_upload_count: u64,
8 pub live_channel_count: u64,
9 pub last_modified_time: chrono::DateTime<chrono::Utc>,
10 pub standard_storage: u64,
11 pub standard_object_count: u64,
12 pub infrequent_access_storage: u64,
13 pub infrequent_access_object_count: u64,
14 pub archive_storage: u64,
15 pub archive_real_storage: u64,
16 pub archive_object_count: u64,
17 pub cold_archive_storage: u64,
18 pub cold_archive_real_storage: u64,
19 pub cold_archive_object_count: u64,
20 pub deep_cold_archive_storage: u64,
21 pub deep_cold_archive_real_storage: u64,
22 pub deep_cold_archive_object_count: u64,
23}
24
25impl BucketStat {
26 pub fn new_from_xml_node(node: roxmltree::Node) -> anyhow::Result<Self> {
27 let storage = node.descendants().find(|n| n.has_tag_name("Storage")).and_then(|node| node.text()).unwrap_or("").parse()?;
28 let object_count = node.descendants().find(|n| n.has_tag_name("ObjectCount")).and_then(|node| node.text()).unwrap_or("").parse()?;
29 let multipart_upload_count = node.descendants().find(|n| n.has_tag_name("MultipartUploadCount")).and_then(|node| node.text()).unwrap_or("").parse()?;
30 let live_channel_count = node.descendants().find(|n| n.has_tag_name("LiveChannelCount")).and_then(|node| node.text()).unwrap_or("").parse()?;
31 let last_modified_time = {
32 let seconds: i64 = node.descendants().find(|n| n.has_tag_name("LastModifiedTime")).and_then(|node| node.text()).unwrap_or("").parse()?;
33 chrono::DateTime::from_timestamp(seconds, 0).unwrap()
34 };
35 let standard_storage = node.descendants().find(|n| n.has_tag_name("StandardStorage")).and_then(|node| node.text()).unwrap_or("").parse()?;
36 let standard_object_count = node.descendants().find(|n| n.has_tag_name("StandardObjectCount")).and_then(|node| node.text()).unwrap_or("").parse()?;
37 let infrequent_access_storage = node.descendants().find(|n| n.has_tag_name("InfrequentAccessStorage")).and_then(|node| node.text()).unwrap_or("").parse()?;
38 let infrequent_access_object_count = node.descendants().find(|n| n.has_tag_name("InfrequentAccessObjectCount")).and_then(|node| node.text()).unwrap_or("").parse()?;
39 let archive_storage = node.descendants().find(|n| n.has_tag_name("ArchiveStorage")).and_then(|node| node.text()).unwrap_or("").parse()?;
40 let archive_real_storage = node.descendants().find(|n| n.has_tag_name("ArchiveRealStorage")).and_then(|node| node.text()).unwrap_or("").parse()?;
41 let archive_object_count = node.descendants().find(|n| n.has_tag_name("ArchiveObjectCount")).and_then(|node| node.text()).unwrap_or("").parse()?;
42 let cold_archive_storage = node.descendants().find(|n| n.has_tag_name("ColdArchiveStorage")).and_then(|node| node.text()).unwrap_or("").parse()?;
43 let cold_archive_real_storage = node.descendants().find(|n| n.has_tag_name("ColdArchiveRealStorage")).and_then(|node| node.text()).unwrap_or("").parse()?;
44 let cold_archive_object_count = node.descendants().find(|n| n.has_tag_name("ColdArchiveObjectCount")).and_then(|node| node.text()).unwrap_or("").parse()?;
45 let deep_cold_archive_storage = node.descendants().find(|n| n.has_tag_name("DeepColdArchiveStorage")).and_then(|node| node.text()).unwrap_or("").parse()?;
46 let deep_cold_archive_real_storage = node.descendants().find(|n| n.has_tag_name("DeepColdArchiveRealStorage")).and_then(|node| node.text()).unwrap_or("").parse()?;
47 let deep_cold_archive_object_count = node.descendants().find(|n| n.has_tag_name("DeepColdArchiveObjectCount")).and_then(|node| node.text()).unwrap_or("").parse()?;
48
49 Ok(Self {
50 storage,
51 object_count,
52 multipart_upload_count,
53 live_channel_count,
54 last_modified_time,
55 standard_storage,
56 standard_object_count,
57 infrequent_access_storage,
58 infrequent_access_object_count,
59 archive_storage,
60 archive_real_storage,
61 archive_object_count,
62 cold_archive_storage,
63 cold_archive_real_storage,
64 cold_archive_object_count,
65 deep_cold_archive_storage,
66 deep_cold_archive_real_storage,
67 deep_cold_archive_object_count,
68 })
69 }
70}