pub struct MemoryStorage { /* private fields */ }Expand description
In-memory storage for testing purposes.
This implementation stores all files in memory, enabling unit tests to run without filesystem access or ZIP operations.
§Example
use cdx_core::archive::MemoryStorage;
use cdx_core::archive::ArchiveStorage;
let mut storage = MemoryStorage::new();
storage.write_file("test.txt", b"Hello, world!").unwrap();
assert!(storage.file_exists("test.txt"));
assert_eq!(storage.read_file("test.txt").unwrap(), b"Hello, world!");Implementations§
Trait Implementations§
Source§impl ArchiveStorage for MemoryStorage
impl ArchiveStorage for MemoryStorage
Source§fn read_file(&mut self, path: &str) -> Result<Vec<u8>>
fn read_file(&mut self, path: &str) -> Result<Vec<u8>>
Read a file from the archive. Read more
Source§fn write_file(&mut self, path: &str, data: &[u8]) -> Result<()>
fn write_file(&mut self, path: &str, data: &[u8]) -> Result<()>
Write a file to the archive. Read more
Source§fn file_exists(&self, path: &str) -> bool
fn file_exists(&self, path: &str) -> bool
Check if a file exists in the archive.
Source§fn file_names(&self) -> Vec<String>
fn file_names(&self) -> Vec<String>
Get all file names in the archive.
Source§impl Clone for MemoryStorage
impl Clone for MemoryStorage
Source§fn clone(&self) -> MemoryStorage
fn clone(&self) -> MemoryStorage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MemoryStorage
impl Debug for MemoryStorage
Source§impl Default for MemoryStorage
impl Default for MemoryStorage
Source§fn default() -> MemoryStorage
fn default() -> MemoryStorage
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MemoryStorage
impl RefUnwindSafe for MemoryStorage
impl Send for MemoryStorage
impl Sync for MemoryStorage
impl Unpin for MemoryStorage
impl UnsafeUnpin for MemoryStorage
impl UnwindSafe for MemoryStorage
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