File tree 1 file changed +21
-0
lines changed
x509-cert/src/ext/pkix/name
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -98,4 +98,25 @@ impl DirectoryString {
98
98
Self :: BmpString ( s) => Cow :: Owned ( s. to_string ( ) ) ,
99
99
}
100
100
}
101
+
102
+ /// Returns `&str` for `PrintableString`, `TeletexString` and `Utf8String`
103
+ ///
104
+ /// Warning: Returns `""` empty string for [`DirectoryString::BmpString`] variant
105
+ #[ deprecated( since = "0.3.0-pre.0" , note = "use `DirectoryString::value` instead" ) ]
106
+ #[ allow( clippy:: should_implement_trait) ]
107
+ pub fn as_ref ( & self ) -> & str {
108
+ match self {
109
+ Self :: PrintableString ( s) => s. as_ref ( ) ,
110
+ Self :: TeletexString ( s) => s. as_ref ( ) ,
111
+ Self :: Utf8String ( s) => s. as_ref ( ) ,
112
+ // BMPString is not str-compatible
113
+ Self :: BmpString ( _s) => "" ,
114
+ }
115
+ }
116
+ }
117
+
118
+ impl From < DirectoryString > for String {
119
+ fn from ( value : DirectoryString ) -> Self {
120
+ value. value ( ) . into_owned ( )
121
+ }
101
122
}
You can’t perform that action at this time.
0 commit comments