FsAdapter

Trait FsAdapter 

Source
pub trait FsAdapter {
    type File: FileAdapter<Self::Permissions>;
    type Permissions: CheckedPermissions;
    type DirIter: Iterator<Item = Result<DirEntry, Error>>;

    // Required methods
    fn create_dir(&self, path: &str, location: Location) -> Result<(), Error>
       where Self::Permissions: MessageAllowed<CreateDirMessage> + MessageAllowed<CloseDir>;
    fn remove(&self, path: &str, location: Location) -> Result<(), Error>
       where Self::Permissions: MessageAllowed<Remove>;
    fn atomic_copy(
        &self,
        src: &str,
        dest: &str,
        rename: Option<String>,
        location: Location,
    ) -> Result<(), Error>
       where Self::Permissions: MessageAllowed<AtomicCopy>;
    fn open_file(
        &self,
        path: &str,
        location: Location,
        flags: OpenFlags,
    ) -> Result<Self::File, Error>
       where Self::Permissions: MessageAllowed<OpenFileMessage> + MessageAllowed<CloseFile>;
    fn open_dir(
        &self,
        path: &str,
        location: Location,
    ) -> Result<Self::DirIter, Error>
       where Self::Permissions: MessageAllowed<OpenDirMessage> + MessageAllowed<CloseDir> + MessageAllowed<NextEntry>;
    fn metadata(
        &self,
        path: &str,
        location: Location,
    ) -> Result<Metadata, Error>
       where Self::Permissions: MessageAllowed<GetMetadata>;
    fn rename(
        &self,
        src: &str,
        dest: &str,
        location: Location,
    ) -> Result<(), Error>
       where Self::Permissions: MessageAllowed<Rename>;
    fn flush(&mut self, location: Location) -> Result<(), Error>
       where Self::Permissions: MessageAllowed<FlushFs>;

    // Provided methods
    fn walk_dir(
        &self,
        path: &str,
        location: Location,
    ) -> Result<DirWalker<Self>, Error>
       where Self: Clone,
             Self::Permissions: MessageAllowed<OpenDirMessage> + MessageAllowed<CloseDir> + MessageAllowed<NextEntry> { ... }
    fn ensure_parent_dir_exists(
        &self,
        path: &str,
        location: Location,
    ) -> Result<(), Error>
       where Self::Permissions: MessageAllowed<CreateDirMessage> + MessageAllowed<CloseDir> { ... }
    fn remove_if_exists(
        &self,
        path: &str,
        location: Location,
    ) -> Result<(), Error>
       where Self::Permissions: MessageAllowed<Remove> { ... }
}
Expand description

Abstraction over filesystem operations for testing and generic code.

  • FileSystem: actual keyos fs server
  • FsTest: uses temporary directories (test-only)

Required Associated Types§

Required Methods§

Source

fn create_dir(&self, path: &str, location: Location) -> Result<(), Error>

Source

fn remove(&self, path: &str, location: Location) -> Result<(), Error>

Source

fn atomic_copy( &self, src: &str, dest: &str, rename: Option<String>, location: Location, ) -> Result<(), Error>

Source

fn open_file( &self, path: &str, location: Location, flags: OpenFlags, ) -> Result<Self::File, Error>

Source

fn open_dir( &self, path: &str, location: Location, ) -> Result<Self::DirIter, Error>

Source

fn metadata(&self, path: &str, location: Location) -> Result<Metadata, Error>

Source

fn rename(&self, src: &str, dest: &str, location: Location) -> Result<(), Error>

Source

fn flush(&mut self, location: Location) -> Result<(), Error>

Provided Methods§

Implementors§