Be aware: Foundation will NEVER ask for your seed words, device PIN, or call you unexpectedly. If anyone does, it's a scam.

Trait

FsAdapter

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>;


    // 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

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>,

  • Permission: os/fs / CreateDirMessage

    Permission group: file-system.write-and-mutate

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / CloseDir

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

fn remove(&self, path: &str, location: Location) -> Result<(), Error>
where Self::Permissions: MessageAllowed<Remove>,

Permission: os/fs / Remove

Permission group: file-system.write-and-mutate

Required signature: thirdParty

Approval: autoAllow

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

Permission: os/fs / AtomicCopy

Permission group: file-system.write-and-mutate

Required signature: thirdParty

Approval: autoAllow

fn open_file( &self, path: &str, location: Location, flags: OpenFlags, ) -> Result<Self::File, Error>
where Self::Permissions: MessageAllowed<OpenFileMessage> + MessageAllowed<CloseFile>,

  • Permission: os/fs / OpenFileMessage

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / CloseFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

fn open_dir( &self, path: &str, location: Location, ) -> Result<Self::DirIter, Error>
where Self::Permissions: MessageAllowed<OpenDirMessage> + MessageAllowed<CloseDir> + MessageAllowed<NextEntry>,

  • Permission: os/fs / OpenDirMessage

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / CloseDir

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / NextEntry

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

fn metadata(&self, path: &str, location: Location) -> Result<Metadata, Error>
where Self::Permissions: MessageAllowed<GetMetadata>,

Permission: os/fs / GetMetadata

Permission group: file-system.read-handles

Required signature: thirdParty

Approval: autoAllow

fn rename(&self, src: &str, dest: &str, location: Location) -> Result<(), Error>
where Self::Permissions: MessageAllowed<Rename>,

Permission: os/fs / Rename

Permission group: file-system.write-and-mutate

Required signature: thirdParty

Approval: autoAllow

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>,

  • Permission: os/fs / OpenDirMessage

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / CloseDir

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / NextEntry

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

fn ensure_parent_dir_exists( &self, path: &str, location: Location, ) -> Result<(), Error>
where Self::Permissions: MessageAllowed<CreateDirMessage> + MessageAllowed<CloseDir>,

  • Permission: os/fs / CreateDirMessage

    Permission group: file-system.write-and-mutate

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / CloseDir

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

fn remove_if_exists(&self, path: &str, location: Location) -> Result<(), Error>
where Self::Permissions: MessageAllowed<Remove>,

Permission: os/fs / Remove

Permission group: file-system.write-and-mutate

Required signature: thirdParty

Approval: autoAllow

Implementors

impl<P> FsAdapter for FileSystem<P>
where P: CheckedPermissions + MessageAllowed<CloseFile> + MessageAllowed<CloseDir> + MessageAllowed<NextEntry> + MessageAllowed<ReadFile> + MessageAllowed<WriteFile> + MessageAllowed<Flush> + MessageAllowed<SeekFile>,

type DirIter = DirIterator<P>

type File = File<P>

type Permissions = P