Skip to main content

OctetStringRef

Struct OctetStringRef 

Source
pub struct OctetStringRef { /* private fields */ }
Expand description

ASN.1 OCTET STRING type: borrowed form.

Octet strings represent contiguous sequences of octets, a.k.a. bytes.

This is a zero-copy reference type which borrows from the input data.

Implementations§

Source§

impl OctetStringRef

Source

pub fn new(slice: &[u8]) -> Result<&Self, Error>

Create a new ASN.1 OCTET STRING from a byte slice.

§Errors

Returns Error with ErrorKind::Length in the event slice is too long.

Source

pub fn as_bytes(&self) -> &[u8]

Borrow the inner byte slice.

Source

pub fn len(&self) -> Length

Get the length of the inner byte slice.

Source

pub fn is_empty(&self) -> bool

Is the inner byte slice empty?

Source

pub fn decode_into<'a, T: Decode<'a>>(&'a self) -> Result<T, T::Error>

Parse T from this OCTET STRING’s contents.

§Errors

Returns T::Error in the event a decoding error occurred.

Trait Implementations§

Source§

impl AsRef<[u8]> for OctetStringRef

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<OctetStringRef> for OctetString

Available on crate feature alloc only.
Source§

fn borrow(&self) -> &OctetStringRef

Immutably borrows from an owned value. Read more
Source§

impl Debug for OctetStringRef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> DecodeValue<'a> for &'a OctetStringRef

Source§

type Error = Error

Type returned in the event of a decoding error.
Source§

fn decode_value<R: Reader<'a>>( reader: &mut R, header: Header, ) -> Result<Self, Error>

Attempt to decode this value using the provided Reader. Read more
Source§

impl EncodeValue for &OctetStringRef

Source§

fn value_len(&self) -> Result<Length, Error>

Compute the length of this value (sans Tag+Length header) when encoded as ASN.1 DER. Read more
Source§

fn encode_value(&self, writer: &mut impl Writer) -> Result<(), Error>

Encode value (sans Tag+Length header) as ASN.1 DER using the provided Writer. Read more
Source§

fn header(&self) -> Result<Header>
where Self: Tagged,

Get the Header used to encode this value. Read more
Source§

impl FixedTag for &OctetStringRef

Source§

const TAG: Tag = Tag::OctetString

ASN.1 tag
Source§

impl FixedTag for OctetStringRef

Source§

const TAG: Tag = Tag::OctetString

ASN.1 tag
Source§

impl<'a> From<&'a OctetString> for &'a OctetStringRef

Available on crate feature alloc only.
Source§

fn from(octet_string: &'a OctetString) -> &'a OctetStringRef

Converts to this type from the input type.
Source§

impl<'a> From<&'a OctetStringRef> for &'a [u8]

Source§

fn from(octet_string: &'a OctetStringRef) -> &'a [u8]

Converts to this type from the input type.
Source§

impl<'a> From<&'a OctetStringRef> for AnyRef<'a>

Source§

fn from(octet_string: &'a OctetStringRef) -> AnyRef<'a>

Converts to this type from the input type.
Source§

impl From<&OctetStringRef> for Bytes

Available on crate feature bytes only.
Source§

fn from(octet_string: &OctetStringRef) -> Bytes

Converts to this type from the input type.
Source§

impl From<&OctetStringRef> for OctetString

Available on crate feature alloc only.
Source§

fn from(octet_string_ref: &OctetStringRef) -> OctetString

Converts to this type from the input type.
Source§

impl From<&OctetStringRef> for Vec<u8>

Available on crate feature alloc only.
Source§

fn from(octet_string: &OctetStringRef) -> Vec<u8>

Converts to this type from the input type.
Source§

impl Hash for OctetStringRef

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
Source§

impl Ord for OctetStringRef

Source§

fn cmp(&self, other: &OctetStringRef) -> Ordering

This method returns an Ordering between self and other. Read more
Source§

impl PartialEq for OctetStringRef

Source§

fn eq(&self, other: &OctetStringRef) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for OctetStringRef

Source§

fn partial_cmp(&self, other: &OctetStringRef) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl ToOwned for OctetStringRef

Available on crate feature alloc only.
Source§

type Owned = OctetString

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> OctetString

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<'a> TryFrom<&&'a [u8]> for &'a OctetStringRef

Hack for simplifying the custom derive use case.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(byte_slice: &&'a [u8]) -> Result<Self, Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a [u8]> for &'a OctetStringRef

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(byte_slice: &'a [u8]) -> Result<Self, Error>

Performs the conversion.
Source§

impl<'a, const N: usize> TryFrom<&'a [u8; N]> for &'a OctetStringRef

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(byte_slice: &'a [u8; N]) -> Result<Self, Error>

Performs the conversion.
Source§

impl<'__der: 'a, 'a> TryFrom<&'__der Any> for &'a OctetStringRef

Available on crate feature alloc only.
Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(any: &'__der Any) -> Result<&'a OctetStringRef>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Cow<'a, [u8]>> for &'a OctetStringRef

Available on crate feature alloc only.
Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(byte_slice: &'a Cow<'a, [u8]>) -> Result<Self, Error>

Performs the conversion.
Source§

impl<'a, const N: usize> TryFrom<&'a OctetStringRef> for [u8; N]

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(octet_string: &'a OctetStringRef) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a OctetStringRef> for Cow<'a, [u8]>

Available on crate feature alloc only.
Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(octet_string: &'a OctetStringRef) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<&OctetStringRef> for Vec<u8, N>

Available on crate feature heapless only.
Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(octet_string: &OctetStringRef) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Vec<u8>> for &'a OctetStringRef

Available on crate feature alloc only.

Hack for simplifying the custom derive use case.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(byte_vec: &'a Vec<u8>) -> Result<Self, Error>

Performs the conversion.
Source§

impl<'a, const N: usize> TryFrom<&'a VecInner<u8, usize, VecStorageInner<[MaybeUninit<u8>; N]>>> for &'a OctetStringRef

Available on crate feature heapless only.
Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(byte_vec: &'a Vec<u8, N>) -> Result<Self, Error>

Performs the conversion.
Source§

impl<'__der: 'a, 'a> TryFrom<AnyRef<'__der>> for &'a OctetStringRef

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(any: AnyRef<'__der>) -> Result<&'a OctetStringRef>

Performs the conversion.
Source§

impl Eq for OctetStringRef

Source§

impl StructuralPartialEq for OctetStringRef

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> IsConstructed for T
where T: FixedTag + ?Sized,

Source§

const CONSTRUCTED: bool = const CONSTRUCTED: bool = T::TAG.is_constructed();

ASN.1 constructed bit
Source§

impl<T> Tagged for T
where T: FixedTag + ?Sized,

Source§

fn tag(&self) -> Tag

Get the ASN.1 tag that this type is encoded with.