pub enum ToplevelDefinition {
Type(ToplevelTypeDefinition),
Value(ToplevelValueDefinition),
Information(ToplevelInformationDefinition),
}
Expand description
Represents a top-level ASN.1 definition. The compiler distinguished three different variants of top-level definitions.
Type
definitions define custom types based on ASN.1’s built-in typesValue
definitions define values using custom ot built-in typesInformation
definitions define abstraction concepts introduced in ITU-T X.681
The linker and any [Backend] for this compiler consumes top-level definitions in order to generate bindings.
Variants§
Type(ToplevelTypeDefinition)
Value(ToplevelValueDefinition)
Information(ToplevelInformationDefinition)
Implementations§
source§impl ToplevelDefinition
impl ToplevelDefinition
sourcepub fn name(&self) -> &String
pub fn name(&self) -> &String
Returns the name of a top-level definition.
§Example
assert_eq!(
ToplevelDefinition::Value(
ToplevelValueDefinition {
comments: String::from("Comments from the ASN.1 spec"),
name: String::from("the-answer"),
associated_type: String::from("INTEGER"),
value: ASN1Value::Integer(42),
index: None,
}
).name(),
&String::from("the-answer")
);
source§impl ToplevelDefinition
impl ToplevelDefinition
pub fn is_class_with_name( &self, name: &String ) -> Option<&InformationObjectClass>
sourcepub fn has_constraint_reference(&self) -> bool
pub fn has_constraint_reference(&self) -> bool
Traverses a top-level declaration to check for references to other top-level declarations
in a constraint. An example would be the constraint of the intercontinental
field in the
following example.
fifteen INTEGER = 15
Departures ::= SEQUENCE {
local SEQUENCE (SIZE(0..999)) OF Local,
continental SEQUENCE (SIZE(0..99)) OF Continental,
intercontinental SEQUENCE (SIZE(0..fifteen)) OF Intercontinental
}
sourcepub fn link_constraint_reference(
&mut self,
tlds: &BTreeMap<String, ToplevelDefinition>
) -> Result<bool, GrammarError>
pub fn link_constraint_reference( &mut self, tlds: &BTreeMap<String, ToplevelDefinition> ) -> Result<bool, GrammarError>
Traverses a top-level declaration to replace references to other top-level declarations
in a constraint. An example would be the constraint of the intercontinental
field in the
following example.
fifteen INTEGER = 15
Departures ::= SEQUENCE {
local SEQUENCE (SIZE(0..999)) OF Local,
continental SEQUENCE (SIZE(0..99)) OF Continental,
intercontinental SEQUENCE (SIZE(0..fifteen)) OF Intercontinental
}
The method handles linking of multiple constraint references within a top-level declaration.
§Params
tlds
- vector of other top-level declarations that will be searched as the method resolves a reference returnstrue
if the reference was resolved successfully.
sourcepub fn collect_supertypes(
&mut self,
tlds: &BTreeMap<String, ToplevelDefinition>
) -> Result<(), GrammarError>
pub fn collect_supertypes( &mut self, tlds: &BTreeMap<String, ToplevelDefinition> ) -> Result<(), GrammarError>
Collects supertypes of ASN1 values.
Trait Implementations§
source§impl Clone for ToplevelDefinition
impl Clone for ToplevelDefinition
source§fn clone(&self) -> ToplevelDefinition
fn clone(&self) -> ToplevelDefinition
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ToplevelDefinition
impl Debug for ToplevelDefinition
source§impl PartialEq for ToplevelDefinition
impl PartialEq for ToplevelDefinition
source§fn eq(&self, other: &ToplevelDefinition) -> bool
fn eq(&self, other: &ToplevelDefinition) -> bool
self
and other
values to be equal, and is used
by ==
.