Skip to main content

Fs

Struct Fs 

Source
pub struct Fs<T: TimeProvider = MonotonicCounter> { /* private fields */ }
Expand description

Main filesystem structure (single-threaded, uses Rc)

Implementations§

Source§

impl<T: TimeProvider> Fs<T>

Source

pub fn to_snapshot(&self) -> FsSnapshot

Source

pub fn from_snapshot(snapshot: FsSnapshot, time_provider: T) -> Self

Source§

impl<T: TimeProvider> Fs<T>

Source

pub fn with_time_provider(time_provider: T) -> Self

Source

pub fn open_path(&mut self, path: &str) -> Result<Fd, FsError>

Source

pub fn open_at( &mut self, dir_fd: Fd, path: &str, flags: u32, ) -> Result<Fd, FsError>

Source

pub fn open_path_with_flags( &mut self, path: &str, flags: u32, ) -> Result<Fd, FsError>

Source

pub fn write(&mut self, fd: Fd, buf: &[u8]) -> Result<usize, FsError>

Source

pub fn append_write(&mut self, fd: Fd, buf: &[u8]) -> Result<usize, FsError>

Append data to file atomically (always writes at end of file)

Source

pub fn read(&mut self, fd: Fd, out: &mut [u8]) -> Result<usize, FsError>

Source

pub fn ftruncate(&mut self, fd: Fd, size: u64) -> Result<(), FsError>

Source

pub fn close(&mut self, fd: Fd) -> Result<(), FsError>

Source

pub fn stat(&self, path: &str) -> Result<Metadata, FsError>

Source

pub fn fstat(&self, fd: Fd) -> Result<Metadata, FsError>

Source

pub fn seek(&mut self, fd: Fd, offset: i64, whence: i32) -> Result<u64, FsError>

Source

pub fn mkdir(&mut self, path: &str) -> Result<(), FsError>

Source

pub fn mkdir_p(&mut self, path: &str) -> Result<(), FsError>

Source

pub fn readdir(&self, path: &str) -> Result<Vec<String>, FsError>

Source

pub fn readdir_fd(&self, fd: Fd) -> Result<Vec<(String, bool)>, FsError>

Read directory entries from an open file descriptor Returns a list of (name, is_dir) tuples

Source

pub fn rmdir(&mut self, path: &str) -> Result<(), FsError>

Remove an empty directory

Source

pub fn rename(&mut self, old_path: &str, new_path: &str) -> Result<(), FsError>

Rename or move a file or directory

Source§

impl Fs<MonotonicCounter>

Source

pub fn new() -> Self

Trait Implementations§

Source§

impl Default for Fs<MonotonicCounter>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Fs<T>
where T: Freeze,

§

impl<T = MonotonicCounter> !RefUnwindSafe for Fs<T>

§

impl<T = MonotonicCounter> !Send for Fs<T>

§

impl<T = MonotonicCounter> !Sync for Fs<T>

§

impl<T> Unpin for Fs<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Fs<T>
where T: UnsafeUnpin,

§

impl<T = MonotonicCounter> !UnwindSafe for Fs<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.