Derive Macro asn1_rs::BerSet

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

§BerSet custom derive

BerSet is a custom derive attribute, to derive a BER Set parser automatically from the structure definition. This attribute will automatically derive implementations for the following traits:

DerSet implies BerSet, and will conflict with this custom derive. Use BerSet when you only want the above traits derived.

Parsers will be automatically derived from struct fields. Every field type must implement the FromBer trait.

See derive documentation for more examples and documentation.

§Examples

To parse the following ASN.1 structure:

S ::= SET {
    a INTEGER(0..2^32),
    b INTEGER(0..2^16),
    c INTEGER(0..2^16),
}

Define a structure and add the BerSet derive:

use asn1_rs::*;

#[derive(BerSet)]
struct S {
  a: u32,
  b: u16,
  c: u16
}

§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(BerSet)]
#[debug_derive]
struct S {
  a: u32,
}