pub enum FileData {
Memory(Vec<u8>),
Spool {
spool: Arc<Mutex<File>>,
offset: u64,
len: u64,
},
}Expand description
File content storage — either in-memory for small files or spooled to disk for large files to keep memory usage bounded.
Variants§
Memory(Vec<u8>)
Small file content held in memory.
Spool
Large file content written to a shared spool file on disk.
Multiple FileData::Spool entries can reference different regions
of the same underlying spool file via Arc.
Implementations§
Source§impl FileData
impl FileData
pub fn is_empty(&self) -> bool
Sourcepub fn read_all(&self) -> Result<Vec<u8>>
pub fn read_all(&self) -> Result<Vec<u8>>
Read the entire content into memory. For Memory variant this
clones; for Spool this reads from disk.
Sourcepub fn as_bytes(&self) -> Option<&[u8]>
pub fn as_bytes(&self) -> Option<&[u8]>
Borrow the in-memory bytes directly (only for Memory variant).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileData
impl RefUnwindSafe for FileData
impl Send for FileData
impl Sync for FileData
impl Unpin for FileData
impl UnsafeUnpin for FileData
impl UnwindSafe for FileData
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