grafos_store/
bucket_config.rs

1//! Bucket configuration types.
2
3extern crate alloc;
4use alloc::string::String;
5
6use serde::{Deserialize, Serialize};
7
8/// Configuration for creating a bucket.
9#[derive(Clone, Debug, Serialize, Deserialize)]
10pub struct BucketConfig {
11    /// Bucket name.
12    pub name: String,
13    /// Storage tier for the bucket.
14    pub tier: BucketTier,
15    /// Hint for expected capacity in bytes (0 = no hint).
16    pub capacity_hint: u64,
17    /// Default TTL in seconds for objects in this bucket.
18    pub ttl_secs: u32,
19    /// Whether to enable object versioning.
20    pub versioning: bool,
21}
22
23/// Storage tier for a bucket.
24#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
25pub enum BucketTier {
26    /// In-memory (DRAM) storage.
27    Memory,
28    /// Durable block storage.
29    Block,
30    /// Tiered: hot (memory) + cold (block).
31    Tiered {
32        /// Hot tier capacity in bytes.
33        hot_bytes: u64,
34        /// Cold tier capacity in blocks.
35        cold_blocks: u64,
36    },
37}
38
39impl Default for BucketConfig {
40    fn default() -> Self {
41        BucketConfig {
42            name: String::new(),
43            tier: BucketTier::Memory,
44            capacity_hint: 0,
45            ttl_secs: 3600,
46            versioning: false,
47        }
48    }
49}
50
51impl BucketConfig {
52    /// Create a new config with the given name.
53    pub fn new(name: &str) -> Self {
54        BucketConfig {
55            name: String::from(name),
56            ..Default::default()
57        }
58    }
59
60    /// Set the storage tier.
61    pub fn tier(mut self, tier: BucketTier) -> Self {
62        self.tier = tier;
63        self
64    }
65
66    /// Set the capacity hint.
67    pub fn capacity_hint(mut self, bytes: u64) -> Self {
68        self.capacity_hint = bytes;
69        self
70    }
71
72    /// Set the TTL in seconds.
73    pub fn ttl_secs(mut self, secs: u32) -> Self {
74        self.ttl_secs = secs;
75        self
76    }
77
78    /// Enable versioning.
79    pub fn versioning(mut self, enabled: bool) -> Self {
80        self.versioning = enabled;
81        self
82    }
83}