rasn_compiler::intermediate

Enum ASN1Value

Source
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

Fields

§type_name: Option<String>
§variant_name: String
§inner_value: Box<ASN1Value>
§

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

Fields

§enumerated: String
§enumerable: String
§

Time(String)

§

ElsewhereDeclaredValue

Fields

§parent: Option<String>
§identifier: String
§

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.

Fields

§supertypes: Vec<String>

typereferences of supertypes

§

LinkedIntValue

Integer values need type information that will not always be picked up by the lexer on first pass.

Fields

§integer_type: IntegerType
§value: i128
§

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

Fields

§parent: Option<String>
§identifier: String
§can_be_const: bool

Implementations§

Source§

impl ASN1Value

Source

pub fn max( &self, other: &ASN1Value, char_set: Option<&BTreeMap<usize, char>>, ) -> Result<ASN1Value, GrammarError>

Source

pub fn min( &self, other: &ASN1Value, char_set: Option<&BTreeMap<usize, char>>, ) -> Result<ASN1Value, GrammarError>

Source

pub fn unwrap_as_integer(&self) -> Result<i128, GrammarError>

Source§

impl ASN1Value

Source

pub fn is_elsewhere_declared(&self) -> bool

Source

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.

Trait Implementations§

Source§

impl AsMut<ASN1Value> for ASN1Value

Source§

fn as_mut(&mut self) -> &mut ASN1Value

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl Clone for ASN1Value

Source§

fn clone(&self) -> ASN1Value

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ASN1Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<ASN1Value> for ContentConstraint

Source§

fn from(value: ASN1Value) -> Self

Converts to this type from the input type.
Source§

impl From<ASN1Value> for ValueConstraint

Source§

fn from(value: ASN1Value) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for ASN1Value

Source§

fn eq(&self, other: &ASN1Value) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ASN1Value

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.