pub enum Error {
BadPolicy(String),
Er7(Error),
}Expand description
What can go wrong.
Two variants, arising from exactly two situations: a policy that cannot
be read, and a path that is not a path (D15, spec §9). Redaction itself
cannot fail — a rule that matches nothing does nothing, and a position
that is not there is not created — so Redactor::redact returns a
Report rather than a Result.
Example:
use er7_redact::{Error, Policy};
assert!(matches!(Policy::parse("PID-5 obfuscate"), Err(Error::BadPolicy(_))));
assert!(matches!(Policy::parse("PID-0 clear"), Err(Error::BadPolicy(_))));
// A path handed straight to the API reports as `er7` phrased it.
use er7_redact::{Action, Rule};
assert!(matches!(Rule::new("PID-0", Action::Clear), Err(Error::Er7(_))));Variants§
BadPolicy(String)
A policy could not be read: an unknown action, a missing one, a count that is not a number, or a line naming something that is not a path. Carries a sentence naming the line and the problem (spec §6.4).
Er7(Error)
A path handed to the API is not a path. Carries er7’s own error,
so that the message reads the same whichever crate reported it.
Trait Implementations§
impl Eq for Error
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()
impl StructuralPartialEq for Error
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl UnwindSafe 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