pub struct Last4Redactor;Expand description
Redact all but the last 4 characters.
Useful for tokens, card numbers, or other identifiers where seeing the last few characters helps with identification.
Always shows at least 4 asterisks to avoid leaking information about short values or value length.
use apollo_redaction::Redacted;
use apollo_redaction::strategy::Last4Redactor;
fn last4(input: &str) -> String {
Redacted::<_, Last4Redactor>::new(input).to_string()
}
assert_eq!(last4("1234567890"), "******7890");
assert_eq!(last4("abc"), "****");
assert_eq!(last4("4242424242424242"), "************4242");Trait Implementations§
Source§impl Clone for Last4Redactor
impl Clone for Last4Redactor
Source§fn clone(&self) -> Last4Redactor
fn clone(&self) -> Last4Redactor
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for Last4Redactor
impl Default for Last4Redactor
Source§fn default() -> Last4Redactor
fn default() -> Last4Redactor
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for Last4Redactor
impl RefUnwindSafe for Last4Redactor
impl Send for Last4Redactor
impl Sync for Last4Redactor
impl Unpin for Last4Redactor
impl UnsafeUnpin for Last4Redactor
impl UnwindSafe for Last4Redactor
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