pub struct StorageChunkManager {
pub objects: HashMap<u64, ChunkedObject>,
pub next_object_id: u64,
pub chunk_size_bytes: u64,
}Expand description
Manages splitting large data objects into fixed-size chunks and tracking their metadata for streaming reads and writes.
Fields§
§objects: HashMap<u64, ChunkedObject>Map from object_id to its chunked representation.
next_object_id: u64Counter for assigning monotonically increasing object IDs.
chunk_size_bytes: u64Default chunk size in bytes (1 MB).
Implementations§
Source§impl StorageChunkManager
impl StorageChunkManager
Sourcepub fn new(chunk_size_bytes: u64) -> Self
pub fn new(chunk_size_bytes: u64) -> Self
Creates a new StorageChunkManager with the given chunk size.
Sourcepub fn create_object(&mut self, total_size_bytes: u64) -> u64
pub fn create_object(&mut self, total_size_bytes: u64) -> u64
Splits a data object of total_size_bytes into chunks and registers it.
Returns the assigned object_id.
Sourcepub fn mark_written(&mut self, object_id: u64, chunk_index: u32) -> bool
pub fn mark_written(&mut self, object_id: u64, chunk_index: u32) -> bool
Sets the specified chunk to Written. Returns false if not found.
Sourcepub fn mark_verified(&mut self, object_id: u64, chunk_index: u32) -> bool
pub fn mark_verified(&mut self, object_id: u64, chunk_index: u32) -> bool
Sets the specified chunk to Verified. Returns false if not found.
Sourcepub fn mark_failed(&mut self, object_id: u64, chunk_index: u32) -> bool
pub fn mark_failed(&mut self, object_id: u64, chunk_index: u32) -> bool
Sets the specified chunk to Failed. Returns false if not found.
Sourcepub fn get_object(&self, object_id: u64) -> Option<&ChunkedObject>
pub fn get_object(&self, object_id: u64) -> Option<&ChunkedObject>
Returns a reference to the ChunkedObject if it exists.
Sourcepub fn pending_chunks(&self, object_id: u64) -> Vec<&Chunk>
pub fn pending_chunks(&self, object_id: u64) -> Vec<&Chunk>
Returns all Pending chunks for the given object, sorted by chunk_index.
Sourcepub fn delete_object(&mut self, object_id: u64) -> bool
pub fn delete_object(&mut self, object_id: u64) -> bool
Removes the object from the manager. Returns true if it existed.
Sourcepub fn stats(&self) -> ChunkManagerStats
pub fn stats(&self) -> ChunkManagerStats
Returns aggregate statistics over all tracked objects.
Auto Trait Implementations§
impl Freeze for StorageChunkManager
impl RefUnwindSafe for StorageChunkManager
impl Send for StorageChunkManager
impl Sync for StorageChunkManager
impl Unpin for StorageChunkManager
impl UnsafeUnpin for StorageChunkManager
impl UnwindSafe for StorageChunkManager
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