Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion der/src/asn1/octet_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,18 @@ mod allocating {
}
}

impl From<OctetStringRef<'_>> for Vec<u8> {
fn from(octet_string: OctetStringRef<'_>) -> Vec<u8> {
Vec::from(octet_string.as_bytes())
}
}

impl From<OctetString> for Vec<u8> {
fn from(octet_string: OctetString) -> Vec<u8> {
octet_string.into_bytes()
}
}

// Implement by hand because the derive would create invalid values.
// Use the constructor to create a valid value.
#[cfg(feature = "arbitrary")]
Expand All @@ -220,10 +232,11 @@ mod allocating {

#[cfg(feature = "bytes")]
mod bytes {
use super::OctetString;
use super::{OctetString, OctetStringRef};
use crate::{
DecodeValue, EncodeValue, Error, FixedTag, Header, Length, Reader, Result, Tag, Writer,
};
use alloc::vec::Vec;
use bytes::Bytes;

impl<'a> DecodeValue<'a> for Bytes {
Expand All @@ -247,6 +260,18 @@ mod bytes {
impl FixedTag for Bytes {
const TAG: Tag = Tag::OctetString;
}

impl From<OctetStringRef<'_>> for Bytes {
fn from(octet_string: OctetStringRef<'_>) -> Bytes {
Vec::from(octet_string).into()
}
}

impl From<OctetString> for Bytes {
fn from(octet_string: OctetString) -> Bytes {
Vec::from(octet_string).into()
}
}
}

#[cfg(test)]
Expand Down