pub struct Redacted {
pub text: String,
pub kinds: Vec<&'static str>,
}Expand description
Text after redact_secrets or public_text, with the shapes that fired in it.
kinds is what mj_capture_redacted_kinds reports for the same text: the names its
[redacted:<name>] markers carry, each once, in the crate’s canonical order, which for
these lower-case hyphenated names is the byte order the shell’s LC_ALL=C sort -u gives.
They are read off the text, as the shell reads them, so a marker the input already
carried counts as much as one this call wrote: text redacted once and redacted again
still says what was taken out of it. A marker that names no shape of the table is not a
kind here, since a kind is one of shape_names; the shell would list that name too.
use majordomus_cli::redaction::{redact_secrets, Redacted};
let key = format!("{}{}", "sk-ant-", "b".repeat(20));
let pat = format!("{}{}", "github_pat_", "c".repeat(20));
let out: Redacted = redact_secrets(&format!("{pat} then {key} then {pat}"));
assert_eq!(out.kinds, ["anthropic-key", "github-pat"]);
assert!(!out.text.contains("sk-ant-"));
// redacting again finds nothing new, and still names what the text had taken out
assert_eq!(redact_secrets(&out.text).kinds, out.kinds);Fields§
§text: StringThe text with every credential replaced by [redacted:<name>].
kinds: Vec<&'static str>The shapes the text’s markers name, sorted and unique.
Trait Implementations§
impl Eq for Redacted
impl StructuralPartialEq for Redacted
Auto Trait Implementations§
impl Freeze for Redacted
impl RefUnwindSafe for Redacted
impl Send for Redacted
impl Sync for Redacted
impl Unpin for Redacted
impl UnsafeUnpin for Redacted
impl UnwindSafe for Redacted
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.