pub struct Fs<T = MonotonicCounter>where
T: TimeProvider,{ /* private fields */ }Expand description
Main filesystem structure. See the module-level comment for an overview of the two storage flavours.
Implementations§
Source§impl<T> Fs<T>where
T: TimeProvider,
impl<T> Fs<T>where
T: TimeProvider,
Sourcepub fn with_time_provider(time_provider: T) -> Fs<T>
pub fn with_time_provider(time_provider: T) -> Fs<T>
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<u32, FsError>
pub fn open_at( &self, dir_fd: u32, path: &str, flags: u32, ) -> Result<u32, FsError>
pub fn open_path_with_flags( &self, path: &str, flags: u32, ) -> Result<u32, FsError>
pub fn write(&self, fd: u32, buf: &[u8]) -> Result<usize, FsError>
Sourcepub fn write_at(
&self,
fd: u32,
offset: u64,
buf: &[u8],
) -> Result<usize, FsError>
pub fn write_at( &self, fd: u32, 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: u32, buf: &[u8]) -> Result<usize, FsError>
pub fn append_write(&self, fd: u32, buf: &[u8]) -> Result<usize, FsError>
Append data to file atomically (always writes at end of file).
pub fn read(&self, fd: u32, out: &mut [u8]) -> Result<usize, FsError>
Sourcepub fn read_at(
&self,
fd: u32,
offset: u64,
out: &mut [u8],
) -> Result<usize, FsError>
pub fn read_at( &self, fd: u32, 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: u32, size: u64) -> Result<(), FsError>
pub fn close(&self, fd: u32) -> Result<(), FsError>
pub fn stat(&self, path: &str) -> Result<Metadata, FsError>
pub fn fstat(&self, fd: u32) -> Result<Metadata, FsError>
pub fn seek(&self, fd: u32, 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> Fs<T>where
T: TimeProvider,
impl<T> Fs<T>where
T: TimeProvider,
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) -> Fs<T>
pub fn from_snapshot(snapshot: FsSnapshot, time_provider: T) -> Fs<T>
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> Send for Fs<T>where
T: Send,
impl<T> Sync for Fs<T>where
T: Sync,
impl<T> Unpin for Fs<T>where
T: Unpin,
impl<T> UnsafeUnpin for Fs<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Fs<T>where
T: UnwindSafe,
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<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
Query the “status” flags for the
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
Set the “status” flags for the
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more