pub struct SandboxPath { /* private fields */ }Expand description
A path that has been validated to be within a SandboxRoot.
Cannot be constructed directly; must come from SandboxRoot::join().
This type guarantees that the path:
- Does not escape the sandbox root
- Does not contain
..traversal components - Is not an absolute path outside the root
- Does not contain symlinks (if configured)
§Example
use xchecker_utils::paths::{SandboxRoot, SandboxConfig};
let root = SandboxRoot::new("/workspace", SandboxConfig::default())?;
let path = root.join("src/lib.rs")?;
// Use the full path for I/O operations
let content = std::fs::read_to_string(path.as_path())?;
// Use the relative path for display or storage
println!("File: {}", path.relative().display());Implementations§
Source§impl SandboxPath
impl SandboxPath
Sourcepub fn as_path(&self) -> &Path
pub fn as_path(&self) -> &Path
Get the full path for I/O operations.
This returns the complete path including the sandbox root,
suitable for use with std::fs operations.
Sourcepub fn relative(&self) -> &Path
pub fn relative(&self) -> &Path
Get the relative portion of the path.
This returns the path relative to the sandbox root, suitable for display or storage in artifacts.
Sourcepub fn to_path_buf(&self) -> PathBuf
pub fn to_path_buf(&self) -> PathBuf
Convert to a PathBuf for ownership.
Sourcepub fn relative_to_path_buf(&self) -> PathBuf
pub fn relative_to_path_buf(&self) -> PathBuf
Convert the relative path to a PathBuf.
Trait Implementations§
Source§impl AsRef<Path> for SandboxPath
impl AsRef<Path> for SandboxPath
Source§impl Clone for SandboxPath
impl Clone for SandboxPath
Source§fn clone(&self) -> SandboxPath
fn clone(&self) -> SandboxPath
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 SandboxPath
impl RefUnwindSafe for SandboxPath
impl Send for SandboxPath
impl Sync for SandboxPath
impl Unpin for SandboxPath
impl UnsafeUnpin for SandboxPath
impl UnwindSafe for SandboxPath
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