#[derive(DerSet)]
{
// Attributes available to this derive:
#[debug_derive]
#[default]
#[optional]
#[tag_explicit]
#[tag_implicit]
#[error]
#[map_err]
}
Expand description
DerSet custom derive
DerSet
is a custom derive attribute, to derive both BER and DER Set
parsers automatically from the structure definition.
This attribute will automatically derive implementations for the following traits:
TryFrom<Any>
, also providingFromBer
Tagged
CheckDerConstraints
FromDer
DerSet
implies BerSet
, and will conflict with this custom derive.
Parsers will be automatically derived from struct fields. Every field type must implement the FromDer
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 DerSet
derive:
use asn1_rs::*;
#[derive(DerSet)]
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(DerSet)]
#[debug_derive]
struct S {
a: u32,
}