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;
160160mod allocating {
161161 use super :: * ;
162162 use crate :: referenced:: * ;
163+ use alloc:: borrow:: Cow ;
163164 use alloc:: vec:: Vec ;
164165
165166 /// ASN.1 `OCTET STRING` type: owned form..
@@ -282,6 +283,22 @@ mod allocating {
282283 }
283284 }
284285
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+
285302 // Implement by hand because the derive would create invalid values.
286303 // Use the constructor to create a valid value.
287304 #[ cfg( feature = "arbitrary" ) ]
You can’t perform that action at this time.
0 commit comments