pub struct CardRedactor;Expand description
Redact credit card numbers while preserving format.
Replaces all digits except the last 4 with asterisks, preserving any separators (spaces, dashes) in their original positions.
Card numbers with fewer than 13 digits are considered invalid.
use apollo_redaction::Redacted;
use apollo_redaction::strategy::CardRedactor;
fn card(input: &str) -> String {
Redacted::<_, CardRedactor>::new(input).to_string()
}
assert_eq!(card("4242424242424242"), "************4242");
assert_eq!(card("4242-4242-4242-4242"), "****-****-****-4242");
assert_eq!(card("4242 4242 4242 4242"), "**** **** **** 4242");
assert_eq!(card("1234"), "[REDACTED: invalid card number]");Trait Implementations§
Source§impl Clone for CardRedactor
impl Clone for CardRedactor
Source§fn clone(&self) -> CardRedactor
fn clone(&self) -> CardRedactor
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 CardRedactor
impl Default for CardRedactor
Source§fn default() -> CardRedactor
fn default() -> CardRedactor
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for CardRedactor
impl RefUnwindSafe for CardRedactor
impl Send for CardRedactor
impl Sync for CardRedactor
impl Unpin for CardRedactor
impl UnsafeUnpin for CardRedactor
impl UnwindSafe for CardRedactor
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