pub struct SecretScanError { /* private fields */ }Expand description
A sanitized scan error. It holds nothing but its code.
Every failure this crate reports is one of these: a fixed
SecretScanErrorCode and its fixed message, with no payload. No error
carries the scanned input, a matched value, a candidate field, or a
placeholder, so an error can be logged or returned to a caller without
leaking what was being scanned.
§Examples
use redact_secret::{DetectorRegistry, SecretScanErrorCode, redact, scan, DefaultPolicy};
let registry = DetectorRegistry::with_built_in([])?;
let input = "API_KEY=ghp_SYNTHETICREVOKED00000000000000000000";
let findings = scan(input, ®istry, &DefaultPolicy)?;
// The same findings do not describe a shorter input.
let error = redact("short", &findings, &redact_secret::default_placeholder_formatter).unwrap_err();
assert_eq!(error.code(), SecretScanErrorCode::InvalidFindings);
assert_eq!(error.to_string(), "Redaction findings are invalid.");
assert!(!error.to_string().contains("ghp_"));Implementations§
Source§impl SecretScanError
impl SecretScanError
Sourcepub const fn new(code: SecretScanErrorCode) -> Self
pub const fn new(code: SecretScanErrorCode) -> Self
Creates an error for code.
Sourcepub const fn code(self) -> SecretScanErrorCode
pub const fn code(self) -> SecretScanErrorCode
The error code.
Trait Implementations§
Source§impl Clone for SecretScanError
impl Clone for SecretScanError
impl Copy for SecretScanError
Source§impl Debug for SecretScanError
impl Debug for SecretScanError
Source§impl Display for SecretScanError
impl Display for SecretScanError
impl Eq for SecretScanError
Source§impl Error for SecretScanError
impl Error for SecretScanError
1.30.0 · 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<DetectionConfigError> for SecretScanError
impl From<DetectionConfigError> for SecretScanError
Source§fn from(error: DetectionConfigError) -> Self
fn from(error: DetectionConfigError) -> Self
Converts to this type from the input type.
Source§impl From<SecretScanErrorCode> for SecretScanError
impl From<SecretScanErrorCode> for SecretScanError
Source§fn from(code: SecretScanErrorCode) -> Self
fn from(code: SecretScanErrorCode) -> Self
Converts to this type from the input type.
Source§impl Hash for SecretScanError
impl Hash for SecretScanError
Source§impl PartialEq for SecretScanError
impl PartialEq for SecretScanError
impl StructuralPartialEq for SecretScanError
Auto Trait Implementations§
impl Freeze for SecretScanError
impl RefUnwindSafe for SecretScanError
impl Send for SecretScanError
impl Sync for SecretScanError
impl Unpin for SecretScanError
impl UnsafeUnpin for SecretScanError
impl UnwindSafe for SecretScanError
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