Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extending #[redact(with = 'X')] to support Strings #76

Open
nick-schafhauser opened this issue Nov 14, 2023 · 0 comments
Open

extending #[redact(with = 'X')] to support Strings #76

nick-schafhauser opened this issue Nov 14, 2023 · 0 comments

Comments

@nick-schafhauser
Copy link
Contributor

nick-schafhauser commented Nov 14, 2023

currently the #[redact(with = 'X')] attribute is limited in that you can only specify one single character that the string will be redacted with.

What do we think about enhancing this attribute so that it can support Strings instead of just chars?

Here is an example of what I am proposing:

#[derive(Redact)]
struct Foo {
    #[redact(with = "[REDACTED]")]
    redact_me: String,
}

fn main() {
    println!(
        "{:#?}",
        Foo {
            redact_me: "Super Secret String".to_string(),
        }
    );
}

// Running main would print the following:
Foo {
    redact_me: "[REDACTED]",
}

Now I am not sure how this would play nicely with the partial or fixed attributes, so perhaps reusing the with attribute to support a String or Char isn't the way to go.
One thought I had was to add another attribute, perhaps #[redact(with_string = "[REDACTED]")] that would be mutually exclusive with partial or fixed

Would love to hear what others think about this sort of thing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant