pub struct First4Redactor;Expand description
Redact all but the first 4 characters.
Useful for API keys or tokens where the prefix identifies the key type.
If the value has 4 or fewer characters, outputs at least 4 asterisks to avoid leaking information about short values.
use apollo_redaction::Redacted;
use apollo_redaction::strategy::First4Redactor;
fn first4(input: &str) -> String {
Redacted::<_, First4Redactor>::new(input).to_string()
}
assert_eq!(first4("sk_live_abc123"), "sk_l****");
assert_eq!(first4("abc"), "****");
assert_eq!(first4("api_key_secret"), "api_****");Trait Implementations§
Source§impl Clone for First4Redactor
impl Clone for First4Redactor
Source§fn clone(&self) -> First4Redactor
fn clone(&self) -> First4Redactor
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 First4Redactor
impl Default for First4Redactor
Source§fn default() -> First4Redactor
fn default() -> First4Redactor
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for First4Redactor
impl RefUnwindSafe for First4Redactor
impl Send for First4Redactor
impl Sync for First4Redactor
impl Unpin for First4Redactor
impl UnsafeUnpin for First4Redactor
impl UnwindSafe for First4Redactor
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