pub enum Error {
Parse(ParseError),
Io {
path: PathBuf,
source: Error,
},
}Expand description
The error type returned by crate::parse_file and crate::parse_str.
Parsing failures are reported as ParseError. Reading a policy file
from disk can additionally fail with an I/O error, which is reported as
the Error::Io variant carrying the offending path.
§Examples
use apparmor_policy::Error;
let e = Error::detached("boom");
assert!(e.to_string().contains("boom"));Variants§
Parse(ParseError)
The policy text is structurally invalid.
Io
The policy file could not be read from disk.
Implementations§
Source§impl Error
impl Error
Sourcepub fn detached(msg: impl Into<String>) -> Self
pub fn detached(msg: impl Into<String>) -> Self
Build an Error::Parse that is not tied to a specific source
location (useful for tooling that constructs errors programmatically).
§Examples
use apparmor_policy::Error;
let e = Error::detached("boom");
assert_eq!(e.to_string(), "boom");Sourcepub fn as_parse(&self) -> Option<&ParseError>
pub fn as_parse(&self) -> Option<&ParseError>
Returns the underlying ParseError if this is a parsing failure.
§Examples
use apparmor_policy::{Error, parse_str};
let e = Error::from(parse_str("profile foo {").unwrap_err());
assert!(e.as_parse().is_some());Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
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
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<ParseError> for Error
impl From<ParseError> for Error
Source§fn from(e: ParseError) -> Self
fn from(e: ParseError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Freeze for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
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