pub struct FixedRedactor<const N: usize>;Expand description
Redact all but the first N characters.
Shows the first N characters, then always shows exactly 4 asterisks to prevent leaking the length of the redacted portion.
If the value has N or fewer characters, outputs just 4 asterisks.
This is a configurable version - for common cases, prefer First4Redactor.
use apollo_redaction::Redacted;
use apollo_redaction::strategy::FixedRedactor;
fn fixed<const N: usize>(input: &str) -> String {
Redacted::<_, FixedRedactor<N>>::new(input).to_string()
}
assert_eq!(fixed::<4>("password123"), "pass****");
assert_eq!(fixed::<4>("test1"), "test****");
assert_eq!(fixed::<4>("abc"), "****"); // short input = 4 asterisksTrait Implementations§
Source§impl<const N: usize> Clone for FixedRedactor<N>
impl<const N: usize> Clone for FixedRedactor<N>
Source§fn clone(&self) -> FixedRedactor<N>
fn clone(&self) -> FixedRedactor<N>
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<const N: usize> Default for FixedRedactor<N>
impl<const N: usize> Default for FixedRedactor<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for FixedRedactor<N>
impl<const N: usize> RefUnwindSafe for FixedRedactor<N>
impl<const N: usize> Send for FixedRedactor<N>
impl<const N: usize> Sync for FixedRedactor<N>
impl<const N: usize> Unpin for FixedRedactor<N>
impl<const N: usize> UnsafeUnpin for FixedRedactor<N>
impl<const N: usize> UnwindSafe for FixedRedactor<N>
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