Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 17 variants NotFound(PathBuf), BadPermission(PathBuf, u32, u32), BadOwner(PathBuf, u32), BadType(PathBuf), CouldNotInspect(PathBuf, Arc<Error>), Multiple(Vec<Box<Error>>), StepsExceeded, CurrentDirectory(Arc<Error>), CreatingDir(Arc<Error>), Content(Box<Error>), Listing(Arc<Error>), InvalidSubdirectory, Io { filename: PathBuf, action: &'static str, err: Arc<Error>, }, MissingField(UninitializedFieldError), NoSuchGroup(String), NoSuchUser(String), PasswdGroupIoError(Arc<Error>),
}
Expand description

An error returned while checking a path for privacy.

Note that this often means a necessary file doesn’t exist at all.

When printing a fs_mistrust::Error, do not describe it as a “permissions error”. Describe it with less specific wording, perhaps “Problem accessing Thing”.

The Display impl will give the details.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

NotFound(PathBuf)

A target (or one of its ancestors) was not found.

§

BadPermission(PathBuf, u32, u32)

A target (or one of its ancestors) had incorrect permissions.

Only generated on unix-like systems.

The first integer contains the current permission bits, and the second contains the permission bits which were incorrectly set.

§

BadOwner(PathBuf, u32)

A target (or one of its ancestors) had an untrusted owner.

Only generated on unix-like systems.

The provided integer contains the user_id o

§

BadType(PathBuf)

A target (or one of its ancestors) had the wrong type.

Ordinarily, the target may be anything at all, though you can override this with require_file and require_directory.

§

CouldNotInspect(PathBuf, Arc<Error>)

We were unable to inspect the target or one of its ancestors.

(Ironically, we might lack permissions to see if something’s permissions are correct.)

(The std::io::Error that caused this problem is wrapped in an Arc so that our own Error type can implement Clone.)

§

Multiple(Vec<Box<Error>>)

Multiple errors occurred while inspecting the target.

This variant will only be returned if the caller specifically asked for it by calling all_errors.

We will never construct an instance of this variant with an empty Vec.

§

StepsExceeded

We’ve realized that we can’t finish resolving our path without taking more than the maximum number of steps. The likeliest explanation is a symlink loop.

§

CurrentDirectory(Arc<Error>)

We can’t find our current working directory, or we found it but it looks impossible.

§

CreatingDir(Arc<Error>)

We tried to create a directory, and encountered a failure in doing so.

§

Content(Box<Error>)

We found a problem while checking the contents of the directory.

§

Listing(Arc<Error>)

Available on crate feature walkdir only.

We were unable to inspect the contents of the directory

This error is only present when the walkdir feature is enabled.

§

InvalidSubdirectory

Tried to use an invalid path with a CheckedDir,

§

Io

We encountered an error while attempting an IO operation on a file.

Fields

§filename: PathBuf

The file that we were trying to modify or inspect

§action: &'static str

The action that failed.

§err: Arc<Error>

The error that we got when trying to perform the operation.

§

MissingField(UninitializedFieldError)

A field was missing when we tried to construct a Mistrust.

§

NoSuchGroup(String)

A group that we were configured to trust could not be found.

§

NoSuchUser(String)

A user that we were configured to trust could not be found.

§

PasswdGroupIoError(Arc<Error>)

Error accessing passwd/group databases or obtaining our uids/gids

Implementations§

Source§

impl Error

Source

pub fn path(&self) -> Option<&Path>

Return the path, if any, associated with this error.

Source

pub fn is_bad_permission(&self) -> bool

Return true iff this error indicates a problem with filesystem permissions.

(Other errors typically indicate an IO problem, possibly one preventing us from looking at permissions in the first place)

Source

pub fn errors<'a>(&'a self) -> impl Iterator<Item = &'a Error> + 'a

Return an iterator over all of the errors contained in this Error.

If this is a singleton, the iterator returns only a single element. Otherwise, it returns all the elements inside the Error::Multiple variant.

Does not recurse, since we do not create nested instances of Error::Multiple.

Trait Implementations§

Source§

impl Clone for Error

Source§

fn clone(&self) -> Error

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Error

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<UninitializedFieldError> for Error

Source§

fn from(source: UninitializedFieldError) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<Error> for Option<Error>

Source§

fn from_iter<T: IntoIterator<Item = Error>>(iter: T) -> Self

Creates a value from an iterator. Read more

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl !UnwindSafe for Error

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 48 bytes

Size for each variant:

  • NotFound: 32 bytes
  • BadPermission: 40 bytes
  • BadOwner: 40 bytes
  • BadType: 32 bytes
  • CouldNotInspect: 40 bytes
  • Multiple: 32 bytes
  • StepsExceeded: 0 bytes
  • CurrentDirectory: 16 bytes
  • CreatingDir: 16 bytes
  • Content: 16 bytes
  • Listing: 16 bytes
  • InvalidSubdirectory: 0 bytes
  • Io: 48 bytes
  • MissingField: 24 bytes
  • NoSuchGroup: 32 bytes
  • NoSuchUser: 32 bytes
  • PasswdGroupIoError: 16 bytes