Files
rustfs/ecstore/src/bucket/encryption/mod.rs
T
2024-10-01 04:35:25 +08:00

43 lines
1.0 KiB
Rust

use serde::{Deserialize, Serialize};
// 定义Algorithm枚举类型
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Algorithm {
AES256,
AWSKms,
}
// 实现从字符串到Algorithm的转换
impl std::str::FromStr for Algorithm {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"AES256" => Ok(Algorithm::AES256),
"aws:kms" => Ok(Algorithm::AWSKms),
_ => Err(format!("未知的 SSE 算法: {}", s)),
}
}
}
// 定义EncryptionAction结构体
#[derive(Debug, Deserialize, Serialize, Default,Clone)]
pub struct EncryptionAction {
algorithm: Option<Algorithm>,
master_key_id: Option<String>,
}
// 定义Rule结构体
#[derive(Debug, Deserialize, Serialize, Default,Clone)]
pub struct Rule {
default_encryption_action: EncryptionAction,
}
// 定义BucketSSEConfig结构体
#[derive(Debug, Deserialize, Serialize, Default,Clone)]
pub struct BucketSSEConfig {
xml_ns: String,
xml_name: String,
rules: Vec<Rule>,
}