//! Decoding trait
use crateDecoder;
use crateResult;
/// Trait for types that can be decoded from ASN.1.
///
/// # Implementing this trait
///
/// An implementation **must** consume exactly the bytes that make up one
/// complete TLV (tag, length, value) triplet from the decoder on success.
/// The decoder cursor must be left pointing at the first byte after the
/// value, ready to read the next element.
///
/// On error, the decoder cursor position is unspecified. Callers that need
/// to recover and continue decoding should save the position before calling
/// `decode` and restore it on failure (or use a peek-based approach).
///
/// The tag consumed by `decode` must match `<Self as Tagged>::tag()` when
/// the `Tagged` trait is also implemented. The [`ImplicitTag`] wrapper
/// relies on this invariant to reconstruct the tag before calling the inner
/// `decode`.
///
/// [`ImplicitTag`]: crate::ImplicitTag