morax_api/property/
storage.rs1use std::fmt;
16
17use serde::Deserialize;
18use serde::Serialize;
19
20#[derive(Debug, Clone, Serialize, Deserialize)]
21#[serde(deny_unknown_fields)]
22pub struct TopicProperty {
23 pub storage: StorageProperty,
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(tag = "scheme")]
28#[serde(deny_unknown_fields)]
29pub enum StorageProperty {
30 #[serde(rename = "s3")]
31 S3(S3StorageProperty),
32}
33
34#[derive(Clone, Serialize, Deserialize)]
35#[serde(deny_unknown_fields)]
36pub struct S3StorageProperty {
37 pub bucket: String,
39 pub region: String,
41 #[serde(default = "default_prefix")]
45 pub prefix: String,
46 pub endpoint: String,
48 pub access_key_id: String,
50 pub secret_access_key: String,
52 #[serde(default = "default_virtual_host_style")]
57 pub virtual_host_style: bool,
58}
59
60impl fmt::Debug for S3StorageProperty {
61 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
62 f.debug_struct("S3Config")
63 .field("prefix", &self.prefix)
64 .field("bucket", &self.bucket)
65 .field("endpoint", &self.endpoint)
66 .field("region", &self.region)
67 .finish_non_exhaustive()
68 }
69}
70
71pub fn default_prefix() -> String {
72 "/".to_string()
73}
74
75pub const fn default_virtual_host_style() -> bool {
76 true
77}