synta 0.1.4

ASN.1 parser, decoder, and encoder library with DER/BER support and C FFI
Documentation
//! Tagged trait for types with ASN.1 tags

use crate::Tag;

/// Trait for types that have a statically known, outermost ASN.1 tag.
///
/// The tag returned by [`tag()`] is the **first byte** (the tag octet) that
/// [`Decode::decode`] expects to see in the input stream, and the tag that
/// [`Encode::encode`] writes at the start of the encoded form.
///
/// This is used by [`ImplicitTag`] to reconstruct the implicit tag's original
/// tag before forwarding to the inner type's `Decode` implementation.
/// It is therefore critical that `tag()` and `Decode::decode` agree on the
/// expected tag value.
///
/// [`Decode::decode`]: crate::Decode::decode
/// [`Encode::encode`]: crate::Encode::encode
/// [`ImplicitTag`]: crate::ImplicitTag
/// [`tag()`]: Self::tag
pub trait Tagged {
    /// Return the outermost ASN.1 tag for this type.
    fn tag() -> Tag;
}