pub struct ProjectSandbox { /* private fields */ }Expand description
Default sandbox rooted at the project directory.
project_root— where.git/.orcswas detected (immutable after creation)permissive_root— effective boundary (defaults toproject_root, narrowed byscoped())
§Example
use orcs_runtime::sandbox::{ProjectSandbox, SandboxPolicy};
let sandbox = ProjectSandbox::new("/home/user/myproject").expect("sandbox init");
assert!(sandbox.validate_read("src/main.rs").is_ok());
assert!(sandbox.validate_read("/etc/passwd").is_err());Implementations§
Source§impl ProjectSandbox
impl ProjectSandbox
Sourcepub fn new(project_root: impl AsRef<Path>) -> Result<Self, SandboxError>
pub fn new(project_root: impl AsRef<Path>) -> Result<Self, SandboxError>
Creates a new sandbox rooted at the given project directory.
The path is canonicalized to resolve symlinks.
§Errors
Returns SandboxError::Init if the path cannot be canonicalized.
Sourcepub fn scoped(&self, sub_path: impl AsRef<Path>) -> Result<Self, SandboxError>
pub fn scoped(&self, sub_path: impl AsRef<Path>) -> Result<Self, SandboxError>
Creates a scoped (virtual) sandbox within this one.
The effective boundary is narrowed to sub_path (relative to
current root()). The project_root remains unchanged.
§Errors
Returns error if sub_path resolves outside the current boundary.
Trait Implementations§
Source§impl Clone for ProjectSandbox
impl Clone for ProjectSandbox
Source§fn clone(&self) -> ProjectSandbox
fn clone(&self) -> ProjectSandbox
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 moreSource§impl Debug for ProjectSandbox
impl Debug for ProjectSandbox
Source§impl SandboxPolicy for ProjectSandbox
impl SandboxPolicy for ProjectSandbox
Source§fn project_root(&self) -> &Path
fn project_root(&self) -> &Path
The project root (where
.git/.orcs was detected).Source§fn validate_read(&self, path: &str) -> Result<PathBuf, SandboxError>
fn validate_read(&self, path: &str) -> Result<PathBuf, SandboxError>
Validates an existing path for reading. Read more
Source§fn validate_write(&self, path: &str) -> Result<PathBuf, SandboxError>
fn validate_write(&self, path: &str) -> Result<PathBuf, SandboxError>
Validates a (potentially new) path for writing. Read more
Auto Trait Implementations§
impl Freeze for ProjectSandbox
impl RefUnwindSafe for ProjectSandbox
impl Send for ProjectSandbox
impl Sync for ProjectSandbox
impl Unpin for ProjectSandbox
impl UnsafeUnpin for ProjectSandbox
impl UnwindSafe for ProjectSandbox
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