xt_oss/oss/
entities.rs

1use crate::oss;
2use serde::{Deserialize, Serialize};
3use std::fmt;
4
5pub mod acceleration;
6pub mod acl;
7pub mod bucket;
8pub mod callback;
9pub mod cname;
10pub mod cors;
11pub mod encryption;
12pub mod lifecycle;
13pub mod log;
14pub mod multi_upload;
15pub mod object;
16pub mod referer;
17pub mod region;
18pub mod style;
19pub mod tag;
20pub mod version;
21pub mod website;
22pub mod worm;
23pub mod payment;
24
25pub enum Directive {
26    COPY,
27    REPLACE,
28}
29
30impl fmt::Display for Directive {
31    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32        write!(
33            f,
34            "{}",
35            match self {
36                Self::COPY => "COPY",
37                Self::REPLACE => "REPLACE",
38            }
39        )
40    }
41}
42
43#[derive(Debug, Default, Clone, Serialize, Deserialize)]
44pub enum Status {
45    Enabled,
46    #[default]
47    Disabled,
48}
49
50impl fmt::Display for Status {
51    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
52        let desc = match self {
53            Self::Enabled => "Enabled",
54            Self::Disabled => "Disabled",
55        };
56        write!(f, "{}", desc)
57    }
58}
59
60/// 指定存储空间的数据容灾类型
61#[derive(Debug, Serialize, Deserialize, Default, Clone)]
62#[serde(tag = "DataRedundancyType")]
63pub enum DataRedundancyType {
64    /// 本地冗余LRS将您的数据冗余存储在同一个可用区的不同存储设备上,可支持两个存储设备并发损坏时,仍维持数据不丢失,可正常访问
65    #[default]
66    LRS,
67    /// 同城冗余ZRS采用多可用区(AZ)内的数据冗余存储机制,将用户的数据冗余存储在同一地域(Region)的多个可用区。当某个可用区不可用时,仍然能够保障数据的正常访问
68    ZRS,
69}
70
71#[derive(Debug, Default, Clone, Copy)]
72pub enum OssAcl {
73    PublicReadWrite,
74    #[default]
75    PublicRead,
76    Private,
77}
78
79impl fmt::Display for OssAcl {
80    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
81        let desc = match self {
82            Self::PublicRead => "public-read",
83            Self::PublicReadWrite => "public-read-write",
84            Self::Private => "private",
85        };
86        write!(f, "{}", desc)
87    }
88}
89
90#[derive(Debug, Serialize, Deserialize, Default, Clone)]
91pub enum ObjectACL {
92    #[default]
93    Default,
94    PublicReadWrite,
95    PublicRead,
96    Private,
97}
98
99impl fmt::Display for ObjectACL {
100    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
101        let value = match self {
102            Self::Default => "default",
103            Self::PublicReadWrite => "public-read-write",
104            Self::PublicRead => "public-read",
105            Self::Private => "private",
106        };
107        write!(f, "{}", value)
108    }
109}
110
111/// OSS 存储类型
112#[derive(Debug, Serialize, Deserialize, Default, Clone)]
113pub enum StorageClass {
114    /// 标准存储
115    #[default]
116    Standard,
117    /// 低频访问存储
118    IA,
119    /// 归档存储
120    Archive,
121    /// 冷归档存储
122    ColdArchive,
123    /// 深度冷归档存储
124    DeepColdArchive,
125}
126
127impl fmt::Display for StorageClass {
128    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
129        write!(
130            f,
131            "{}",
132            match self {
133                Self::Standard => "Standard",
134                Self::IA => "IA",
135                Self::Archive => "Archive",
136                Self::ColdArchive => "ColdArchive",
137                Self::DeepColdArchive => "DeepColdArchive",
138            }
139        )
140    }
141}
142
143#[derive(Debug, Serialize, Deserialize, Default, Clone)]
144pub enum ServerSideEncryption {
145    //使用OSS完全托管密钥进行加解密(SSE-OSS)。
146    #[default]
147    AES256,
148    // 使用KMS托管密钥进行加解密。
149    KMS,
150    // 国密SM4算法。
151    SM4,
152}
153
154impl fmt::Display for ServerSideEncryption {
155    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
156        write!(
157            f,
158            "{}",
159            match self {
160                Self::AES256 => "AES256",
161                Self::KMS => "KMS",
162                Self::SM4 => "SM$",
163            }
164        )
165    }
166}