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.