pub struct Fs<T: TimeProvider = MonotonicCounter> { /* private fields */ }Expand description
Main filesystem structure. See the module-level comment for an overview of the two storage flavours.
Implementations§
Source§impl<T: TimeProvider> Fs<T>
impl<T: TimeProvider> Fs<T>
Sourcepub fn with_time_provider(time_provider: T) -> Self
pub fn with_time_provider(time_provider: T) -> Self
Build an empty filesystem with the supplied time provider. A root directory is created automatically with timestamps populated by the provider.
pub fn open_path(&self, path: &str) -> Result<Fd, FsError>
pub fn open_at(&self, dir_fd: Fd, path: &str, flags: u32) -> Result<Fd, FsError>
pub fn open_path_with_flags( &self, path: &str, flags: u32, ) -> Result<Fd, FsError>
pub fn write(&self, fd: Fd, buf: &[u8]) -> Result<usize, FsError>
Sourcepub fn write_at(
&self,
fd: Fd,
offset: u64,
buf: &[u8],
) -> Result<usize, FsError>
pub fn write_at( &self, fd: Fd, offset: u64, buf: &[u8], ) -> Result<usize, FsError>
Write data at a specific offset atomically (seek + write in one lock acquisition). Does not touch O_APPEND.
Sourcepub fn append_write(&self, fd: Fd, buf: &[u8]) -> Result<usize, FsError>
pub fn append_write(&self, fd: Fd, buf: &[u8]) -> Result<usize, FsError>
Append data to file atomically (always writes at end of file).
pub fn read(&self, fd: Fd, out: &mut [u8]) -> Result<usize, FsError>
Sourcepub fn read_at(
&self,
fd: Fd,
offset: u64,
out: &mut [u8],
) -> Result<usize, FsError>
pub fn read_at( &self, fd: Fd, offset: u64, out: &mut [u8], ) -> Result<usize, FsError>
Read data at a specific offset atomically (seek + read in one lock acquisition).
pub fn ftruncate(&self, fd: Fd, size: u64) -> Result<(), FsError>
pub fn close(&self, fd: Fd) -> Result<(), FsError>
pub fn stat(&self, path: &str) -> Result<Metadata, FsError>
pub fn fstat(&self, fd: Fd) -> Result<Metadata, FsError>
pub fn seek(&self, fd: Fd, offset: i64, whence: i32) -> Result<u64, FsError>
pub fn mkdir(&self, path: &str) -> Result<(), FsError>
pub fn mkdir_p(&self, path: &str) -> Result<(), FsError>
pub fn unlink(&self, path: &str) -> Result<(), FsError>
pub fn readdir(&self, path: &str) -> Result<Vec<String>, FsError>
Source§impl<T: TimeProvider> Fs<T>
impl<T: TimeProvider> Fs<T>
Sourcepub fn to_snapshot(&self) -> FsSnapshot
pub fn to_snapshot(&self) -> FsSnapshot
Create a snapshot of the current filesystem state.
Sourcepub fn from_snapshot(snapshot: FsSnapshot, time_provider: T) -> Self
pub fn from_snapshot(snapshot: FsSnapshot, time_provider: T) -> Self
Restore filesystem state from a snapshot.
Trait Implementations§
Auto Trait Implementations§
impl<T = MonotonicCounter> !Freeze for Fs<T>
impl<T = MonotonicCounter> !RefUnwindSafe for Fs<T>
impl<T = MonotonicCounter> !Send for Fs<T>
impl<T = MonotonicCounter> !Sync for Fs<T>
impl<T = MonotonicCounter> !UnwindSafe for Fs<T>
impl<T> Unpin for Fs<T>where
T: Unpin,
impl<T> UnsafeUnpin for Fs<T>where
T: UnsafeUnpin,
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