From 9d4fe6fcb842c8c0c06522535c905daf2caf8fba Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Wed, 11 Jan 2023 16:50:40 -0800 Subject: [PATCH] der: add `OctetString::into_bytes()` This makes it possible to extract the owned data without copying. --- der/src/asn1/octet_string.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/der/src/asn1/octet_string.rs b/der/src/asn1/octet_string.rs index f30d3d07c..be57eda30 100644 --- a/der/src/asn1/octet_string.rs +++ b/der/src/asn1/octet_string.rs @@ -132,6 +132,11 @@ mod allocating { self.inner.as_slice() } + /// Take ownership of the octet string. + pub fn into_bytes(self) -> Vec { + self.inner + } + /// Get the length of the inner byte slice. pub fn len(&self) -> Length { self.value_len().expect("invalid OCTET STRING length")