[−][src]Struct picky_asn1::wrapper::Implicit
Wrapper for ASN.1 implicits (optionals) fields
Wrapped type has to implement the Default trait to be deserializable (on deserialization failure a default value is returned).
Examples:
use picky_asn1::wrapper::{Implicit, ApplicationTag0}; use serde::{Serialize, Deserialize}; #[derive(Serialize, Deserialize, Debug, PartialEq)] struct MyWrapper(u8); impl Default for MyWrapper { fn default() -> Self { Self(10) } } #[derive(Serialize, Deserialize, Debug, PartialEq)] struct ComplexType { // skip if default to reduce encoded size #[serde(skip_serializing_if = "implicit_field_is_default")] optional_field: Implicit<MyWrapper>, // behind application tag 0 to distinguish from optional_field that is a ASN.1 integer too. explicit_field: ApplicationTag0<u8>, } fn implicit_field_is_default(wrapper: &Implicit<MyWrapper>) -> bool { wrapper.0 == MyWrapper::default() } let complex_type = ComplexType { optional_field: MyWrapper::default().into(), explicit_field: 5.into(), }; let buffer = [ 0x30, 0x05, // sequence // optional field isn't present 0xA0, 0x03, 0x02, 0x01, 0x05, // explicit field ]; let encoded = picky_asn1_der::to_vec(&complex_type).expect("couldn't serialize"); assert_eq!( encoded, buffer, ); let decoded: ComplexType = picky_asn1_der::from_bytes(&buffer).expect("couldn't deserialize"); assert_eq!( decoded, complex_type, );
Trait Implementations
impl<T: Clone> Clone for Implicit<T>
[src]
impl<T: Debug> Debug for Implicit<T>
[src]
impl<T> Deref for Implicit<T>
[src]
impl<T> DerefMut for Implicit<T>
[src]
impl<'de, T> Deserialize<'de> for Implicit<T> where
T: Deserialize<'de> + Default,
[src]
T: Deserialize<'de> + Default,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl<T> From<T> for Implicit<T>
[src]
impl<T: Hash> Hash for Implicit<T>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T: PartialEq> PartialEq<Implicit<T>> for Implicit<T>
[src]
impl<T> PartialEq<T> for Implicit<T> where
T: PartialEq,
[src]
T: PartialEq,
impl<T: PartialOrd> PartialOrd<Implicit<T>> for Implicit<T>
[src]
fn partial_cmp(&self, other: &Implicit<T>) -> Option<Ordering>
[src]
fn lt(&self, other: &Implicit<T>) -> bool
[src]
fn le(&self, other: &Implicit<T>) -> bool
[src]
fn gt(&self, other: &Implicit<T>) -> bool
[src]
fn ge(&self, other: &Implicit<T>) -> bool
[src]
impl<T> Serialize for Implicit<T> where
T: Serialize,
[src]
T: Serialize,
impl<T> StructuralPartialEq for Implicit<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Implicit<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Implicit<T> where
T: Send,
T: Send,
impl<T> Sync for Implicit<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Implicit<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Implicit<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<!> for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,