1 use serde::{Deserialize, Serialize};
4 ops::{Deref, DerefMut},
7 #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize, Default)]
9 pub struct Sensitive<T>(T);
11 impl<T> Sensitive<T> {
12 pub fn new(item: T) -> Self {
16 pub fn into_inner(self) -> T {
21 impl<T> std::fmt::Debug for Sensitive<T> {
22 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23 f.debug_struct("Sensitive").finish()
27 impl<T> AsRef<T> for Sensitive<T> {
28 fn as_ref(&self) -> &T {
33 impl AsRef<str> for Sensitive<String> {
34 fn as_ref(&self) -> &str {
39 impl AsRef<[u8]> for Sensitive<String> {
40 fn as_ref(&self) -> &[u8] {
45 impl AsRef<[u8]> for Sensitive<Vec<u8>> {
46 fn as_ref(&self) -> &[u8] {
51 impl<T> AsMut<T> for Sensitive<T> {
52 fn as_mut(&mut self) -> &mut T {
57 impl AsMut<str> for Sensitive<String> {
58 fn as_mut(&mut self) -> &mut str {
63 impl Deref for Sensitive<String> {
66 fn deref(&self) -> &Self::Target {
71 impl DerefMut for Sensitive<String> {
72 fn deref_mut(&mut self) -> &mut Self::Target {
77 impl<T> From<T> for Sensitive<T> {
78 fn from(t: T) -> Self {
83 impl From<&str> for Sensitive<String> {
84 fn from(s: &str) -> Self {
89 impl<T> Borrow<T> for Sensitive<T> {
90 fn borrow(&self) -> &T {
95 impl Borrow<str> for Sensitive<String> {
96 fn borrow(&self) -> &str {