Derive Macro asn1_rs::BerAlias

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

BerAlias custom derive

BerAlias is a custom derive attribute, to derive a BER 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. Use BerAlias when you only want the above traits derived.

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> trait.

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 BerAlias derive:

use asn1_rs::*;

#[derive(BerAlias)]
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(BerAlias)]
#[debug_derive]
struct S(pub u32);