synta 0.1.3

ASN.1 parser, decoder, and encoder library with DER/BER support and C FFI
Documentation
//! Implicit-tagging decode trait

use crate::error::Result;
use crate::Encoding;

/// Decode the VALUE bytes of an `[N] IMPLICIT`-tagged element.
///
/// After the context tag and length have been consumed from the wire, the
/// remaining `content` bytes are the same bytes that would appear as the value
/// of the inner type under its own tag.  This trait lets a type reconstruct
/// itself directly from those bytes, avoiding a separate allocation for the
/// tag prefix.
///
/// # Implementing this trait
///
/// For primitive types (OCTET STRING, BIT STRING, …) `content` is the raw
/// value bytes with no tag or length wrapper.  For constructed types (SEQUENCE,
/// SET) `content` is the body of the constructed element — the bytes that
/// would follow the SEQUENCE/SET tag and length.
///
/// The derive macro generates this impl automatically for structs with a
/// lifetime parameter.
pub trait DecodeImplicit<'a>: Sized {
    /// Decode from the content bytes of an IMPLICIT-tagged TLV.
    ///
    /// `content` is the value bytes after the context tag and length have
    /// been stripped.  `encoding` is passed through so that sub-decoders can
    /// apply the same rule set (DER / BER / CER).
    fn decode_implicit(content: &'a [u8], encoding: Encoding) -> Result<Self>;
}