File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -160,6 +160,7 @@ pub use self::allocating::OctetString;
160
160
mod allocating {
161
161
use super :: * ;
162
162
use crate :: referenced:: * ;
163
+ use alloc:: borrow:: Cow ;
163
164
use alloc:: vec:: Vec ;
164
165
165
166
/// ASN.1 `OCTET STRING` type: owned form..
@@ -282,6 +283,22 @@ mod allocating {
282
283
}
283
284
}
284
285
286
+ impl < ' a > TryFrom < & ' a Cow < ' a , [ u8 ] > > for OctetStringRef < ' a > {
287
+ type Error = Error ;
288
+
289
+ fn try_from ( byte_slice : & ' a Cow < ' a , [ u8 ] > ) -> Result < Self , Error > {
290
+ OctetStringRef :: new ( byte_slice)
291
+ }
292
+ }
293
+
294
+ impl < ' a > TryFrom < OctetStringRef < ' a > > for Cow < ' a , [ u8 ] > {
295
+ type Error = Error ;
296
+
297
+ fn try_from ( octet_string : OctetStringRef < ' a > ) -> Result < Self , Self :: Error > {
298
+ Ok ( Cow :: Borrowed ( octet_string. as_bytes ( ) ) )
299
+ }
300
+ }
301
+
285
302
// Implement by hand because the derive would create invalid values.
286
303
// Use the constructor to create a valid value.
287
304
#[ cfg( feature = "arbitrary" ) ]
You can’t perform that action at this time.
0 commit comments