mountpoint_s3_fs/
object.rs

1use std::fmt::Debug;
2
3use mountpoint_s3_client::types::ETag;
4
5use crate::sync::Arc;
6
7/// Identifier for a specific version of an S3 object.
8/// Formed by the object key and etag. Holds its components in an [Arc], so it can be cheaply cloned.
9#[derive(Clone, Hash, PartialEq, Eq)]
10pub struct ObjectId {
11    inner: Arc<InnerObjectId>,
12}
13
14impl Debug for ObjectId {
15    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16        f.debug_struct("ObjectId")
17            .field("key", &self.inner.key)
18            .field("etag", &self.inner.etag)
19            .finish()
20    }
21}
22
23#[derive(Debug, Hash, PartialEq, Eq)]
24struct InnerObjectId {
25    key: String,
26    etag: ETag,
27}
28
29impl ObjectId {
30    pub fn new(key: String, etag: ETag) -> Self {
31        Self {
32            inner: Arc::new(InnerObjectId { key, etag }),
33        }
34    }
35
36    pub fn key(&self) -> &str {
37        &self.inner.key
38    }
39
40    pub fn etag(&self) -> &ETag {
41        &self.inner.etag
42    }
43}