rskit_process/command/
redaction.rs1use rskit_util::SecretKeyMatcher;
4
5#[derive(Debug, Clone, Eq, PartialEq, Default)]
7pub struct ArgRedaction {
8 matcher: SecretKeyMatcher,
9}
10
11impl ArgRedaction {
12 #[must_use]
14 pub fn new() -> Self {
15 Self::default()
16 }
17
18 #[must_use]
20 pub fn from_names(names: impl IntoIterator<Item = impl AsRef<str>>) -> Self {
21 Self {
22 matcher: SecretKeyMatcher::new(names),
23 }
24 }
25
26 #[must_use]
28 pub fn with_name(mut self, name: impl AsRef<str>) -> Self {
29 self.matcher = self.matcher.with_name(name);
30 self
31 }
32
33 #[must_use]
35 pub fn with_names(mut self, names: impl IntoIterator<Item = impl AsRef<str>>) -> Self {
36 self.matcher = self.matcher.with_names(names);
37 self
38 }
39
40 #[must_use]
42 pub fn is_sensitive_arg_name(&self, name: &str) -> bool {
43 self.matcher.is_secret_key(name)
44 }
45}