pub struct MemoryFilesystem { /* private fields */ }Expand description
Pure Rust, deterministic byte-path filesystem. Paths are exact opaque keys, including NUL and invalid UTF-8; no directories or OS normalization exist. Open files survive remove/rename. Temporary handles are anonymous and drop their storage on close; temporary names reserve visible empty entries. Clones share files/resources; preserve this object across snapshot restore.
Implementations§
Source§impl MemoryFilesystem
impl MemoryFilesystem
Sourcepub fn new(
files: impl IntoIterator<Item = (Vec<u8>, Vec<u8>)>,
options: MemoryOptions,
) -> Result<Self, HostIoError>
pub fn new( files: impl IntoIterator<Item = (Vec<u8>, Vec<u8>)>, options: MemoryOptions, ) -> Result<Self, HostIoError>
Seed initial files, bypassing read-only policy but enforcing file-size limits. Duplicate paths take the last supplied value.
Sourcepub fn contents(&self, path: &[u8]) -> Option<Vec<u8>>
pub fn contents(&self, path: &[u8]) -> Option<Vec<u8>>
Copy a named file without acquiring a handle; useful for reference fixtures.
Sourcepub fn open_count(&self) -> usize
pub fn open_count(&self) -> usize
Count live handles (temporary handles included).
Trait Implementations§
Source§impl Clone for MemoryFilesystem
impl Clone for MemoryFilesystem
Source§impl Filesystem for MemoryFilesystem
impl Filesystem for MemoryFilesystem
Source§fn probe_readable(&self, path: &[u8]) -> Completion<bool>
fn probe_readable(&self, path: &[u8]) -> Completion<bool>
Perform
probe_readable; return final success/failure or an opaque pending token.Source§fn open(&self, path: &[u8], mode: OpenMode) -> Completion<ResourceId>
fn open(&self, path: &[u8], mode: OpenMode) -> Completion<ResourceId>
Perform
open; return final success/failure or an opaque pending token.Source§fn read_at(
&self,
id: ResourceId,
offset: u64,
max: usize,
) -> Completion<Vec<u8>>
fn read_at( &self, id: ResourceId, offset: u64, max: usize, ) -> Completion<Vec<u8>>
Perform
read_at; return final success/failure or an opaque pending token.Source§fn write_at(
&self,
id: ResourceId,
offset: u64,
bytes: &[u8],
) -> Completion<usize>
fn write_at( &self, id: ResourceId, offset: u64, bytes: &[u8], ) -> Completion<usize>
Perform
write_at; return final success/failure or an opaque pending token.Source§fn append(&self, id: ResourceId, bytes: &[u8]) -> Completion<u64>
fn append(&self, id: ResourceId, bytes: &[u8]) -> Completion<u64>
Perform
append; return final success/failure or an opaque pending token.Source§fn size(&self, id: ResourceId) -> Completion<u64>
fn size(&self, id: ResourceId) -> Completion<u64>
Perform
size; return final success/failure or an opaque pending token.Source§fn flush(&self, id: ResourceId) -> Completion<()>
fn flush(&self, id: ResourceId) -> Completion<()>
Perform
flush; return final success/failure or an opaque pending token.Source§fn close(&self, id: ResourceId) -> Completion<()>
fn close(&self, id: ResourceId) -> Completion<()>
Perform
close; return final success/failure or an opaque pending token.Source§fn remove(&self, path: &[u8]) -> Completion<()>
fn remove(&self, path: &[u8]) -> Completion<()>
Perform
remove; return final success/failure or an opaque pending token.Source§fn rename(&self, from: &[u8], to: &[u8]) -> Completion<()>
fn rename(&self, from: &[u8], to: &[u8]) -> Completion<()>
Perform
rename; return final success/failure or an opaque pending token.Source§fn temp_file(&self) -> Completion<ResourceId>
fn temp_file(&self) -> Completion<ResourceId>
Perform
temp_file; return final success/failure or an opaque pending token.Source§fn temp_name(&self) -> Completion<Vec<u8>>
fn temp_name(&self) -> Completion<Vec<u8>>
Perform
temp_name; return final success/failure or an opaque pending token.Source§fn read_file(&self, path: &[u8], max: usize) -> Completion<Vec<u8>>
fn read_file(&self, path: &[u8], max: usize) -> Completion<Vec<u8>>
Perform
read_file; return final success/failure or an opaque pending token.Source§fn read_file_range(
&self,
path: &[u8],
offset: u64,
max: usize,
) -> Completion<Vec<u8>>
fn read_file_range( &self, path: &[u8], offset: u64, max: usize, ) -> Completion<Vec<u8>>
Read a bounded range of a named file without retaining a live resource.
Used by checkpointable source loading. Short results indicate EOF.
The default supports only a whole file fitting in the first request.
Source§fn handle_policy(&self) -> HandlePolicy
fn handle_policy(&self) -> HandlePolicy
Snapshot policy for live resource keys.
Source§fn rebind(&self, id: ResourceId) -> Result<(), HostIoError>
fn rebind(&self, id: ResourceId) -> Result<(), HostIoError>
Reacquire an existing resource without creating, truncating or changing it.
Auto Trait Implementations§
impl !RefUnwindSafe for MemoryFilesystem
impl !Send for MemoryFilesystem
impl !Sync for MemoryFilesystem
impl !UnwindSafe for MemoryFilesystem
impl Freeze for MemoryFilesystem
impl Unpin for MemoryFilesystem
impl UnsafeUnpin for MemoryFilesystem
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