pub struct StorageObjectStore {
pub objects: HashMap<u64, StoredObject>,
pub name_index: HashMap<(String, String), u64>,
pub next_object_id: u64,
}Expand description
High-level object store providing named object management, versioning, and metadata-rich retrieval on top of raw block storage.
Fields§
§objects: HashMap<u64, StoredObject>Objects keyed by their numeric id.
name_index: HashMap<(String, String), u64>Index from (namespace, name) to object_id.
next_object_id: u64Counter used to assign the next object id.
Implementations§
Source§impl StorageObjectStore
impl StorageObjectStore
Sourcepub fn create(
&mut self,
name: &str,
namespace: &str,
cid: &str,
size_bytes: u64,
author: &str,
message: &str,
created_at_secs: u64,
) -> u64
pub fn create( &mut self, name: &str, namespace: &str, cid: &str, size_bytes: u64, author: &str, message: &str, created_at_secs: u64, ) -> u64
Creates a new object with version 1 and returns its object_id.
If an object with the same (namespace, name) already exists the existing
object id is returned without creating a duplicate entry.
Sourcepub fn add_version(
&mut self,
object_id: u64,
cid: &str,
size_bytes: u64,
author: &str,
message: &str,
created_at_secs: u64,
) -> bool
pub fn add_version( &mut self, object_id: u64, cid: &str, size_bytes: u64, author: &str, message: &str, created_at_secs: u64, ) -> bool
Appends a new version to an existing object.
The new version number is previous_max_version + 1.
Returns false if the object is not found.
Sourcepub fn get_by_name(&self, namespace: &str, name: &str) -> Option<&StoredObject>
pub fn get_by_name(&self, namespace: &str, name: &str) -> Option<&StoredObject>
Retrieves an object by its (namespace, name) pair.
Sourcepub fn get(&self, object_id: u64) -> Option<&StoredObject>
pub fn get(&self, object_id: u64) -> Option<&StoredObject>
Retrieves an object by its numeric id.
Sourcepub fn delete(&mut self, object_id: u64) -> bool
pub fn delete(&mut self, object_id: u64) -> bool
Deletes an object by id.
Returns false when the object is not found or when it is pinned.
Sourcepub fn pin(&mut self, object_id: u64) -> bool
pub fn pin(&mut self, object_id: u64) -> bool
Pins an object, preventing it from being deleted.
Returns false if the object is not found.
Sourcepub fn unpin(&mut self, object_id: u64) -> bool
pub fn unpin(&mut self, object_id: u64) -> bool
Unpins an object, allowing it to be deleted.
Returns false if the object is not found.
Sourcepub fn add_tag(&mut self, object_id: u64, tag: &str) -> bool
pub fn add_tag(&mut self, object_id: u64, tag: &str) -> bool
Adds a tag to an object (idempotent — duplicate tags are silently ignored).
Returns false if the object is not found.
Sourcepub fn objects_in_namespace(&self, namespace: &str) -> Vec<&StoredObject>
pub fn objects_in_namespace(&self, namespace: &str) -> Vec<&StoredObject>
Returns all objects in the given namespace, sorted ascending by name.
Sourcepub fn objects_with_tag(&self, tag: &str) -> Vec<&StoredObject>
pub fn objects_with_tag(&self, tag: &str) -> Vec<&StoredObject>
Returns all objects that carry the given tag, sorted ascending by object_id.
Sourcepub fn stats(&self) -> ObjectStoreStats
pub fn stats(&self) -> ObjectStoreStats
Computes aggregate statistics for the entire store.
Trait Implementations§
Source§impl Debug for StorageObjectStore
impl Debug for StorageObjectStore
Source§impl Default for StorageObjectStore
impl Default for StorageObjectStore
Source§fn default() -> StorageObjectStore
fn default() -> StorageObjectStore
Auto Trait Implementations§
impl Freeze for StorageObjectStore
impl RefUnwindSafe for StorageObjectStore
impl Send for StorageObjectStore
impl Sync for StorageObjectStore
impl Unpin for StorageObjectStore
impl UnsafeUnpin for StorageObjectStore
impl UnwindSafe for StorageObjectStore
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more