pub struct OctetStringAsn1Container<Encapsulated>(pub Encapsulated);
Expand description

An OctetString encapsulating things.

Same as BitStringAsn1Container but using an OctetString instead.

Useful to perform a full serialization / deserialization in one pass instead of using OctetStringAsn1 manually.

Examples

use picky_asn1::wrapper::OctetStringAsn1Container;
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, Debug, PartialEq)]
struct MyType {
    a: u32,
    b: u16,
    c: u16,
}

type MyTypeEncapsulated = OctetStringAsn1Container<MyType>;

let encapsulated: MyTypeEncapsulated = MyType {
    a: 83910,
    b: 3839,
    c: 4023,
}.into();

let buffer = [
    0x04, 0x0F, // octet string part
    0x30, 0x0d, // sequence
    0x02, 0x03, 0x01, 0x47, 0xc6, // integer a
    0x02, 0x02, 0x0e, 0xff, // integer b
    0x02, 0x02, 0x0f, 0xb7, // integer c
];

let encoded = picky_asn1_der::to_vec(&encapsulated).expect("couldn't serialize");
assert_eq!(
    encoded,
    buffer,
);

let decoded: MyTypeEncapsulated = picky_asn1_der::from_bytes(&buffer).expect("couldn't deserialize");
assert_eq!(
    decoded,
    encapsulated,
);

Tuple Fields§

§0: Encapsulated

Trait Implementations§

source§

impl<Encapsulated> Asn1Type for OctetStringAsn1Container<Encapsulated>

source§

const TAG: Tag = Tag::OCTET_STRING

source§

const NAME: &'static str = _

source§

impl<Encapsulated: Clone> Clone for OctetStringAsn1Container<Encapsulated>

source§

fn clone(&self) -> OctetStringAsn1Container<Encapsulated>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Encapsulated: Debug> Debug for OctetStringAsn1Container<Encapsulated>

source§

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

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

impl<Encapsulated> Default for OctetStringAsn1Container<Encapsulated>where Encapsulated: Default,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<Encapsulated> Deref for OctetStringAsn1Container<Encapsulated>

§

type Target = Encapsulated

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<Encapsulated> DerefMut for OctetStringAsn1Container<Encapsulated>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<'de, Encapsulated> Deserialize<'de> for OctetStringAsn1Container<Encapsulated>where Encapsulated: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<Encapsulated> From<Encapsulated> for OctetStringAsn1Container<Encapsulated>

source§

fn from(wrapped: Encapsulated) -> Self

Converts to this type from the input type.
source§

impl<Encapsulated: Hash> Hash for OctetStringAsn1Container<Encapsulated>

source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<Encapsulated> PartialEq<Encapsulated> for OctetStringAsn1Container<Encapsulated>where Encapsulated: PartialEq,

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Encapsulated: PartialEq> PartialEq<OctetStringAsn1Container<Encapsulated>> for OctetStringAsn1Container<Encapsulated>

source§

fn eq(&self, other: &OctetStringAsn1Container<Encapsulated>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Encapsulated: PartialOrd> PartialOrd<OctetStringAsn1Container<Encapsulated>> for OctetStringAsn1Container<Encapsulated>

source§

fn partial_cmp( &self, other: &OctetStringAsn1Container<Encapsulated> ) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<Encapsulated> Serialize for OctetStringAsn1Container<Encapsulated>where Encapsulated: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<Encapsulated: Eq> Eq for OctetStringAsn1Container<Encapsulated>

source§

impl<Encapsulated> StructuralEq for OctetStringAsn1Container<Encapsulated>

source§

impl<Encapsulated> StructuralPartialEq for OctetStringAsn1Container<Encapsulated>

Auto Trait Implementations§

§

impl<Encapsulated> RefUnwindSafe for OctetStringAsn1Container<Encapsulated>where Encapsulated: RefUnwindSafe,

§

impl<Encapsulated> Send for OctetStringAsn1Container<Encapsulated>where Encapsulated: Send,

§

impl<Encapsulated> Sync for OctetStringAsn1Container<Encapsulated>where Encapsulated: Sync,

§

impl<Encapsulated> Unpin for OctetStringAsn1Container<Encapsulated>where Encapsulated: Unpin,

§

impl<Encapsulated> UnwindSafe for OctetStringAsn1Container<Encapsulated>where Encapsulated: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,