Struct FileSystem

Source
pub struct FileSystem<'a> { /* private fields */ }
Expand description

A buffer backed filesystem.

Implementations§

Source§

impl<'a> FileSystem<'a>

Source

pub fn mount(buffer: &'a mut [u8]) -> Result<Self>

Mount the buffer, assuming it is formatted.

Source

pub fn format(buffer: &mut [u8]) -> Result<()>

Format the buffer.

Source

pub fn mount_or_format(buffer: &'a mut [u8]) -> Result<Self>

Format the buffer if there is no MBR, and then mount it.

Source

pub fn cwd(&self) -> &Path

Returns the current work directory.

Source

pub fn cd<P: AsRef<Path>>(&mut self, dir: P) -> Result<()>

Navigates into the provided directory.

Source

pub fn mkdir<P: AsRef<Path>>(&mut self, dir: P) -> Result<()>

Creates the provided path recursively from the current directory.

Source

pub fn rmdir<P: AsRef<Path>>(&mut self, dir: P) -> Result<()>

Recursively removes the path and all its contents.

Source

pub fn open<P: AsRef<Path>>(&mut self, path: P) -> Result<File>

Opens the file at the specified path.

Source

pub fn save(&mut self, file: File) -> Result<()>

Saves the file into the buffer.

Source

pub fn ls<P: AsRef<Path>>(&mut self, dir: P) -> Result<Vec<DirOrFile>>

List the contents of a directory.

Source

pub fn rm<P: AsRef<Path>>(&mut self, dir: P) -> Result<()>

Removes a file or an empty directory.

Auto Trait Implementations§

§

impl<'a> !Freeze for FileSystem<'a>

§

impl<'a> !RefUnwindSafe for FileSystem<'a>

§

impl<'a> !Send for FileSystem<'a>

§

impl<'a> !Sync for FileSystem<'a>

§

impl<'a> Unpin for FileSystem<'a>

§

impl<'a> !UnwindSafe for FileSystem<'a>

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.