grafos_store/
bucket_handle.rs

1//! Typed handle for an open bucket.
2
3extern crate alloc;
4use alloc::string::String;
5
6use crate::bucket_config::BucketTier;
7use crate::uri::FabricUri;
8
9/// A handle to an open bucket, providing identity and generation tracking.
10pub struct BucketHandle {
11    pub(crate) name: String,
12    pub(crate) pool: String,
13    pub(crate) tier: BucketTier,
14    pub(crate) created_at: u64,
15    pub(crate) generation: u64,
16}
17
18impl BucketHandle {
19    /// Bucket name.
20    pub fn name(&self) -> &str {
21        &self.name
22    }
23
24    /// Pool name.
25    pub fn pool(&self) -> &str {
26        &self.pool
27    }
28
29    /// Storage tier.
30    pub fn tier(&self) -> &BucketTier {
31        &self.tier
32    }
33
34    /// Creation timestamp (unix seconds).
35    pub fn created_at(&self) -> u64 {
36        self.created_at
37    }
38
39    /// Bucket generation (incremented on recreate).
40    pub fn generation(&self) -> u64 {
41        self.generation
42    }
43
44    /// Build a FabricUri for a key within this bucket.
45    pub fn uri(&self, key: &str) -> Result<FabricUri, grafos_std::error::FabricError> {
46        FabricUri::new(&self.pool, &self.name, key)
47    }
48}