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

Struct

FileSystem

pub struct FileSystem<P: CheckedPermissions> { /* private fields */ }
Expand description

Client handle for the filesystem server.

This is the filesystem crate’s high-level API surface. It owns a checked connection to os/fs, enforces location access checks, and creates File and Dir handles for file and directory operations.

Implementations

impl<P: CheckedPermissions> FileSystem<P>

pub fn open_file( &self, path: impl Into<String>, location: Location, flags: OpenFlags, ) -> Result<File<P>, Error>
where P: 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

pub fn open_dir( &self, path: impl Into<String>, location: Location, ) -> Result<Dir<P>, Error>
where P: MessageAllowed<OpenDirMessage> + MessageAllowed<CloseDir>,

  • 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

pub fn create_dir( &self, path: impl Into<String>, location: Location, ) -> Result<Dir<P>, Error>
where P: 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

pub fn create_dir_async( &self, path: impl Into<String>, location: Location, ) -> Result<CreateDirMessage, Error>
where P: 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

pub fn ensure_parent_dir_exists( &self, path: &str, location: Location, ) -> Result<(), Error>
where P: 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

pub fn remove( &self, path: impl Into<String>, location: Location, ) -> Result<(), Error>
where P: MessageAllowed<Remove>,

Permission: os/fs / Remove

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

Required signature: thirdParty

Approval: autoAllow

pub fn remove_async( &self, path: impl Into<String>, location: Location, ) -> Result<Remove, Error>
where P: MessageAllowed<Remove>,

Permission: os/fs / Remove

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

Required signature: thirdParty

Approval: autoAllow

pub fn atomic_copy( &self, src: impl Into<String>, dest_dir: impl Into<String>, rename: Option<impl Into<String>>, location: Location, ) -> Result<(), Error>
where P: MessageAllowed<AtomicCopy>,

Permission: os/fs / AtomicCopy

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

Required signature: thirdParty

Approval: autoAllow

Copy a source file/directory to a destination directory. If source is a directory, the copy is recursive.

Optionally, the copied file/directory can be renamed by providing the rename argument.

The destination directory must be empty; copying into a non-empty directory returns Error::FileAlreadyExists.

pub fn metadata( &self, path: impl Into<String>, location: Location, ) -> Result<Metadata, Error>
where P: MessageAllowed<GetMetadata>,

Permission: os/fs / GetMetadata

Permission group: file-system.read-handles

Required signature: thirdParty

Approval: autoAllow

pub fn rename( &self, from: impl Into<String>, to: impl Into<String>, location: Location, ) -> Result<(), Error>
where P: MessageAllowed<Rename>,

Permission: os/fs / Rename

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

Required signature: thirdParty

Approval: autoAllow

pub fn rename_async( &self, from: impl Into<String>, to: impl Into<String>, location: Location, ) -> Result<Rename, Error>
where P: MessageAllowed<Rename>,

Permission: os/fs / Rename

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

Required signature: thirdParty

Approval: autoAllow

pub fn durable_file_write( &self, path: &str, location: Location, data: &[u8], ) -> Result<(), Error>

Permission: not needed

Replace the contents of path with data, so that a crash at any point during the write leaves FileSystem::durable_file_read either the complete old contents or the complete new ones.

<path>.tmp and <path>.new belong to this file and must not be used for anything else. Parent directories must already exist.

pub fn durable_file_read( &self, path: &str, location: Location, ) -> Result<Vec<u8>, Error>

Permission: not needed

Read a file written by FileSystem::durable_file_write.

§Errors

Error::FileNotFound if no generation of the file exists.

pub fn map_file( &self, location: Location, path: impl Into<String>, ) -> Result<MemoryRange, Error>

Permission: not needed

pub fn subscribe_filesystem_events<S>( &self, listener: &mut ServerContext<S>, location: Location, )
where S: Server + ScalarEventHandler<FileSystemEvent>, P: MessageAllowed<SubscribeFilesystemEvent>,

Permission: os/fs / SubscribeFilesystemEvent

Permission group: file-system.read-handles

Required signature: thirdParty

Approval: autoAllow

pub fn wait_for_filesystem(&self, location: Location)
where P: 'static + MessageAllowed<SubscribeFilesystemEvent>,

Permission: os/fs / SubscribeFilesystemEvent

Permission group: file-system.read-handles

Required signature: thirdParty

Approval: autoAllow

Trait Implementations

impl<P: Clone + CheckedPermissions> Clone for FileSystem<P>

fn clone(&self) -> FileSystem<P>

Returns a duplicate of the value. Read more
1.0.0

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

impl<P: Debug + CheckedPermissions> Debug for FileSystem<P>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

impl<P: Default + CheckedPermissions> Default for FileSystem<P>

fn default() -> FileSystem<P>

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

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

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

  • Permission: os/fs / CloseFile

    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

  • Permission: os/fs / ReadFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / WriteFile

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / Flush

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / SeekFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / CreateDirMessage

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

    Required signature: thirdParty

    Approval: autoAllow

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

  • Permission: os/fs / CloseFile

    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

  • Permission: os/fs / ReadFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / WriteFile

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / Flush

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / SeekFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • 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 P: MessageAllowed<AtomicCopy>,

  • Permission: os/fs / CloseFile

    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

  • Permission: os/fs / ReadFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / WriteFile

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / Flush

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / SeekFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • 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 P: MessageAllowed<OpenFileMessage> + MessageAllowed<CloseFile>,

  • Permission: os/fs / CloseFile

    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

  • Permission: os/fs / ReadFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / WriteFile

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / Flush

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / SeekFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / OpenFileMessage

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

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

  • Permission: os/fs / CloseFile

    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

  • Permission: os/fs / ReadFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / WriteFile

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / Flush

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / SeekFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / OpenDirMessage

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

    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

  • Permission: os/fs / ReadFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / WriteFile

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / Flush

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / SeekFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • 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 P: MessageAllowed<Rename>,

  • Permission: os/fs / CloseFile

    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

  • Permission: os/fs / ReadFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / WriteFile

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / Flush

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / SeekFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / Rename

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

    Required signature: thirdParty

    Approval: autoAllow

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

    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

  • Permission: os/fs / ReadFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / WriteFile

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / Flush

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / SeekFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / OpenDirMessage

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

    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

  • Permission: os/fs / ReadFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / WriteFile

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / Flush

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / SeekFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / CreateDirMessage

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

    Required signature: thirdParty

    Approval: autoAllow

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

  • Permission: os/fs / CloseFile

    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

  • Permission: os/fs / ReadFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / WriteFile

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / Flush

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

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / SeekFile

    Permission group: file-system.read-handles

    Required signature: thirdParty

    Approval: autoAllow

  • Permission: os/fs / Remove

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

    Required signature: thirdParty

    Approval: autoAllow

Auto Trait Implementations

impl<P> !Freeze for FileSystem<P>

impl<P> RefUnwindSafe for FileSystem<P>

impl<P> Send for FileSystem<P>

impl<P> Sync for FileSystem<P>

impl<P> Unpin for FileSystem<P>

impl<P> UnsafeUnpin for FileSystem<P>

impl<P> UnwindSafe for FileSystem<P>