Struct picky_asn1_der::Asn1RawDer
source · pub struct Asn1RawDer(pub Vec<u8>);
Expand description
User-provided raw DER wrapper.
Allow user to provide raw DER: no tag is added by serializer and bytes are bumped as it. Note that provided DER header has to be valid to determine length on deserialization.
Example
use picky_asn1_der::Asn1RawDer;
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, PartialEq, Debug)]
struct A {
number: u8,
user_provided: Asn1RawDer,
}
let plain_a = A {
number: 7,
user_provided: Asn1RawDer(vec![
0x30, 0x08,
0x0C, 0x03, 0x41, 0x62, 0x63,
0x02, 0x01, 0x05,
]),
};
let serialized_a = picky_asn1_der::to_vec(&plain_a).expect("A to vec");
assert_eq!(
serialized_a,
[
0x30, 0x0D,
0x02, 0x01, 0x07,
0x30, 0x08,
0x0C, 0x03, 0x41, 0x62, 0x63,
0x02, 0x01, 0x05,
]
);
let deserialized_a = picky_asn1_der::from_bytes(&serialized_a).expect("A from bytes");
assert_eq!(plain_a, deserialized_a);
// we can deserialize into a compatible B structure.
#[derive(Deserialize, Debug, PartialEq)]
struct B {
number: u8,
tuple: (String, u8),
}
let plain_b = B { number: 7, tuple: ("Abc".to_owned(), 5) };
let deserialized_b: B = picky_asn1_der::from_bytes(&serialized_a).expect("B from bytes");
assert_eq!(deserialized_b, plain_b);
Tuple Fields§
§0: Vec<u8>
Implementations§
Trait Implementations§
source§impl Clone for Asn1RawDer
impl Clone for Asn1RawDer
source§fn clone(&self) -> Asn1RawDer
fn clone(&self) -> Asn1RawDer
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for Asn1RawDer
impl Debug for Asn1RawDer
source§impl<'de> Deserialize<'de> for Asn1RawDer
impl<'de> Deserialize<'de> for Asn1RawDer
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 Hash for Asn1RawDer
impl Hash for Asn1RawDer
source§impl PartialEq<Asn1RawDer> for Asn1RawDer
impl PartialEq<Asn1RawDer> for Asn1RawDer
source§fn eq(&self, other: &Asn1RawDer) -> bool
fn eq(&self, other: &Asn1RawDer) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<Asn1RawDer> for Asn1RawDer
impl PartialOrd<Asn1RawDer> for Asn1RawDer
source§fn partial_cmp(&self, other: &Asn1RawDer) -> Option<Ordering>
fn partial_cmp(&self, other: &Asn1RawDer) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
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 moresource§impl Serialize for Asn1RawDer
impl Serialize for Asn1RawDer
impl Eq for Asn1RawDer
impl StructuralEq for Asn1RawDer
impl StructuralPartialEq for Asn1RawDer
Auto Trait Implementations§
impl RefUnwindSafe for Asn1RawDer
impl Send for Asn1RawDer
impl Sync for Asn1RawDer
impl Unpin for Asn1RawDer
impl UnwindSafe for Asn1RawDer
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more