Derive Macro asn1_rs::DerAlias

source ·
#[derive(DerAlias)]
{
    // Attributes available to this derive:
    #[debug_derive]
    #[default]
    #[optional]
    #[tag_explicit]
    #[tag_implicit]
    #[error]
    #[map_err]
}
Expand description

§DerAlias custom derive

DerAlias is a custom derive attribute, to derive a DER object parser automatically from the structure definition. This attribute will automatically derive implementations for the following traits:

DerAlias implies BerAlias, and will conflict with this custom derive.

When defining alias, only unnamed (tuple) structs with one field are supported.

Parser will be automatically derived from the struct field. This field type must implement the TryFrom<Any> and FromDer traits.

See derive documentation for more examples and documentation.

§Examples

To parse the following ASN.1 object:

MyInt ::= INTEGER(0..2^32)

Define a structure and add the DerAlias derive:

use asn1_rs::*;

#[derive(DerAlias)]
struct S(pub u32);

§Debugging

To help debugging the generated code, the #[debug_derive] attribute has been added.

When this attribute is specified, the generated code will be printed to stderr during compilation.

Example:

use asn1_rs::*;

#[derive(DerAlias)]
#[debug_derive]
struct S(pub u32);