pub struct ChunkedFileBuffer {
pub storage: Vec<u8>,
pub chunk_size: usize,
pub read_pos: usize,
pub write_pos: usize,
pub bytes_written: usize,
}Expand description
Chunked file reader/writer that processes data in fixed-size blocks.
Suitable for large datasets that exceed available memory. Both reading and writing are abstracted as in-memory operations (no actual file I/O in this mock implementation).
Fields§
§storage: Vec<u8>Underlying byte storage (simulates a file).
chunk_size: usizeChunk size in bytes.
read_pos: usizeCurrent read position.
write_pos: usizeCurrent write position.
bytes_written: usizeTotal bytes written.
Implementations§
Source§impl ChunkedFileBuffer
impl ChunkedFileBuffer
Sourcepub fn write_chunk(&mut self, data: &[u8])
pub fn write_chunk(&mut self, data: &[u8])
Write a chunk of data to the buffer.
Sourcepub fn read_chunk(&mut self) -> Option<Vec<u8>>
pub fn read_chunk(&mut self) -> Option<Vec<u8>>
Read the next chunk. Returns None if no more data.
Sourcepub fn available_chunks(&self) -> usize
pub fn available_chunks(&self) -> usize
Number of full chunks available for reading.
Sourcepub fn reset_read(&mut self)
pub fn reset_read(&mut self)
Reset read cursor to beginning.
Sourcepub fn stored_bytes(&self) -> usize
pub fn stored_bytes(&self) -> usize
Total bytes stored.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ChunkedFileBuffer
impl RefUnwindSafe for ChunkedFileBuffer
impl Send for ChunkedFileBuffer
impl Sync for ChunkedFileBuffer
impl Unpin for ChunkedFileBuffer
impl UnsafeUnpin for ChunkedFileBuffer
impl UnwindSafe for ChunkedFileBuffer
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.