pub struct RedactKeys { /* private fields */ }Expand description
Replaces the value of every object field with one of these names
(case-insensitively, at any depth) with "[REDACTED]".
use agent_effects::redaction::{Field, RedactKeys, Redactor};
use agent_effects::EffectName;
use serde_json::json;
let redact = RedactKeys::new(["password", "card_number"]);
let mut value = json!({ "user": "ada", "auth": { "Password": "hunter2" }, "cards": [{ "card_number": "4242" }] });
redact.redact(Field::Input, &EffectName::new("signup").unwrap(), &mut value);
assert_eq!(value, json!({ "user": "ada", "auth": { "Password": "[REDACTED]" }, "cards": [{ "card_number": "[REDACTED]" }] }));Implementations§
Source§impl RedactKeys
impl RedactKeys
Sourcepub fn new<K: AsRef<str>>(keys: impl IntoIterator<Item = K>) -> Self
pub fn new<K: AsRef<str>>(keys: impl IntoIterator<Item = K>) -> Self
Masks fields with any of keys.
Trait Implementations§
Source§impl Clone for RedactKeys
impl Clone for RedactKeys
Source§impl Debug for RedactKeys
impl Debug for RedactKeys
Source§impl Default for RedactKeys
impl Default for RedactKeys
Source§impl Redactor for RedactKeys
impl Redactor for RedactKeys
Auto Trait Implementations§
impl Freeze for RedactKeys
impl RefUnwindSafe for RedactKeys
impl Send for RedactKeys
impl Sync for RedactKeys
impl Unpin for RedactKeys
impl UnsafeUnpin for RedactKeys
impl UnwindSafe for RedactKeys
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