pub enum ASN1Value {
Show 20 variants
All,
Null,
Boolean(bool),
Choice {
type_name: Option<String>,
variant_name: String,
inner_value: Box<ASN1Value>,
},
SequenceOrSet(Vec<(Option<String>, Box<ASN1Value>)>),
Integer(i128),
Real(f64),
String(String),
BitString(Vec<bool>),
OctetString(Vec<u8>),
EnumeratedValue {
enumerated: String,
enumerable: String,
},
Time(String),
ElsewhereDeclaredValue {
parent: Option<String>,
identifier: String,
},
ObjectIdentifier(ObjectIdentifierValue),
LinkedNestedValue {
supertypes: Vec<String>,
value: Box<ASN1Value>,
},
LinkedIntValue {
integer_type: IntegerType,
value: i128,
},
LinkedStructLikeValue(Vec<(String, ASN1Type, StructLikeFieldValue)>),
LinkedArrayLikeValue(Vec<Box<ASN1Value>>),
LinkedCharStringValue(CharacterStringType, String),
LinkedElsewhereDefinedValue {
parent: Option<String>,
identifier: String,
can_be_const: bool,
},
}
Expand description
The possible types of an ASN1 value.
Variants§
All
Null
Boolean(bool)
Choice
SequenceOrSet(Vec<(Option<String>, Box<ASN1Value>)>)
In ASN.1, value definitions are ambiguous between SEQUENCE, SET, SEQUENCE OF, and SET OF
For example, { my-elem FALSE }
could be a value of all four types
Integer(i128)
Real(f64)
String(String)
BitString(Vec<bool>)
OctetString(Vec<u8>)
EnumeratedValue
Time(String)
ElsewhereDeclaredValue
ObjectIdentifier(ObjectIdentifierValue)
LinkedNestedValue
In ASN1 value declarations, the value type is not straighforward to parse. For example, in the following ASN1
ExampleInt ::= INTEGER
ExampleSubset ::= ExampleInt (1..500)
AnotherSubset ::= ExampleSubset (2..200)
ExampleSet ::= SET {
int AnotherSubset DEFAULT 3
}
the relation of the default value to ExampleSubset
will not be picked up by the lexer.
However, in some representations, this relation is critical information.
LinkedIntValue
Integer values need type information that will not always be picked up by the lexer on first pass.
LinkedStructLikeValue(Vec<(String, ASN1Type, StructLikeFieldValue)>)
Struct-like values such as SEQUENCE values need type information that will not always be picked up by the lexer on first pass. Contains a vector of the struct-like’s fields, with the field name, the field type, and the field value as a tuple
LinkedArrayLikeValue(Vec<Box<ASN1Value>>)
Array-like values such as SEQUENCE OF values need type information that will not always be picked up by the lexer on first pass.
LinkedCharStringValue(CharacterStringType, String)
Character string values such as UTF8String values need type information that will not always be picked up by the lexer on first pass.
LinkedElsewhereDefinedValue
Implementations§
Source§impl ASN1Value
impl ASN1Value
pub fn max( &self, other: &ASN1Value, char_set: Option<&BTreeMap<usize, char>>, ) -> Result<ASN1Value, GrammarError>
pub fn min( &self, other: &ASN1Value, char_set: Option<&BTreeMap<usize, char>>, ) -> Result<ASN1Value, GrammarError>
pub fn unwrap_as_integer(&self) -> Result<i128, GrammarError>
Source§impl ASN1Value
impl ASN1Value
pub fn link_with_type( &mut self, tlds: &BTreeMap<String, ToplevelDefinition>, ty: &ASN1Type, type_name: Option<&String>, ) -> Result<(), GrammarError>
pub fn is_elsewhere_declared(&self) -> bool
Sourcepub fn resolve_elsewhere_with_parent(
&mut self,
tlds: &BTreeMap<String, ToplevelDefinition>,
) -> Result<(), GrammarError>
pub fn resolve_elsewhere_with_parent( &mut self, tlds: &BTreeMap<String, ToplevelDefinition>, ) -> Result<(), GrammarError>
Tries to resolve an ElsewhereDeclaredValue
that references a
path instead of a simple top-level declaration.
§Example
From X501 LDAP System Schema
namingContexts ATTRIBUTE ::= {
WITH SYNTAX DistinguishedName
USAGE dSAOperation
LDAP-SYNTAX dn.&id
LDAP-NAME {"namingContexts"}
ID id-lat-namingContexts
}
The LDAP-SYNTAX
field refers to a field ob an information object dn
.
pub fn link_elsewhere_declared( &mut self, identifier: &String, tlds: &BTreeMap<String, ToplevelDefinition>, ) -> Result<(), GrammarError>
Trait Implementations§
Source§impl From<ASN1Value> for ContentConstraint
impl From<ASN1Value> for ContentConstraint
Source§impl From<ASN1Value> for ValueConstraint
impl From<ASN1Value> for ValueConstraint
impl StructuralPartialEq for ASN1Value
Auto Trait Implementations§
impl Freeze for ASN1Value
impl RefUnwindSafe for ASN1Value
impl Send for ASN1Value
impl Sync for ASN1Value
impl Unpin for ASN1Value
impl UnwindSafe for ASN1Value
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)