1 use serde::{Deserialize, Serialize};
4 ops::{Deref, DerefMut},
6 #[cfg(feature = "full")]
9 #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize, Default)]
11 pub struct Sensitive<T>(T);
13 impl<T> Sensitive<T> {
14 pub fn new(item: T) -> Self {
17 pub fn into_inner(self) -> T {
22 impl<T> std::fmt::Debug for Sensitive<T> {
23 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
24 f.debug_struct("Sensitive").finish()
28 impl<T> AsRef<T> for Sensitive<T> {
29 fn as_ref(&self) -> &T {
34 impl AsRef<str> for Sensitive<String> {
35 fn as_ref(&self) -> &str {
40 impl AsRef<[u8]> for Sensitive<String> {
41 fn as_ref(&self) -> &[u8] {
46 impl AsRef<[u8]> for Sensitive<Vec<u8>> {
47 fn as_ref(&self) -> &[u8] {
52 impl<T> AsMut<T> for Sensitive<T> {
53 fn as_mut(&mut self) -> &mut T {
58 impl AsMut<str> for Sensitive<String> {
59 fn as_mut(&mut self) -> &mut str {
64 impl Deref for Sensitive<String> {
67 fn deref(&self) -> &Self::Target {
72 impl DerefMut for Sensitive<String> {
73 fn deref_mut(&mut self) -> &mut Self::Target {
78 impl<T> From<T> for Sensitive<T> {
79 fn from(t: T) -> Self {
84 impl From<&str> for Sensitive<String> {
85 fn from(s: &str) -> Self {
90 impl<T> Borrow<T> for Sensitive<T> {
91 fn borrow(&self) -> &T {
96 impl Borrow<str> for Sensitive<String> {
97 fn borrow(&self) -> &str {
102 #[cfg(feature = "full")]
103 impl TS for Sensitive<String> {
104 fn name() -> String {
107 fn name_with_type_args(_args: Vec<String>) -> String {
110 fn dependencies() -> Vec<ts_rs::Dependency> {
113 fn transparent() -> bool {