summaryrefslogtreecommitdiffstats
path: root/vendor/der/src/asn1/octet_string.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/der/src/asn1/octet_string.rs
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/der/src/asn1/octet_string.rs')
-rw-r--r--vendor/der/src/asn1/octet_string.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/vendor/der/src/asn1/octet_string.rs b/vendor/der/src/asn1/octet_string.rs
index d5eb0dd0f..53d8ecb6a 100644
--- a/vendor/der/src/asn1/octet_string.rs
+++ b/vendor/der/src/asn1/octet_string.rs
@@ -112,7 +112,7 @@ mod allocating {
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
pub struct OctetString {
/// Bitstring represented as a slice of bytes.
- inner: Vec<u8>,
+ pub(super) inner: Vec<u8>,
}
impl OctetString {
@@ -214,6 +214,33 @@ mod allocating {
}
}
+#[cfg(feature = "bytes")]
+mod bytes {
+ use super::OctetString;
+ use crate::{DecodeValue, EncodeValue, FixedTag, Header, Length, Reader, Result, Tag, Writer};
+ use bytes::Bytes;
+
+ impl<'a> DecodeValue<'a> for Bytes {
+ fn decode_value<R: Reader<'a>>(reader: &mut R, header: Header) -> Result<Self> {
+ OctetString::decode_value(reader, header).map(|octet_string| octet_string.inner.into())
+ }
+ }
+
+ impl EncodeValue for Bytes {
+ fn value_len(&self) -> Result<Length> {
+ self.len().try_into()
+ }
+
+ fn encode_value(&self, writer: &mut impl Writer) -> Result<()> {
+ writer.write(self.as_ref())
+ }
+ }
+
+ impl FixedTag for Bytes {
+ const TAG: Tag = Tag::OctetString;
+ }
+}
+
#[cfg(test)]
mod tests {
use crate::asn1::{OctetStringRef, PrintableStringRef};