From 6608678e9bb04dfbb430f9dfe5dbfa2da15e14b6 Mon Sep 17 00:00:00 2001 From: dishmaker <141624503+dishmaker@users.noreply.github.com> Date: Fri, 10 Oct 2025 16:13:48 +0200 Subject: [PATCH] der: add doc example for `Decode` --- der/src/decode.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/der/src/decode.rs b/der/src/decode.rs index 452a624c5..58b6b4ba3 100644 --- a/der/src/decode.rs +++ b/der/src/decode.rs @@ -23,6 +23,29 @@ use crate::EncodingRules; /// /// When decoding fails, a [`Decode::Error`] type is thrown. /// Most ASN.1 DER objects return a builtin der [`Error`] type as [`Decode::Error`], which can be made from [`ErrorKind`]. +/// +/// ## Example +/// +/// ``` +/// # #[cfg(all(feature = "alloc", feature = "std"))] +/// # { +/// use der::{Any, Decode, Reader}; +/// +/// /// Wrapper around Any, with custom foreign trait support. +/// /// +/// /// For example: serde Serialize/Deserialize +/// pub struct AnySerde(pub Any); +/// +/// impl<'a> Decode<'a> for AnySerde { +/// type Error = der::Error; +/// +/// fn decode>(reader: &mut R) -> der::Result { +/// // calls impl Decode for Any +/// Ok(Self(Any::decode(reader)?)) +/// } +/// } +/// # } +/// ``` #[diagnostic::on_unimplemented( note = "Consider adding impls of `DecodeValue` and `FixedTag` to `{Self}`" )]