pub struct FilesystemRoot { /* private fields */ }Expand description
A canonicalized sandbox root. All paths resolved through this instance are guaranteed to live under the root directory on the local filesystem.
Implementations§
Source§impl FilesystemRoot
impl FilesystemRoot
Sourcepub fn new(root: impl Into<PathBuf>) -> Result<FilesystemRoot, String>
pub fn new(root: impl Into<PathBuf>) -> Result<FilesystemRoot, String>
Construct a sandbox rooted at root. The directory must exist and be
canonicalizable (symlinks resolved). Returns Err if the root does not
exist or is not accessible.
Sourcepub fn resolve(&self, input: &str) -> Result<PathBuf, String>
pub fn resolve(&self, input: &str) -> Result<PathBuf, String>
Resolve a user-supplied path against the sandbox root.
Returns the absolute, canonical path if it is (or — for not-yet-existing paths — would be) under the root. Rejects:
- any path whose components contain
.. - any path that canonicalizes outside the root (symlink escape)
- for new files: any parent path that escapes the root
Trait Implementations§
Source§impl Clone for FilesystemRoot
impl Clone for FilesystemRoot
Source§fn clone(&self) -> FilesystemRoot
fn clone(&self) -> FilesystemRoot
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FilesystemRoot
impl RefUnwindSafe for FilesystemRoot
impl Send for FilesystemRoot
impl Sync for FilesystemRoot
impl Unpin for FilesystemRoot
impl UnsafeUnpin for FilesystemRoot
impl UnwindSafe for FilesystemRoot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more