Struct
AuthorizedFs
pub struct AuthorizedFs<'a> { /* private fields */ }The authority of one origin. Every operation runs the decision rules in the module documentation; nothing else reaches the filesystem for a renderer.
Methods
#pub fn read_file(&self, path: &Path) -> Result<Vec<u8>, FsError>
fs.read_file: READ. Regular files only, up to the transfer limit.
#pub fn write_file(&self, path: &Path, contents: &[u8]) -> Result<(), FsError>
fs.write_file: WRITE to replace an existing file, CREATE to make a
new one. The object decides which applies. Contents over the transfer
limit are refused before anything is opened.
An existing file is replaced whole. The contents go to a new file beside it which then takes its name and its permissions. A write that fails part-way leaves the old contents. The file is a new object afterwards (its owner is the application’s user); on Windows another program holding it open without delete sharing makes the write fail.
#pub fn create_dir(&self, path: &Path) -> Result<(), FsError>
fs.create_dir: CREATE. One level; the parent must exist.
#pub fn remove_dir(&self, path: &Path) -> Result<(), FsError>
fs.remove_dir: DELETE. The directory must be empty.
#pub fn rename_file(&self, from: &Path, to: &Path) -> Result<(), FsError>
fs.rename_file: RENAME on source and destination, each authorized
independently. An existing destination is replaced.
Every rule is a function of where content lives. A move is also judged
as a whole. It may not carry content out from under a deny rule
(PATH_DENIED) nor to a place where the origin holds more access over
it than it held at the source (PATH_DENIED).
#pub fn copy_file(&self, from: &Path, to: &Path) -> Result<u64, FsError>
fs.copy_file: READ on the source, CREATE on the destination. Never
overwrites. Returns the number of bytes copied.
#pub fn list_dir(&self, path: &Path) -> Result<Vec<DirEntry>, FsError>
fs.read_dir: LIST. Denied entries, links and reparse points are
omitted, never flagged.