Skip to main content

Guard

Struct Guard 

Source
pub struct Guard { /* private fields */ }
Expand description

What decides whether a launch may proceed. Build one with Guard::for_workspace (apps) or Guard::for_temp_roots (engines without a workspace).

Implementations§

Source§

impl Guard

Source

pub fn for_temp_roots(app: Option<&str>) -> Guard

Guard for an engine or any launch without a workspace: paths must sit in a system temp root and break no forbidden-location rule.

Source

pub fn for_workspace(ws: &QaWorkspace) -> Result<Guard, UserDataViolation>

Guard for an app launched in ws. Fails when the home is not a QA root this runner created or is itself in a forbidden location.

Source

pub fn with_user_homes(self, homes: Vec<PathBuf>) -> Guard

Replace the user homes the guard protects (default: HOME and USERPROFILE of this process). Tests point it at a fake home.

Source

pub fn with_app(self, app: &str) -> Guard

Name the app under test; its real data directories become forbidden.

Source

pub fn forbidden(&self, resolved: &Path) -> Option<(Rule, String)>

First forbidden-location rule resolved breaks, ignoring any QA root.

Source

pub fn check_dir(&self, path: &Path) -> Result<PathBuf, UserDataViolation>

Judge one directory the runner would hand to the app. Returns its resolved path.

Source

pub fn check_env( &self, env: &[(String, String)], ) -> Result<(), UserDataViolation>

Judge every absolute-path value of a launch environment.

Trait Implementations§

Source§

impl Clone for Guard

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Guard

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Guard

§

impl RefUnwindSafe for Guard

§

impl Send for Guard

§

impl Sync for Guard

§

impl Unpin for Guard

§

impl UnsafeUnpin for Guard

§

impl UnwindSafe for Guard

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.