pub struct CorpusRoot { /* private fields */ }Expand description
A canonicalized, read-only corpus root that all paths are jailed to.
Cheaply cloneable; clones share the same root and limits.
Implementations§
Source§impl CorpusRoot
impl CorpusRoot
Sourcepub fn new(path: impl AsRef<Path>) -> Result<Self>
pub fn new(path: impl AsRef<Path>) -> Result<Self>
Establish a corpus root at path with Limits::default.
Fails if the path does not exist or is not a directory.
Sourcepub fn with_limits(path: impl AsRef<Path>, limits: Limits) -> Result<Self>
pub fn with_limits(path: impl AsRef<Path>, limits: Limits) -> Result<Self>
Establish a corpus root at path with explicit limits.
Sourcepub fn resolve(&self, requested: &str) -> Result<PathBuf>
pub fn resolve(&self, requested: &str) -> Result<PathBuf>
Resolve a caller-supplied path against the corpus root and verify it stays within the jail.
requested may be relative (resolved against the root) or absolute
(which must still land inside the root). The path must exist; symlinks
are resolved before the containment check, so a link pointing outside
the corpus is rejected.
Sourcepub fn relativize<'a>(&self, path: &'a Path) -> Cow<'a, str>
pub fn relativize<'a>(&self, path: &'a Path) -> Cow<'a, str>
Render a path (assumed inside the root) as a corpus-relative string for display back to the agent. Falls back to the original on failure.
Trait Implementations§
Source§impl Clone for CorpusRoot
impl Clone for CorpusRoot
Source§fn clone(&self) -> CorpusRoot
fn clone(&self) -> CorpusRoot
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 CorpusRoot
impl RefUnwindSafe for CorpusRoot
impl Send for CorpusRoot
impl Sync for CorpusRoot
impl Unpin for CorpusRoot
impl UnsafeUnpin for CorpusRoot
impl UnwindSafe for CorpusRoot
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