@@ -204,6 +204,18 @@ mod allocating {
204
204
}
205
205
}
206
206
207
+ impl From < OctetStringRef < ' _ > > for Vec < u8 > {
208
+ fn from ( octet_string : OctetStringRef < ' _ > ) -> Vec < u8 > {
209
+ Vec :: from ( octet_string. as_bytes ( ) )
210
+ }
211
+ }
212
+
213
+ impl From < OctetString > for Vec < u8 > {
214
+ fn from ( octet_string : OctetString ) -> Vec < u8 > {
215
+ octet_string. into_bytes ( )
216
+ }
217
+ }
218
+
207
219
// Implement by hand because the derive would create invalid values.
208
220
// Use the constructor to create a valid value.
209
221
#[ cfg( feature = "arbitrary" ) ]
@@ -220,10 +232,11 @@ mod allocating {
220
232
221
233
#[ cfg( feature = "bytes" ) ]
222
234
mod bytes {
223
- use super :: OctetString ;
235
+ use super :: { OctetString , OctetStringRef } ;
224
236
use crate :: {
225
237
DecodeValue , EncodeValue , Error , FixedTag , Header , Length , Reader , Result , Tag , Writer ,
226
238
} ;
239
+ use alloc:: vec:: Vec ;
227
240
use bytes:: Bytes ;
228
241
229
242
impl < ' a > DecodeValue < ' a > for Bytes {
@@ -247,6 +260,18 @@ mod bytes {
247
260
impl FixedTag for Bytes {
248
261
const TAG : Tag = Tag :: OctetString ;
249
262
}
263
+
264
+ impl From < OctetStringRef < ' _ > > for Bytes {
265
+ fn from ( octet_string : OctetStringRef < ' _ > ) -> Bytes {
266
+ Vec :: from ( octet_string) . into ( )
267
+ }
268
+ }
269
+
270
+ impl From < OctetString > for Bytes {
271
+ fn from ( octet_string : OctetString ) -> Bytes {
272
+ Vec :: from ( octet_string) . into ( )
273
+ }
274
+ }
250
275
}
251
276
252
277
#[ cfg( test) ]
0 commit comments