diff --git a/rasn-compiler-tests/tests/edge_cases.rs b/rasn-compiler-tests/tests/edge_cases.rs index 04351632..5790dcc9 100644 --- a/rasn-compiler-tests/tests/edge_cases.rs +++ b/rasn-compiler-tests/tests/edge_cases.rs @@ -126,3 +126,56 @@ e2e_pdu!( LDAPString ::= [UNIVERSAL 4] IMPLICIT UTF8String "# ); + +e2e_pdu!( + constrained_integer_newtype_default, + r#" + UInt8 ::= INTEGER (0..255) + MySeq ::= SEQUENCE { + value UInt8 DEFAULT 8 + } + "# +); + +e2e_pdu!( + sequence_of_newtype_default, + r#" + MyOctet ::= OCTET STRING + OctetList ::= SEQUENCE OF MyOctet + MySeq ::= SEQUENCE { + data OctetList DEFAULT { 'CAFE'H, 'BABE'H } + } + "# +); + +#[test] +fn inline_constrained_integer_default() { + // INTEGER with inline constraint should NOT wrap in newtype + let generated = rasn_compiler::Compiler::::new() + .add_asn_literal( + r#" + TestModule DEFINITIONS AUTOMATIC TAGS ::= BEGIN + TestSeq ::= SEQUENCE { + count INTEGER (0..255) DEFAULT 1, + bigCount INTEGER (0..4294967295) DEFAULT 100 + } + END + "#, + ) + .compile_to_string() + .unwrap() + .generated; + + // Should NOT generate U8(1) or U32(100) - just bare literals + assert!( + !generated.contains("U8(1)") && !generated.contains("U32(100)"), + "Inline constrained integers should not be wrapped. Generated:\n{}", + generated + ); + let normalized = generated.replace(' ', ""); + assert!( + normalized.contains("fntest_seq_count_default()->u8") && normalized.contains("{1}"), + "Should generate bare integer literal. Generated:\n{}", + generated + ); +} diff --git a/rasn-compiler-tests/tests/external_module_mapping.rs b/rasn-compiler-tests/tests/external_module_mapping.rs new file mode 100644 index 00000000..894e19c0 --- /dev/null +++ b/rasn-compiler-tests/tests/external_module_mapping.rs @@ -0,0 +1,224 @@ +//! Tests for external module mapping feature. +//! +//! This feature allows mapping ASN.1 module names to external Rust crate paths, +//! so that IMPORTS from those modules generate `use crate_path::Type;` instead +//! of `use super::module_name::Type;`. + +use std::collections::HashMap; + +use rasn_compiler::prelude::*; + +/// Test that external module mapping generates correct import statements. +#[test] +fn external_module_mapping_generates_correct_import() { + let mut config = RasnConfig::default(); + + // Map PKIX1Explicit88 to rasn_pkix crate + config.external_module_mappings.insert( + "PKIX1Explicit88".to_string(), + ExternalModuleMapping { + rust_path: "rasn_pkix".to_string(), + type_mappings: HashMap::new(), + }, + ); + + let asn1 = r#" + TestModule DEFINITIONS AUTOMATIC TAGS ::= BEGIN + IMPORTS Certificate FROM PKIX1Explicit88 { 1 2 3 }; + + MyCert ::= Certificate + END + "#; + + let result = Compiler::::new_with_config(config) + .add_asn_literal(asn1) + .compile_to_string() + .unwrap(); + + // Verify the generated code uses external crate import (handle unformatted output) + let normalized = result.generated.replace(' ', ""); + assert!( + normalized.contains("pubuserasn_pkix::{Certificate"), + "Expected external crate import, got:\n{}", + result.generated + ); + + // Verify it does NOT use sibling module import + assert!( + !normalized.contains("super::pkix1_explicit88"), + "Should not have sibling module import, got:\n{}", + result.generated + ); +} + +/// Test external module mapping with multiple types imported. +#[test] +fn external_module_mapping_multiple_types() { + let mut config = RasnConfig::default(); + + config.external_module_mappings.insert( + "PKIX1Explicit88".to_string(), + ExternalModuleMapping { + rust_path: "rasn_pkix".to_string(), + type_mappings: HashMap::new(), + }, + ); + + let asn1 = r#" + TestModule DEFINITIONS AUTOMATIC TAGS ::= BEGIN + IMPORTS Certificate, CertificateList, Time FROM PKIX1Explicit88 { 1 2 3 }; + + MyCert ::= Certificate + MyList ::= CertificateList + END + "#; + + let result = Compiler::::new_with_config(config) + .add_asn_literal(asn1) + .compile_to_string() + .unwrap(); + + // Verify all types are imported from external crate (handle unformatted output) + let normalized = result.generated.replace(' ', ""); + assert!( + normalized.contains("pubuserasn_pkix::{") + && normalized.contains("Certificate") + && normalized.contains("CertificateList") + && normalized.contains("Time"), + "Expected all types from external crate, got:\n{}", + result.generated + ); + + // Verify no sibling imports for PKIX + assert!( + !normalized.contains("super::pkix1_explicit88"), + "Should not have sibling module import" + ); +} + +/// Test external module mapping with explicit type name mapping. +#[test] +fn external_module_mapping_with_type_mapping() { + let mut config = RasnConfig::default(); + + let mut type_mappings = HashMap::new(); + // Map ASN.1 type name to different Rust type name + type_mappings.insert("MyAsn1Type".to_string(), "RustTypeName".to_string()); + + config.external_module_mappings.insert( + "ExternalModule".to_string(), + ExternalModuleMapping { + rust_path: "my_crate::submodule".to_string(), + type_mappings, + }, + ); + + let asn1 = r#" + TestModule DEFINITIONS AUTOMATIC TAGS ::= BEGIN + IMPORTS MyAsn1Type FROM ExternalModule { 1 2 3 }; + + MyType ::= MyAsn1Type + END + "#; + + let result = Compiler::::new_with_config(config) + .add_asn_literal(asn1) + .compile_to_string() + .unwrap(); + + // Verify the mapped type name is used in the import (handle unformatted output) + let normalized = result.generated.replace(' ', ""); + assert!( + normalized.contains("pubusemy_crate::submodule::{RustTypeName"), + "Expected mapped type name in import, got:\n{}", + result.generated + ); +} + +/// Test that unmapped modules still use default sibling import. +#[test] +fn unmapped_module_uses_sibling_import() { + let mut config = RasnConfig::default(); + + // Only map one module + config.external_module_mappings.insert( + "MappedModule".to_string(), + ExternalModuleMapping { + rust_path: "mapped_crate".to_string(), + type_mappings: HashMap::new(), + }, + ); + + // Note: multiple IMPORTS statements need to be combined in ASN.1 + let asn1 = r#" + TestModule DEFINITIONS AUTOMATIC TAGS ::= BEGIN + IMPORTS + MappedType FROM MappedModule { 1 2 3 } + UnmappedType FROM UnmappedModule { 1 2 3 }; + + MyType1 ::= MappedType + MyType2 ::= UnmappedType + END + "#; + + let result = Compiler::::new_with_config(config) + .add_asn_literal(asn1) + .compile_to_string() + .unwrap(); + + // Verify mapped module uses external import (handle unformatted output) + let normalized = result.generated.replace(' ', ""); + assert!( + normalized.contains("pubusemapped_crate::{"), + "Expected external crate import for mapped module, got:\n{}", + result.generated + ); + + // Verify unmapped module uses sibling import + assert!( + normalized.contains("pubusesuper::unmapped_module::{"), + "Expected sibling import for unmapped module, got:\n{}", + result.generated + ); +} + +/// Test external module mapping with lowercase constant imports. +#[test] +fn external_module_mapping_with_constant() { + let mut config = RasnConfig::default(); + + config.external_module_mappings.insert( + "ConstModule".to_string(), + ExternalModuleMapping { + rust_path: "const_crate".to_string(), + type_mappings: HashMap::new(), + }, + ); + + let asn1 = r#" + TestModule DEFINITIONS AUTOMATIC TAGS ::= BEGIN + IMPORTS myConstant, MyType FROM ConstModule { 1 2 3 }; + + MyLocalType ::= MyType + END + "#; + + let result = Compiler::::new_with_config(config) + .add_asn_literal(asn1) + .compile_to_string() + .unwrap(); + + // Verify constant is imported with correct case (SCREAMING_SNAKE_CASE) + assert!( + result.generated.contains("MY_CONSTANT"), + "Expected constant with SCREAMING_SNAKE_CASE, got:\n{}", + result.generated + ); + + // Verify type is also imported + assert!( + result.generated.contains("MyType"), + "Expected type to be imported, got:\n{}", + result.generated + ); +} diff --git a/rasn-compiler-tests/tests/snapshots/edge_cases__constrained_integer_newtype_default.snap b/rasn-compiler-tests/tests/snapshots/edge_cases__constrained_integer_newtype_default.snap new file mode 100644 index 00000000..f8b1ad88 --- /dev/null +++ b/rasn-compiler-tests/tests/snapshots/edge_cases__constrained_integer_newtype_default.snap @@ -0,0 +1,6 @@ +--- +source: rasn-compiler-tests/tests/edge_cases.rs +description: "\n UInt8 ::= INTEGER (0..255)\n MySeq ::= SEQUENCE {\n value UInt8 DEFAULT 8\n }\n " +--- +Generated: +# [allow (non_camel_case_types , non_snake_case , non_upper_case_globals , unused , clippy :: too_many_arguments ,)] pub mod test_module { extern crate alloc ; use core :: borrow :: Borrow ; use std :: sync :: LazyLock ; use rasn :: prelude :: * ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (automatic_tags)] pub struct MySeq { # [rasn (default = "my_seq_value_default")] pub value : UInt8 , } impl MySeq { pub fn new (value : UInt8) -> Self { Self { value } } } impl std :: default :: Default for MySeq { fn default () -> Self { Self { value : my_seq_value_default () } } } fn my_seq_value_default () -> UInt8 { UInt8 (8) } # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate , value ("0..=255"))] pub struct UInt8 (pub u8) ; } diff --git a/rasn-compiler-tests/tests/snapshots/edge_cases__distinguished_value_range.snap b/rasn-compiler-tests/tests/snapshots/edge_cases__distinguished_value_range.snap index 2d98fa67..b9553ded 100644 --- a/rasn-compiler-tests/tests/snapshots/edge_cases__distinguished_value_range.snap +++ b/rasn-compiler-tests/tests/snapshots/edge_cases__distinguished_value_range.snap @@ -3,22 +3,4 @@ source: rasn-compiler-tests/tests/edge_cases.rs description: " Restricted ::= Distinguished (second|fourth..sixth|eighth)\n Distinguished ::= INTEGER {\n first(1),\n second(2),\n third(3),\n fourth(4),\n fifth(5),\n sixth(6),\n seventh(7),\n eighth(8),\n ninth(9),\n tenth(10),\n } (1..10)" --- Generated: -#[allow( - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - unused, - clippy::too_many_arguments -)] -pub mod test_module { - extern crate alloc; - use core::borrow::Borrow; - use rasn::prelude::*; - use std::sync::LazyLock; - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate, value("1..=10"))] - pub struct Distinguished(pub u8); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate, value("2..=8"))] - pub struct Restricted(pub Distinguished); -} +# [allow (non_camel_case_types , non_snake_case , non_upper_case_globals , unused , clippy :: too_many_arguments ,)] pub mod test_module { extern crate alloc ; use core :: borrow :: Borrow ; use std :: sync :: LazyLock ; use rasn :: prelude :: * ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate , value ("1..=10"))] pub struct Distinguished (pub u8) ; impl Distinguished { pub const FIRST : Self = Self (1) ; pub const SECOND : Self = Self (2) ; pub const THIRD : Self = Self (3) ; pub const FOURTH : Self = Self (4) ; pub const FIFTH : Self = Self (5) ; pub const SIXTH : Self = Self (6) ; pub const SEVENTH : Self = Self (7) ; pub const EIGHTH : Self = Self (8) ; pub const NINTH : Self = Self (9) ; pub const TENTH : Self = Self (10) ; } # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate , value ("2..=8"))] pub struct Restricted (pub Distinguished) ; } diff --git a/rasn-compiler-tests/tests/snapshots/edge_cases__distinguished_value_range_in_choice.snap b/rasn-compiler-tests/tests/snapshots/edge_cases__distinguished_value_range_in_choice.snap index f892b60c..8d62fb1b 100644 --- a/rasn-compiler-tests/tests/snapshots/edge_cases__distinguished_value_range_in_choice.snap +++ b/rasn-compiler-tests/tests/snapshots/edge_cases__distinguished_value_range_in_choice.snap @@ -3,26 +3,4 @@ source: rasn-compiler-tests/tests/edge_cases.rs description: "\n TestChoice ::= CHOICE {\n restricted Distinguished (second|fourth..sixth|eighth),\n ...\n }\n Distinguished ::= INTEGER {\n first(1),\n second(2),\n third(3),\n fourth(4),\n fifth(5),\n sixth(6),\n seventh(7),\n eighth(8),\n ninth(9),\n tenth(10),\n } (1..10)" --- Generated: -#[allow( - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - unused, - clippy::too_many_arguments -)] -pub mod test_module { - extern crate alloc; - use core::borrow::Borrow; - use rasn::prelude::*; - use std::sync::LazyLock; - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate, value("1..=10"))] - pub struct Distinguished(pub u8); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(choice, automatic_tags)] - #[non_exhaustive] - pub enum TestChoice { - #[rasn(value("2..=8"))] - restricted(Distinguished), - } -} +# [allow (non_camel_case_types , non_snake_case , non_upper_case_globals , unused , clippy :: too_many_arguments ,)] pub mod test_module { extern crate alloc ; use core :: borrow :: Borrow ; use std :: sync :: LazyLock ; use rasn :: prelude :: * ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate , value ("1..=10"))] pub struct Distinguished (pub u8) ; impl Distinguished { pub const FIRST : Self = Self (1) ; pub const SECOND : Self = Self (2) ; pub const THIRD : Self = Self (3) ; pub const FOURTH : Self = Self (4) ; pub const FIFTH : Self = Self (5) ; pub const SIXTH : Self = Self (6) ; pub const SEVENTH : Self = Self (7) ; pub const EIGHTH : Self = Self (8) ; pub const NINTH : Self = Self (9) ; pub const TENTH : Self = Self (10) ; } # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (choice)] # [non_exhaustive] pub enum TestChoice { # [rasn (value ("2..=8") , tag (context , 0))] restricted (Distinguished) , } } diff --git a/rasn-compiler-tests/tests/snapshots/edge_cases__distinguished_value_range_in_choice_from_impl.snap b/rasn-compiler-tests/tests/snapshots/edge_cases__distinguished_value_range_in_choice_from_impl.snap index b072f8f9..34053037 100644 --- a/rasn-compiler-tests/tests/snapshots/edge_cases__distinguished_value_range_in_choice_from_impl.snap +++ b/rasn-compiler-tests/tests/snapshots/edge_cases__distinguished_value_range_in_choice_from_impl.snap @@ -3,31 +3,4 @@ source: rasn-compiler-tests/tests/edge_cases.rs description: "\n TestChoice ::= CHOICE {\n restricted Distinguished (second|fourth..sixth|eighth),\n ...\n }\n Distinguished ::= INTEGER {\n first(1),\n second(2),\n third(3),\n fourth(4),\n fifth(5),\n sixth(6),\n seventh(7),\n eighth(8),\n ninth(9),\n tenth(10),\n } (1..10)" --- Generated: -#[allow( - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - unused, - clippy::too_many_arguments -)] -pub mod test_module { - extern crate alloc; - use core::borrow::Borrow; - use rasn::prelude::*; - use std::sync::LazyLock; - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate, value("1..=10"))] - pub struct Distinguished(pub u8); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(choice, automatic_tags)] - #[non_exhaustive] - pub enum TestChoice { - #[rasn(value("2..=8"))] - restricted(Distinguished), - } - impl From for TestChoice { - fn from(value: Distinguished) -> Self { - Self::restricted(value) - } - } -} +# [allow (non_camel_case_types , non_snake_case , non_upper_case_globals , unused , clippy :: too_many_arguments ,)] pub mod test_module { extern crate alloc ; use core :: borrow :: Borrow ; use std :: sync :: LazyLock ; use rasn :: prelude :: * ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate , value ("1..=10"))] pub struct Distinguished (pub u8) ; impl Distinguished { pub const FIRST : Self = Self (1) ; pub const SECOND : Self = Self (2) ; pub const THIRD : Self = Self (3) ; pub const FOURTH : Self = Self (4) ; pub const FIFTH : Self = Self (5) ; pub const SIXTH : Self = Self (6) ; pub const SEVENTH : Self = Self (7) ; pub const EIGHTH : Self = Self (8) ; pub const NINTH : Self = Self (9) ; pub const TENTH : Self = Self (10) ; } # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (choice)] # [non_exhaustive] pub enum TestChoice { # [rasn (value ("2..=8") , tag (context , 0))] restricted (Distinguished) , } impl From < Distinguished > for TestChoice { fn from (value : Distinguished) -> Self { Self :: restricted (value) } } } diff --git a/rasn-compiler-tests/tests/snapshots/edge_cases__enum_and_distinguished_defaults.snap b/rasn-compiler-tests/tests/snapshots/edge_cases__enum_and_distinguished_defaults.snap index f69316b5..a02e8d40 100644 --- a/rasn-compiler-tests/tests/snapshots/edge_cases__enum_and_distinguished_defaults.snap +++ b/rasn-compiler-tests/tests/snapshots/edge_cases__enum_and_distinguished_defaults.snap @@ -3,52 +3,4 @@ source: rasn-compiler-tests/tests/edge_cases.rs description: "\n Test ::= SEQUENCE {\n int IntWithDefault DEFAULT first,\n enum EnumWithDefault DEFAULT first,\n }\n\n IntWithDefault ::= INTEGER {\n first(1),\n second(2)\n } (1..10)\n\n EnumWithDefault ::= ENUMERATED {\n first(1),\n second(2)\n }\n " --- Generated: -#[allow( - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - unused, - clippy::too_many_arguments -)] -pub mod test_module { - extern crate alloc; - use core::borrow::Borrow; - use rasn::prelude::*; - use std::sync::LazyLock; - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] - #[rasn(enumerated)] - pub enum EnumWithDefault { - first = 1, - second = 2, - } - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate, value("1..=10"))] - pub struct IntWithDefault(pub u8); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(automatic_tags)] - pub struct Test { - #[rasn(default = "test_int_default")] - pub int: IntWithDefault, - #[rasn(default = "test_r_enum_default", identifier = "enum")] - pub r_enum: EnumWithDefault, - } - impl Test { - pub fn new(int: IntWithDefault, r_enum: EnumWithDefault) -> Self { - Self { int, r_enum } - } - } - impl std::default::Default for Test { - fn default() -> Self { - Self { - int: test_int_default(), - r_enum: test_r_enum_default(), - } - } - } - fn test_int_default() -> IntWithDefault { - IntWithDefault(1) - } - fn test_r_enum_default() -> EnumWithDefault { - EnumWithDefault::first - } -} +# [allow (non_camel_case_types , non_snake_case , non_upper_case_globals , unused , clippy :: too_many_arguments ,)] pub mod test_module { extern crate alloc ; use core :: borrow :: Borrow ; use std :: sync :: LazyLock ; use rasn :: prelude :: * ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash , Copy)] # [rasn (enumerated)] pub enum EnumWithDefault { first = 1 , second = 2 , } # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate , value ("1..=10"))] pub struct IntWithDefault (pub u8) ; impl IntWithDefault { pub const FIRST : Self = Self (1) ; pub const SECOND : Self = Self (2) ; } # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (automatic_tags)] pub struct Test { # [rasn (default = "test_int_default")] pub int : IntWithDefault , # [rasn (default = "test_r_enum_default" , identifier = "enum")] pub r_enum : EnumWithDefault , } impl Test { pub fn new (int : IntWithDefault , r_enum : EnumWithDefault) -> Self { Self { int , r_enum } } } impl std :: default :: Default for Test { fn default () -> Self { Self { int : test_int_default () , r_enum : test_r_enum_default () } } } fn test_int_default () -> IntWithDefault { IntWithDefault (1) } fn test_r_enum_default () -> EnumWithDefault { EnumWithDefault :: first } } diff --git a/rasn-compiler-tests/tests/snapshots/edge_cases__recursive_type.snap b/rasn-compiler-tests/tests/snapshots/edge_cases__recursive_type.snap index f1def992..0cded9bc 100644 --- a/rasn-compiler-tests/tests/snapshots/edge_cases__recursive_type.snap +++ b/rasn-compiler-tests/tests/snapshots/edge_cases__recursive_type.snap @@ -3,54 +3,4 @@ source: rasn-compiler-tests/tests/edge_cases.rs description: "\n Filter ::= CHOICE {\n and [0] SET SIZE (1..MAX) OF filter Filter,\n or [1] SET SIZE (1..MAX) OF filter Filter,\n not [2] Filter,\n equalityMatch [3] AttributeValueAssertion,\n ...\n }\n\n AttributeValueAssertion ::= SEQUENCE {\n attributeDesc AttributeDescription,\n assertionValue AssertionValue }\n\n AssertionValue ::= OCTET STRING\n\n AttributeDescription ::= LDAPString\n\n LDAPString ::= [UNIVERSAL 4] IMPLICIT UTF8String\n " --- Generated: -#[allow( - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - unused, - clippy::too_many_arguments -)] -pub mod test_module { - extern crate alloc; - use core::borrow::Borrow; - use rasn::prelude::*; - use std::sync::LazyLock; - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate)] - pub struct AssertionValue(pub OctetString); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate)] - pub struct AttributeDescription(pub LDAPString); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(automatic_tags)] - pub struct AttributeValueAssertion { - #[rasn(identifier = "attributeDesc")] - pub attribute_desc: AttributeDescription, - #[rasn(identifier = "assertionValue")] - pub assertion_value: AssertionValue, - } - impl AttributeValueAssertion { - pub fn new(attribute_desc: AttributeDescription, assertion_value: AssertionValue) -> Self { - Self { - attribute_desc, - assertion_value, - } - } - } - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(choice)] - #[non_exhaustive] - pub enum Filter { - #[rasn(size("1.."), tag(context, 0))] - and(SetOf), - #[rasn(size("1.."), tag(context, 1))] - or(SetOf), - #[rasn(tag(context, 2))] - not(Box), - #[rasn(tag(context, 3))] - equalityMatch(AttributeValueAssertion), - } - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate, tag(universal, 4))] - pub struct LDAPString(pub Utf8String); -} +# [allow (non_camel_case_types , non_snake_case , non_upper_case_globals , unused , clippy :: too_many_arguments ,)] pub mod test_module { extern crate alloc ; use core :: borrow :: Borrow ; use std :: sync :: LazyLock ; use rasn :: prelude :: * ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate)] pub struct AssertionValue (pub OctetString) ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate)] pub struct AttributeDescription (pub LDAPString) ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (automatic_tags)] pub struct AttributeValueAssertion { # [rasn (identifier = "attributeDesc")] pub attribute_desc : AttributeDescription , # [rasn (identifier = "assertionValue")] pub assertion_value : AssertionValue , } impl AttributeValueAssertion { pub fn new (attribute_desc : AttributeDescription , assertion_value : AssertionValue) -> Self { Self { attribute_desc , assertion_value } } } # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (choice)] # [non_exhaustive] pub enum Filter { # [rasn (size ("1..") , tag (context , 0))] and (SetOf < Filter >) , # [rasn (size ("1..") , tag (context , 1))] or (SetOf < Filter >) , # [rasn (tag (context , 2))] not (Box < Filter >) , # [rasn (tag (context , 3))] equalityMatch (AttributeValueAssertion) , } # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate , tag (universal , 4))] pub struct LDAPString (pub Utf8String) ; } diff --git a/rasn-compiler-tests/tests/snapshots/edge_cases__same_variant_name.snap b/rasn-compiler-tests/tests/snapshots/edge_cases__same_variant_name.snap index b20ea8d0..c584dfe4 100644 --- a/rasn-compiler-tests/tests/snapshots/edge_cases__same_variant_name.snap +++ b/rasn-compiler-tests/tests/snapshots/edge_cases__same_variant_name.snap @@ -3,35 +3,4 @@ source: rasn-compiler-tests/tests/edge_cases.rs description: "\n ChoiceType ::= CHOICE {\n number INTEGER,\n anotherNumber INTEGER,\n bool BOOLEAN,\n oneMoreNumber INTEGER,\n aString IA5String\n }\n " --- Generated: -#[allow( - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - unused, - clippy::too_many_arguments -)] -pub mod test_module { - extern crate alloc; - use core::borrow::Borrow; - use rasn::prelude::*; - use std::sync::LazyLock; - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(choice, automatic_tags)] - pub enum ChoiceType { - number(Integer), - anotherNumber(Integer), - bool(bool), - oneMoreNumber(Integer), - aString(Ia5String), - } - impl From for ChoiceType { - fn from(value: bool) -> Self { - Self::bool(value) - } - } - impl From for ChoiceType { - fn from(value: Ia5String) -> Self { - Self::aString(value) - } - } -} +# [allow (non_camel_case_types , non_snake_case , non_upper_case_globals , unused , clippy :: too_many_arguments ,)] pub mod test_module { extern crate alloc ; use core :: borrow :: Borrow ; use std :: sync :: LazyLock ; use rasn :: prelude :: * ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (choice)] pub enum ChoiceType { # [rasn (tag (context , 0))] number (Integer) , # [rasn (tag (context , 1))] anotherNumber (Integer) , # [rasn (tag (context , 2))] bool (bool) , # [rasn (tag (context , 3))] oneMoreNumber (Integer) , # [rasn (tag (context , 4))] aString (Ia5String) , } impl From < bool > for ChoiceType { fn from (value : bool) -> Self { Self :: bool (value) } } impl From < Ia5String > for ChoiceType { fn from (value : Ia5String) -> Self { Self :: aString (value) } } } diff --git a/rasn-compiler-tests/tests/snapshots/edge_cases__sequence_of_newtype_default.snap b/rasn-compiler-tests/tests/snapshots/edge_cases__sequence_of_newtype_default.snap new file mode 100644 index 00000000..452e9b5a --- /dev/null +++ b/rasn-compiler-tests/tests/snapshots/edge_cases__sequence_of_newtype_default.snap @@ -0,0 +1,6 @@ +--- +source: rasn-compiler-tests/tests/edge_cases.rs +description: "\n MyOctet ::= OCTET STRING\n OctetList ::= SEQUENCE OF MyOctet\n MySeq ::= SEQUENCE {\n data OctetList DEFAULT { 'CAFE'H, 'BABE'H }\n }\n " +--- +Generated: +# [allow (non_camel_case_types , non_snake_case , non_upper_case_globals , unused , clippy :: too_many_arguments ,)] pub mod test_module { extern crate alloc ; use core :: borrow :: Borrow ; use std :: sync :: LazyLock ; use rasn :: prelude :: * ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate)] pub struct MyOctet (pub OctetString) ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (automatic_tags)] pub struct MySeq { # [rasn (default = "my_seq_data_default")] pub data : OctetList , } impl MySeq { pub fn new (data : OctetList) -> Self { Self { data } } } impl std :: default :: Default for MySeq { fn default () -> Self { Self { data : my_seq_data_default () } } } fn my_seq_data_default () -> OctetList { OctetList (alloc :: vec ! [MyOctet (< OctetString as From < & 'static [u8] >> :: from (& [202 , 254])) , MyOctet (< OctetString as From < & 'static [u8] >> :: from (& [186 , 190]))]) } # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate)] pub struct OctetList (pub SequenceOf < MyOctet >) ; } diff --git a/rasn-compiler-tests/tests/snapshots/information_objects__information_object.snap b/rasn-compiler-tests/tests/snapshots/information_objects__information_object.snap index 09a29e46..c34e19c9 100644 --- a/rasn-compiler-tests/tests/snapshots/information_objects__information_object.snap +++ b/rasn-compiler-tests/tests/snapshots/information_objects__information_object.snap @@ -3,158 +3,4 @@ source: rasn-compiler-tests/tests/information_objects.rs description: "\n ERROR ::= CLASS {\n &errorCode ErrorCode UNIQUE,\n &ParameterType\n } WITH SYNTAX { [&ParameterType] IDENTIFIED BY &errorCode }\n\n ErrorCode ::= CHOICE {\n local INTEGER,\n global OBJECT IDENTIFIER\n }\n\n Errors ERROR ::= {\n { BOOLEAN IDENTIFIED BY asn-val-security-failure} |\n { INTEGER IDENTIFIED BY asn-val-unknown-branch} |\n { IDENTIFIED BY asn-val-unknown-order} |\n { BIT STRING (SIZE(4)) IDENTIFIED BY local: 4},\n ...\n }\n\n Actual ::= SEQUENCE {\n errorCode ERROR.&errorCode ({Errors}),\n parameter ERROR.&ParameterType ({Errors}{@errorCode}) OPTIONAL\n }\n\n asn-val-security-failure ErrorCode ::= local: 1\n asn-val-unknown-branch ErrorCode ::= local: 2\n asn-val-unknown-order ErrorCode ::= local: 3\n " --- Generated: -#[allow( - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - unused, - clippy::too_many_arguments -)] -pub mod test_module { - extern crate alloc; - use core::borrow::Borrow; - use rasn::prelude::*; - use std::sync::LazyLock; - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(automatic_tags)] - pub struct Actual { - #[rasn(identifier = "errorCode")] - pub error_code: ErrorCode, - pub parameter: Option, - } - impl Actual { - pub fn new(error_code: ErrorCode, parameter: Option) -> Self { - Self { - error_code, - parameter, - } - } - } - impl Actual { - pub fn decode_parameter( - &self, - decoder: &mut D, - ) -> Result { - Errors_ParameterType::decode(decoder, self.parameter.as_ref(), &self.error_code) - } - } - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(choice, automatic_tags)] - pub enum ErrorCode { - local(Integer), - global(ObjectIdentifier), - } - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(size("4"), delegate)] - pub struct Inner_Errors_ParameterType_2(pub BitString); - #[derive(Debug, Clone, PartialEq)] - pub enum Errors_ParameterType { - AsnValSecurityFailure(bool), - AsnValUnknownBranch(Integer), - Errors_ParameterType_2(Inner_Errors_ParameterType_2), - } - impl Errors_ParameterType { - pub fn decode( - decoder: &mut D, - open_type_payload: Option<&Any>, - identifier: &ErrorCode, - ) -> Result { - match identifier { - i if i == &*ASN_VAL_SECURITY_FAILURE => Ok(decoder - .codec() - .decode_from_binary( - open_type_payload - .ok_or_else(|| { - rasn::error::DecodeError::from_kind( - rasn::error::DecodeErrorKind::Custom { - msg: "Failed to decode open type! No input data given." - .into(), - }, - decoder.codec(), - ) - .into() - })? - .as_bytes(), - ) - .map(Self::AsnValSecurityFailure)?), - i if i == &*ASN_VAL_UNKNOWN_BRANCH => Ok(decoder - .codec() - .decode_from_binary( - open_type_payload - .ok_or_else(|| { - rasn::error::DecodeError::from_kind( - rasn::error::DecodeErrorKind::Custom { - msg: "Failed to decode open type! No input data given." - .into(), - }, - decoder.codec(), - ) - .into() - })? - .as_bytes(), - ) - .map(Self::AsnValUnknownBranch)?), - i if i == &ErrorCode::local(Integer::from(4i128)) => Ok(decoder - .codec() - .decode_from_binary( - open_type_payload - .ok_or_else(|| { - rasn::error::DecodeError::from_kind( - rasn::error::DecodeErrorKind::Custom { - msg: "Failed to decode open type! No input data given." - .into(), - }, - decoder.codec(), - ) - .into() - })? - .as_bytes(), - ) - .map(Self::Errors_ParameterType_2)?), - _ => Err(rasn::error::DecodeError::from_kind( - rasn::error::DecodeErrorKind::Custom { - msg: alloc::format!( - "Unknown unique identifier for information object class instance." - ), - }, - decoder.codec(), - ) - .into()), - } - } - pub fn encode( - &self, - encoder: &mut E, - identifier: &ErrorCode, - ) -> Result<(), E::Error> { - match (self, identifier) { - (Self::AsnValSecurityFailure(inner), i) if i == &*ASN_VAL_SECURITY_FAILURE => { - inner.encode(encoder) - } - (Self::AsnValUnknownBranch(inner), i) if i == &*ASN_VAL_UNKNOWN_BRANCH => { - inner.encode(encoder) - } - (Self::Errors_ParameterType_2(inner), i) - if i == &ErrorCode::local(Integer::from(4i128)) => - { - inner.encode(encoder) - } - _ => Err(rasn::error::EncodeError::from_kind( - rasn::error::EncodeErrorKind::Custom { - msg: alloc::format!( - "Unknown unique identifier for information object class instance." - ), - }, - encoder.codec(), - ) - .into()), - } - } - } - pub static ASN_VAL_SECURITY_FAILURE: LazyLock = - LazyLock::new(|| ErrorCode::local(Integer::from(1i128))); - pub static ASN_VAL_UNKNOWN_BRANCH: LazyLock = - LazyLock::new(|| ErrorCode::local(Integer::from(2i128))); - pub static ASN_VAL_UNKNOWN_ORDER: LazyLock = - LazyLock::new(|| ErrorCode::local(Integer::from(3i128))); -} +# [allow (non_camel_case_types , non_snake_case , non_upper_case_globals , unused , clippy :: too_many_arguments ,)] pub mod test_module { extern crate alloc ; use core :: borrow :: Borrow ; use std :: sync :: LazyLock ; use rasn :: prelude :: * ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (automatic_tags)] pub struct Actual { # [rasn (identifier = "errorCode")] pub error_code : ErrorCode , pub parameter : Option < Any > , } impl Actual { pub fn new (error_code : ErrorCode , parameter : Option < Any >) -> Self { Self { error_code , parameter } } } impl Actual { pub fn decode_parameter < D : Decoder > (& self , decoder : & mut D) -> Result < Errors_ParameterType , D :: Error > { Errors_ParameterType :: decode (decoder , self . parameter . as_ref () , & self . error_code) } } # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (choice)] pub enum ErrorCode { # [rasn (tag (context , 0))] local (Integer) , # [rasn (tag (context , 1))] global (ObjectIdentifier) , } # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (size ("4") , delegate)] pub struct Inner_Errors_ParameterType_2 (pub BitString) ; # [derive (Debug , Clone , PartialEq)] pub enum Errors_ParameterType { AsnValSecurityFailure (bool) , AsnValUnknownBranch (Integer) , Errors_ParameterType_2 (Inner_Errors_ParameterType_2) , } impl Errors_ParameterType { pub fn decode < D : Decoder > (decoder : & mut D , open_type_payload : Option < & Any > , identifier : & ErrorCode) -> Result < Self , D :: Error > { match identifier { i if i == & * ASN_VAL_SECURITY_FAILURE => Ok (decoder . codec () . decode_from_binary (open_type_payload . ok_or_else (|| rasn :: error :: DecodeError :: from_kind (rasn :: error :: DecodeErrorKind :: Custom { msg : "Failed to decode open type! No input data given." . into () , } , decoder . codec ()) . into ()) ? . as_bytes ()) . map (Self :: AsnValSecurityFailure) ?) , i if i == & * ASN_VAL_UNKNOWN_BRANCH => Ok (decoder . codec () . decode_from_binary (open_type_payload . ok_or_else (|| rasn :: error :: DecodeError :: from_kind (rasn :: error :: DecodeErrorKind :: Custom { msg : "Failed to decode open type! No input data given." . into () , } , decoder . codec ()) . into ()) ? . as_bytes ()) . map (Self :: AsnValUnknownBranch) ?) , i if i == & ErrorCode :: local (Integer :: from (4i128)) => Ok (decoder . codec () . decode_from_binary (open_type_payload . ok_or_else (|| rasn :: error :: DecodeError :: from_kind (rasn :: error :: DecodeErrorKind :: Custom { msg : "Failed to decode open type! No input data given." . into () , } , decoder . codec ()) . into ()) ? . as_bytes ()) . map (Self :: Errors_ParameterType_2) ?) , _ => Err (rasn :: error :: DecodeError :: from_kind (rasn :: error :: DecodeErrorKind :: Custom { msg : alloc :: format ! ("Unknown unique identifier for information object class instance.") , } , decoder . codec ()) . into ()) } } pub fn encode < E : Encoder > (& self , encoder : & mut E , identifier : & ErrorCode) -> Result < () , E :: Error > { match (self , identifier) { (Self :: AsnValSecurityFailure (inner) , i) if i == & * ASN_VAL_SECURITY_FAILURE => inner . encode (encoder) , (Self :: AsnValUnknownBranch (inner) , i) if i == & * ASN_VAL_UNKNOWN_BRANCH => inner . encode (encoder) , (Self :: Errors_ParameterType_2 (inner) , i) if i == & ErrorCode :: local (Integer :: from (4i128)) => inner . encode (encoder) , _ => Err (rasn :: error :: EncodeError :: from_kind (rasn :: error :: EncodeErrorKind :: Custom { msg : alloc :: format ! ("Unknown unique identifier for information object class instance.") , } , encoder . codec ()) . into ()) } } } pub static ASN_VAL_SECURITY_FAILURE : LazyLock < ErrorCode > = LazyLock :: new (|| ErrorCode :: local (Integer :: from (1i128))) ; pub static ASN_VAL_UNKNOWN_BRANCH : LazyLock < ErrorCode > = LazyLock :: new (|| ErrorCode :: local (Integer :: from (2i128))) ; pub static ASN_VAL_UNKNOWN_ORDER : LazyLock < ErrorCode > = LazyLock :: new (|| ErrorCode :: local (Integer :: from (3i128))) ; } diff --git a/rasn-compiler-tests/tests/snapshots/nested_types__boolean.snap b/rasn-compiler-tests/tests/snapshots/nested_types__boolean.snap index f91efaa7..d0aab213 100644 --- a/rasn-compiler-tests/tests/snapshots/nested_types__boolean.snap +++ b/rasn-compiler-tests/tests/snapshots/nested_types__boolean.snap @@ -3,23 +3,4 @@ source: rasn-compiler-tests/tests/nested_types.rs description: " Test-Boolean ::= BOOLEAN\n Wrapping-Boolean ::= Test-Boolean\n value Wrapping-Boolean ::= FALSE" --- Generated: -#[allow( - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - unused, - clippy::too_many_arguments -)] -pub mod test_module { - extern crate alloc; - use core::borrow::Borrow; - use rasn::prelude::*; - use std::sync::LazyLock; - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] - #[rasn(delegate, identifier = "Test-Boolean")] - pub struct TestBoolean(pub bool); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate, identifier = "Wrapping-Boolean")] - pub struct WrappingBoolean(pub TestBoolean); - pub const VALUE: WrappingBoolean = WrappingBoolean(TestBoolean(false)); -} +# [allow (non_camel_case_types , non_snake_case , non_upper_case_globals , unused , clippy :: too_many_arguments ,)] pub mod test_module { extern crate alloc ; use core :: borrow :: Borrow ; use std :: sync :: LazyLock ; use rasn :: prelude :: * ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash , Copy)] # [rasn (delegate , identifier = "Test-Boolean")] pub struct TestBoolean (pub bool) ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate , identifier = "Wrapping-Boolean")] pub struct WrappingBoolean (pub TestBoolean) ; pub const VALUE : WrappingBoolean = WrappingBoolean (TestBoolean (false)) ; } diff --git a/rasn-compiler-tests/tests/snapshots/nested_types__constraint_cross_reference.snap b/rasn-compiler-tests/tests/snapshots/nested_types__constraint_cross_reference.snap index 0a2a4d29..3f3c6221 100644 --- a/rasn-compiler-tests/tests/snapshots/nested_types__constraint_cross_reference.snap +++ b/rasn-compiler-tests/tests/snapshots/nested_types__constraint_cross_reference.snap @@ -3,23 +3,4 @@ source: rasn-compiler-tests/tests/nested_types.rs description: " Test-Int ::= INTEGER (0..123723)\n Wrapping-Int ::= Test-Int (0..value)\n value Test-Int ::= 5" --- Generated: -#[allow( - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - unused, - clippy::too_many_arguments -)] -pub mod test_module { - extern crate alloc; - use core::borrow::Borrow; - use rasn::prelude::*; - use std::sync::LazyLock; - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate, identifier = "Test-Int", value("0..=123723"))] - pub struct TestInt(pub u32); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate, identifier = "Wrapping-Int", value("0..=5"))] - pub struct WrappingInt(pub TestInt); - pub const VALUE: TestInt = TestInt(5); -} +# [allow (non_camel_case_types , non_snake_case , non_upper_case_globals , unused , clippy :: too_many_arguments ,)] pub mod test_module { extern crate alloc ; use core :: borrow :: Borrow ; use std :: sync :: LazyLock ; use rasn :: prelude :: * ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate , identifier = "Test-Int" , value ("0..=123723"))] pub struct TestInt (pub u32) ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate , identifier = "Wrapping-Int" , value ("0..=5"))] pub struct WrappingInt (pub TestInt) ; pub const VALUE : TestInt = TestInt (5) ; } diff --git a/rasn-compiler-tests/tests/snapshots/nested_types__integer.snap b/rasn-compiler-tests/tests/snapshots/nested_types__integer.snap index bc341731..0234b3a2 100644 --- a/rasn-compiler-tests/tests/snapshots/nested_types__integer.snap +++ b/rasn-compiler-tests/tests/snapshots/nested_types__integer.snap @@ -3,23 +3,4 @@ source: rasn-compiler-tests/tests/nested_types.rs description: " Test-Int ::= INTEGER (0..123723)\n Wrapping-Int ::= Test-Int (0..123)\n value Wrapping-Int ::= 4" --- Generated: -#[allow( - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - unused, - clippy::too_many_arguments -)] -pub mod test_module { - extern crate alloc; - use core::borrow::Borrow; - use rasn::prelude::*; - use std::sync::LazyLock; - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate, identifier = "Test-Int", value("0..=123723"))] - pub struct TestInt(pub u32); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate, identifier = "Wrapping-Int", value("0..=123"))] - pub struct WrappingInt(pub TestInt); - pub const VALUE: WrappingInt = WrappingInt(TestInt(4)); -} +# [allow (non_camel_case_types , non_snake_case , non_upper_case_globals , unused , clippy :: too_many_arguments ,)] pub mod test_module { extern crate alloc ; use core :: borrow :: Borrow ; use std :: sync :: LazyLock ; use rasn :: prelude :: * ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate , identifier = "Test-Int" , value ("0..=123723"))] pub struct TestInt (pub u32) ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate , identifier = "Wrapping-Int" , value ("0..=123"))] pub struct WrappingInt (pub TestInt) ; pub const VALUE : WrappingInt = WrappingInt (TestInt (4)) ; } diff --git a/rasn-compiler-tests/tests/snapshots/nested_types__sequence.snap b/rasn-compiler-tests/tests/snapshots/nested_types__sequence.snap index f7619416..b3566179 100644 --- a/rasn-compiler-tests/tests/snapshots/nested_types__sequence.snap +++ b/rasn-compiler-tests/tests/snapshots/nested_types__sequence.snap @@ -3,46 +3,4 @@ source: rasn-compiler-tests/tests/nested_types.rs description: " Test-Int ::= INTEGER (0..123723)\n Wrapping-Int ::= Test-Int (0..123)\n Test-Boolean ::= BOOLEAN\n Wrapping-Boolean ::= Test-Boolean\n Test-Sequence ::= SEQUENCE {\n int Wrapping-Int DEFAULT 5,\n boolean Wrapping-Boolean,\n }\n value Test-Sequence ::= { boolean TRUE }" --- Generated: -#[allow( - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - unused, - clippy::too_many_arguments -)] -pub mod test_module { - extern crate alloc; - use core::borrow::Borrow; - use rasn::prelude::*; - use std::sync::LazyLock; - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] - #[rasn(delegate, identifier = "Test-Boolean")] - pub struct TestBoolean(pub bool); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate, identifier = "Test-Int", value("0..=123723"))] - pub struct TestInt(pub u32); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(automatic_tags, identifier = "Test-Sequence")] - pub struct TestSequence { - #[rasn(default = "test_sequence_int_default")] - pub int: WrappingInt, - pub boolean: WrappingBoolean, - } - impl TestSequence { - pub fn new(int: WrappingInt, boolean: WrappingBoolean) -> Self { - Self { int, boolean } - } - } - fn test_sequence_int_default() -> WrappingInt { - WrappingInt(TestInt(5)) - } - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate, identifier = "Wrapping-Boolean")] - pub struct WrappingBoolean(pub TestBoolean); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate, identifier = "Wrapping-Int", value("0..=123"))] - pub struct WrappingInt(pub TestInt); - pub static VALUE: LazyLock = LazyLock::new(|| { - TestSequence::new(WrappingInt(TestInt(5)), WrappingBoolean(TestBoolean(true))) - }); -} +# [allow (non_camel_case_types , non_snake_case , non_upper_case_globals , unused , clippy :: too_many_arguments ,)] pub mod test_module { extern crate alloc ; use core :: borrow :: Borrow ; use std :: sync :: LazyLock ; use rasn :: prelude :: * ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash , Copy)] # [rasn (delegate , identifier = "Test-Boolean")] pub struct TestBoolean (pub bool) ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate , identifier = "Test-Int" , value ("0..=123723"))] pub struct TestInt (pub u32) ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (automatic_tags , identifier = "Test-Sequence")] pub struct TestSequence { # [rasn (default = "test_sequence_int_default")] pub int : WrappingInt , pub boolean : WrappingBoolean , } impl TestSequence { pub fn new (int : WrappingInt , boolean : WrappingBoolean) -> Self { Self { int , boolean } } } fn test_sequence_int_default () -> WrappingInt { WrappingInt (TestInt (5)) } # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate , identifier = "Wrapping-Boolean")] pub struct WrappingBoolean (pub TestBoolean) ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate , identifier = "Wrapping-Int" , value ("0..=123"))] pub struct WrappingInt (pub TestInt) ; pub static VALUE : LazyLock < TestSequence > = LazyLock :: new (|| TestSequence :: new (WrappingInt (TestInt (5)) , WrappingBoolean (TestBoolean (true)))) ; } diff --git a/rasn-compiler-tests/tests/snapshots/parameterization__anonymous_type_param.snap b/rasn-compiler-tests/tests/snapshots/parameterization__anonymous_type_param.snap index 64f70cf7..5dd53548 100644 --- a/rasn-compiler-tests/tests/snapshots/parameterization__anonymous_type_param.snap +++ b/rasn-compiler-tests/tests/snapshots/parameterization__anonymous_type_param.snap @@ -3,70 +3,4 @@ source: rasn-compiler-tests/tests/parameterization.rs description: "\n SetupRelease { ElementTypeParam } ::= CHOICE { \n release NULL,\n setup ElementTypeParam \n }\n\n LocationMeasurementInfo ::= SEQUENCE {\n test BOOLEAN\n }\n\n LocationMeasurementIndication-IEs ::= SEQUENCE { \n measurementIndication SetupRelease { LocationMeasurementInfo }, \n lateNonCriticalExtension OCTET STRING OPTIONAL,\n nonCriticalExtension SEQUENCE{} OPTIONAL \n }\n " --- Generated: -#[allow( - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - unused, - clippy::too_many_arguments -)] -pub mod test_module { - extern crate alloc; - use core::borrow::Borrow; - use rasn::prelude::*; - use std::sync::LazyLock; - #[doc = " Inner type "] - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(choice, automatic_tags)] - pub enum LocationMeasurementIndicationIEsMeasurementIndication { - release(()), - setup(LocationMeasurementInfo), - } - #[doc = " Inner type "] - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(automatic_tags)] - pub struct LocationMeasurementIndicationIEsNonCriticalExtension {} - impl LocationMeasurementIndicationIEsNonCriticalExtension { - pub fn new() -> Self { - Self {} - } - } - impl std::default::Default for LocationMeasurementIndicationIEsNonCriticalExtension { - fn default() -> Self { - Self {} - } - } - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(automatic_tags, identifier = "LocationMeasurementIndication-IEs")] - pub struct LocationMeasurementIndicationIEs { - #[rasn(identifier = "measurementIndication")] - pub measurement_indication: LocationMeasurementIndicationIEsMeasurementIndication, - #[rasn(identifier = "lateNonCriticalExtension")] - pub late_non_critical_extension: Option, - #[rasn(identifier = "nonCriticalExtension")] - pub non_critical_extension: Option, - } - impl LocationMeasurementIndicationIEs { - pub fn new( - measurement_indication: LocationMeasurementIndicationIEsMeasurementIndication, - late_non_critical_extension: Option, - non_critical_extension: Option, - ) -> Self { - Self { - measurement_indication, - late_non_critical_extension, - non_critical_extension, - } - } - } - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(automatic_tags)] - pub struct LocationMeasurementInfo { - pub test: bool, - } - impl LocationMeasurementInfo { - pub fn new(test: bool) -> Self { - Self { test } - } - } -} +# [allow (non_camel_case_types , non_snake_case , non_upper_case_globals , unused , clippy :: too_many_arguments ,)] pub mod test_module { extern crate alloc ; use core :: borrow :: Borrow ; use std :: sync :: LazyLock ; use rasn :: prelude :: * ; # [doc = " Inner type "] # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (choice)] pub enum LocationMeasurementIndicationIEsMeasurementIndication { # [rasn (tag (context , 0))] release (()) , # [rasn (tag (context , 1))] setup (LocationMeasurementInfo) , } # [doc = " Inner type "] # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (automatic_tags)] pub struct LocationMeasurementIndicationIEsNonCriticalExtension { } impl LocationMeasurementIndicationIEsNonCriticalExtension { pub fn new () -> Self { Self { } } } impl std :: default :: Default for LocationMeasurementIndicationIEsNonCriticalExtension { fn default () -> Self { Self { } } } # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (automatic_tags , identifier = "LocationMeasurementIndication-IEs")] pub struct LocationMeasurementIndicationIEs { # [rasn (identifier = "measurementIndication")] pub measurement_indication : LocationMeasurementIndicationIEsMeasurementIndication , # [rasn (identifier = "lateNonCriticalExtension")] pub late_non_critical_extension : Option < OctetString > , # [rasn (identifier = "nonCriticalExtension")] pub non_critical_extension : Option < LocationMeasurementIndicationIEsNonCriticalExtension > , } impl LocationMeasurementIndicationIEs { pub fn new (measurement_indication : LocationMeasurementIndicationIEsMeasurementIndication , late_non_critical_extension : Option < OctetString > , non_critical_extension : Option < LocationMeasurementIndicationIEsNonCriticalExtension >) -> Self { Self { measurement_indication , late_non_critical_extension , non_critical_extension } } } # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (automatic_tags)] pub struct LocationMeasurementInfo { pub test : bool , } impl LocationMeasurementInfo { pub fn new (test : bool) -> Self { Self { test } } } } diff --git a/rasn-compiler-tests/tests/snapshots/parameterization__parameterized_information_object_classes.snap b/rasn-compiler-tests/tests/snapshots/parameterization__parameterized_information_object_classes.snap index fa67347d..69a35402 100644 --- a/rasn-compiler-tests/tests/snapshots/parameterization__parameterized_information_object_classes.snap +++ b/rasn-compiler-tests/tests/snapshots/parameterization__parameterized_information_object_classes.snap @@ -3,224 +3,4 @@ source: rasn-compiler-tests/tests/parameterization.rs description: "\n NGAP-PROTOCOL-EXTENSION ::= CLASS {\n &id\t\t\t\tINTEGER\t\t\tUNIQUE,\n &criticality\tINTEGER,\n &Extension,\n &presence\t\tBOOLEAN\n }\n WITH SYNTAX {\n ID\t\t\t\t&id\n CRITICALITY\t\t&criticality\n EXTENSION\t\t&Extension\n PRESENCE\t\t&presence\n }\n\n ProtocolExtensionContainer {NGAP-PROTOCOL-EXTENSION : ExtensionSetParam} ::= \n SEQUENCE (SIZE (1..maxProtocolExtensions)) OF\n ProtocolExtensionField {{ExtensionSetParam}}\n\n ProtocolExtensionField {NGAP-PROTOCOL-EXTENSION : ExtensionSetParam} ::= SEQUENCE {\n id\t\t\t\t\tNGAP-PROTOCOL-EXTENSION.&id\t\t\t\t({ExtensionSetParam}),\n criticality\t\t\tNGAP-PROTOCOL-EXTENSION.&criticality\t({ExtensionSetParam}{@id}),\n extensionValue\t\tNGAP-PROTOCOL-EXTENSION.&Extension\t\t({ExtensionSetParam}{@id})\n }\n\n A2X-PC5-FlowBitRates ::= SEQUENCE {\n a2X-GuaranteedFlowBitRate\t\tBOOLEAN,\n iE-Extensions\t\tProtocolExtensionContainer { {A2X-PC5-FlowBitRates-ExtIEs} }\tOPTIONAL,\n ...\n }\n\n A2X-PC5-FlowBitRates-ExtIEs NGAP-PROTOCOL-EXTENSION ::= {\n ...\n }\n " --- Generated: -#[allow( - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - unused, - clippy::too_many_arguments -)] -pub mod test_module { - extern crate alloc; - use core::borrow::Borrow; - use rasn::prelude::*; - use std::sync::LazyLock; - #[doc = " Anonymous SEQUENCE OF member "] - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(automatic_tags, identifier = "SEQUENCE")] - pub struct AnonymousA2XPC5FlowBitRatesIEExtensions { - pub id: Integer, - pub criticality: Integer, - #[rasn(identifier = "extensionValue")] - pub extension_value: Any, - } - impl AnonymousA2XPC5FlowBitRatesIEExtensions { - pub fn new(id: Integer, criticality: Integer, extension_value: Any) -> Self { - Self { - id, - criticality, - extension_value, - } - } - } - impl AnonymousA2XPC5FlowBitRatesIEExtensions { - pub fn decode_extension_value( - &self, - decoder: &mut D, - ) -> Result { - A2XPC5FlowBitRatesExtIEs_Extension::decode( - decoder, - Some(&self.extension_value), - &self.id, - ) - } - } - #[doc = " Inner type "] - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate, size("1.."))] - pub struct A2XPC5FlowBitRatesIEExtensions( - pub SequenceOf, - ); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(automatic_tags, identifier = "A2X-PC5-FlowBitRates")] - #[non_exhaustive] - pub struct A2XPC5FlowBitRates { - #[rasn(identifier = "a2X-GuaranteedFlowBitRate")] - pub a2_x_guaranteed_flow_bit_rate: bool, - #[rasn(identifier = "iE-Extensions")] - pub i_e_extensions: Option, - } - impl A2XPC5FlowBitRates { - pub fn new( - a2_x_guaranteed_flow_bit_rate: bool, - i_e_extensions: Option, - ) -> Self { - Self { - a2_x_guaranteed_flow_bit_rate, - i_e_extensions, - } - } - } - #[derive(Debug, Clone, PartialEq)] - pub enum A2XPC5FlowBitRatesExtIEs_Extension {} - impl A2XPC5FlowBitRatesExtIEs_Extension { - pub fn decode( - decoder: &mut D, - open_type_payload: Option<&Any>, - identifier: &Integer, - ) -> Result { - match identifier { - _ => Err(rasn::error::DecodeError::from_kind( - rasn::error::DecodeErrorKind::Custom { - msg: alloc::format!( - "Unknown unique identifier for information object class instance." - ), - }, - decoder.codec(), - ) - .into()), - } - } - pub fn encode( - &self, - encoder: &mut E, - identifier: &Integer, - ) -> Result<(), E::Error> { - match (self, identifier) { - _ => Err(rasn::error::EncodeError::from_kind( - rasn::error::EncodeErrorKind::Custom { - msg: alloc::format!( - "Unknown unique identifier for information object class instance." - ), - }, - encoder.codec(), - ) - .into()), - } - } - } - #[derive(Debug, Clone, PartialEq)] - pub enum A2XPC5FlowBitRatesExtIEs_criticality {} - impl A2XPC5FlowBitRatesExtIEs_criticality { - pub fn decode( - decoder: &mut D, - open_type_payload: Option<&Any>, - identifier: &Integer, - ) -> Result { - match identifier { - _ => Err(rasn::error::DecodeError::from_kind( - rasn::error::DecodeErrorKind::Custom { - msg: alloc::format!( - "Unknown unique identifier for information object class instance." - ), - }, - decoder.codec(), - ) - .into()), - } - } - pub fn encode( - &self, - encoder: &mut E, - identifier: &Integer, - ) -> Result<(), E::Error> { - match (self, identifier) { - _ => Err(rasn::error::EncodeError::from_kind( - rasn::error::EncodeErrorKind::Custom { - msg: alloc::format!( - "Unknown unique identifier for information object class instance." - ), - }, - encoder.codec(), - ) - .into()), - } - } - } - #[derive(Debug, Clone, PartialEq)] - pub enum A2XPC5FlowBitRatesExtIEs_id {} - impl A2XPC5FlowBitRatesExtIEs_id { - pub fn decode( - decoder: &mut D, - open_type_payload: Option<&Any>, - identifier: &Integer, - ) -> Result { - match identifier { - _ => Err(rasn::error::DecodeError::from_kind( - rasn::error::DecodeErrorKind::Custom { - msg: alloc::format!( - "Unknown unique identifier for information object class instance." - ), - }, - decoder.codec(), - ) - .into()), - } - } - pub fn encode( - &self, - encoder: &mut E, - identifier: &Integer, - ) -> Result<(), E::Error> { - match (self, identifier) { - _ => Err(rasn::error::EncodeError::from_kind( - rasn::error::EncodeErrorKind::Custom { - msg: alloc::format!( - "Unknown unique identifier for information object class instance." - ), - }, - encoder.codec(), - ) - .into()), - } - } - } - #[derive(Debug, Clone, PartialEq)] - pub enum A2XPC5FlowBitRatesExtIEs_presence {} - impl A2XPC5FlowBitRatesExtIEs_presence { - pub fn decode( - decoder: &mut D, - open_type_payload: Option<&Any>, - identifier: &Integer, - ) -> Result { - match identifier { - _ => Err(rasn::error::DecodeError::from_kind( - rasn::error::DecodeErrorKind::Custom { - msg: alloc::format!( - "Unknown unique identifier for information object class instance." - ), - }, - decoder.codec(), - ) - .into()), - } - } - pub fn encode( - &self, - encoder: &mut E, - identifier: &Integer, - ) -> Result<(), E::Error> { - match (self, identifier) { - _ => Err(rasn::error::EncodeError::from_kind( - rasn::error::EncodeErrorKind::Custom { - msg: alloc::format!( - "Unknown unique identifier for information object class instance." - ), - }, - encoder.codec(), - ) - .into()), - } - } - } -} +# [allow (non_camel_case_types , non_snake_case , non_upper_case_globals , unused , clippy :: too_many_arguments ,)] pub mod test_module { extern crate alloc ; use core :: borrow :: Borrow ; use std :: sync :: LazyLock ; use rasn :: prelude :: * ; # [doc = " Anonymous SEQUENCE OF member "] # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (automatic_tags , identifier = "SEQUENCE")] pub struct AnonymousA2XPC5FlowBitRatesIEExtensions { pub id : Integer , pub criticality : Integer , # [rasn (identifier = "extensionValue")] pub extension_value : Any , } impl AnonymousA2XPC5FlowBitRatesIEExtensions { pub fn new (id : Integer , criticality : Integer , extension_value : Any) -> Self { Self { id , criticality , extension_value } } } impl AnonymousA2XPC5FlowBitRatesIEExtensions { pub fn decode_extension_value < D : Decoder > (& self , decoder : & mut D) -> Result < A2XPC5FlowBitRatesExtIEs_Extension , D :: Error > { A2XPC5FlowBitRatesExtIEs_Extension :: decode (decoder , Some (& self . extension_value) , & self . id) } } # [doc = " Inner type "] # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (delegate , size ("1.."))] pub struct A2XPC5FlowBitRatesIEExtensions (pub SequenceOf < AnonymousA2XPC5FlowBitRatesIEExtensions >) ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (automatic_tags , identifier = "A2X-PC5-FlowBitRates")] # [non_exhaustive] pub struct A2XPC5FlowBitRates { # [rasn (identifier = "a2X-GuaranteedFlowBitRate")] pub a2_x_guaranteed_flow_bit_rate : bool , # [rasn (identifier = "iE-Extensions")] pub i_e_extensions : Option < A2XPC5FlowBitRatesIEExtensions > , } impl A2XPC5FlowBitRates { pub fn new (a2_x_guaranteed_flow_bit_rate : bool , i_e_extensions : Option < A2XPC5FlowBitRatesIEExtensions >) -> Self { Self { a2_x_guaranteed_flow_bit_rate , i_e_extensions } } } # [derive (Debug , Clone , PartialEq)] pub enum A2XPC5FlowBitRatesExtIEs_Extension { } impl A2XPC5FlowBitRatesExtIEs_Extension { pub fn decode < D : Decoder > (decoder : & mut D , open_type_payload : Option < & Any > , identifier : & Integer) -> Result < Self , D :: Error > { match identifier { _ => Err (rasn :: error :: DecodeError :: from_kind (rasn :: error :: DecodeErrorKind :: Custom { msg : alloc :: format ! ("Unknown unique identifier for information object class instance.") , } , decoder . codec ()) . into ()) } } pub fn encode < E : Encoder > (& self , encoder : & mut E , identifier : & Integer) -> Result < () , E :: Error > { match (self , identifier) { _ => Err (rasn :: error :: EncodeError :: from_kind (rasn :: error :: EncodeErrorKind :: Custom { msg : alloc :: format ! ("Unknown unique identifier for information object class instance.") , } , encoder . codec ()) . into ()) } } } # [derive (Debug , Clone , PartialEq)] pub enum A2XPC5FlowBitRatesExtIEs_criticality { } impl A2XPC5FlowBitRatesExtIEs_criticality { pub fn decode < D : Decoder > (decoder : & mut D , open_type_payload : Option < & Any > , identifier : & Integer) -> Result < Self , D :: Error > { match identifier { _ => Err (rasn :: error :: DecodeError :: from_kind (rasn :: error :: DecodeErrorKind :: Custom { msg : alloc :: format ! ("Unknown unique identifier for information object class instance.") , } , decoder . codec ()) . into ()) } } pub fn encode < E : Encoder > (& self , encoder : & mut E , identifier : & Integer) -> Result < () , E :: Error > { match (self , identifier) { _ => Err (rasn :: error :: EncodeError :: from_kind (rasn :: error :: EncodeErrorKind :: Custom { msg : alloc :: format ! ("Unknown unique identifier for information object class instance.") , } , encoder . codec ()) . into ()) } } } # [derive (Debug , Clone , PartialEq)] pub enum A2XPC5FlowBitRatesExtIEs_id { } impl A2XPC5FlowBitRatesExtIEs_id { pub fn decode < D : Decoder > (decoder : & mut D , open_type_payload : Option < & Any > , identifier : & Integer) -> Result < Self , D :: Error > { match identifier { _ => Err (rasn :: error :: DecodeError :: from_kind (rasn :: error :: DecodeErrorKind :: Custom { msg : alloc :: format ! ("Unknown unique identifier for information object class instance.") , } , decoder . codec ()) . into ()) } } pub fn encode < E : Encoder > (& self , encoder : & mut E , identifier : & Integer) -> Result < () , E :: Error > { match (self , identifier) { _ => Err (rasn :: error :: EncodeError :: from_kind (rasn :: error :: EncodeErrorKind :: Custom { msg : alloc :: format ! ("Unknown unique identifier for information object class instance.") , } , encoder . codec ()) . into ()) } } } # [derive (Debug , Clone , PartialEq)] pub enum A2XPC5FlowBitRatesExtIEs_presence { } impl A2XPC5FlowBitRatesExtIEs_presence { pub fn decode < D : Decoder > (decoder : & mut D , open_type_payload : Option < & Any > , identifier : & Integer) -> Result < Self , D :: Error > { match identifier { _ => Err (rasn :: error :: DecodeError :: from_kind (rasn :: error :: DecodeErrorKind :: Custom { msg : alloc :: format ! ("Unknown unique identifier for information object class instance.") , } , decoder . codec ()) . into ()) } } pub fn encode < E : Encoder > (& self , encoder : & mut E , identifier : & Integer) -> Result < () , E :: Error > { match (self , identifier) { _ => Err (rasn :: error :: EncodeError :: from_kind (rasn :: error :: EncodeErrorKind :: Custom { msg : alloc :: format ! ("Unknown unique identifier for information object class instance.") , } , encoder . codec ()) . into ()) } } } } diff --git a/rasn-compiler-tests/tests/snapshots/parameterization__parameterized_type.snap b/rasn-compiler-tests/tests/snapshots/parameterization__parameterized_type.snap index 2920f356..73ecbfb9 100644 --- a/rasn-compiler-tests/tests/snapshots/parameterization__parameterized_type.snap +++ b/rasn-compiler-tests/tests/snapshots/parameterization__parameterized_type.snap @@ -3,35 +3,4 @@ source: rasn-compiler-tests/tests/parameterization.rs description: "\n ParamType { INTEGER: lower, BOOLEAN: flag } ::= SEQUENCE {\n int-value INTEGER (lower..12),\n bool-value BOOLEAN DEFAULT flag\n }\n ImplType ::= ParamType { 2, TRUE }\n " --- Generated: -#[allow( - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - unused, - clippy::too_many_arguments -)] -pub mod test_module { - extern crate alloc; - use core::borrow::Borrow; - use rasn::prelude::*; - use std::sync::LazyLock; - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(automatic_tags)] - pub struct ImplType { - #[rasn(value("2..=12"), identifier = "int-value")] - pub int_value: u8, - #[rasn(default = "impl_type_bool_value_default", identifier = "bool-value")] - pub bool_value: bool, - } - impl ImplType { - pub fn new(int_value: u8, bool_value: bool) -> Self { - Self { - int_value, - bool_value, - } - } - } - fn impl_type_bool_value_default() -> bool { - true - } -} +# [allow (non_camel_case_types , non_snake_case , non_upper_case_globals , unused , clippy :: too_many_arguments ,)] pub mod test_module { extern crate alloc ; use core :: borrow :: Borrow ; use std :: sync :: LazyLock ; use rasn :: prelude :: * ; # [derive (AsnType , Debug , Clone , Decode , Encode , PartialEq , Eq , Hash)] # [rasn (automatic_tags)] pub struct ImplType { # [rasn (value ("2..=12") , identifier = "int-value")] pub int_value : u8 , # [rasn (default = "impl_type_bool_value_default" , identifier = "bool-value")] pub bool_value : bool , } impl ImplType { pub fn new (int_value : u8 , bool_value : bool) -> Self { Self { int_value , bool_value } } } fn impl_type_bool_value_default () -> bool { true } } diff --git a/rasn-compiler-tests/tests/snapshots/parse_test__parses_modules@iso_10031-2_1991_DOR-definition.asn1.snap b/rasn-compiler-tests/tests/snapshots/parse_test__parses_modules@iso_10031-2_1991_DOR-definition.asn1.snap index b2cdd313..b843844a 100644 --- a/rasn-compiler-tests/tests/snapshots/parse_test__parses_modules@iso_10031-2_1991_DOR-definition.asn1.snap +++ b/rasn-compiler-tests/tests/snapshots/parse_test__parses_modules@iso_10031-2_1991_DOR-definition.asn1.snap @@ -117,10 +117,7 @@ pub mod dor_definition { } } fn dor_quality_of_service_default() -> QualityOfService { - QualityOfService(QualityOfService::new( - QoSLevel::level_1(()), - SingleUseOfReference(true), - )) + QualityOfService::new(QoSLevel::level_1(()), SingleUseOfReference(true)) } #[doc = " Data types for extending a specific QoS"] #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] diff --git a/rasn-compiler-tests/tests/snapshots/parse_test__parses_modules@itu-t_f_f515_2003_Uds.asn1.snap b/rasn-compiler-tests/tests/snapshots/parse_test__parses_modules@itu-t_f_f515_2003_Uds.asn1.snap index c40bac07..55409335 100644 --- a/rasn-compiler-tests/tests/snapshots/parse_test__parses_modules@itu-t_f_f515_2003_Uds.asn1.snap +++ b/rasn-compiler-tests/tests/snapshots/parse_test__parses_modules@itu-t_f_f515_2003_Uds.asn1.snap @@ -1,42 +1,8 @@ --- source: rasn-compiler-tests/tests/parse_test.rs +assertion_line: 33 input_file: rasn-compiler-tests/tests/modules/itu-t_f_f515_2003_Uds.asn1 --- -Warnings: -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! -Not yet implemented error while generating bindings: Enumerated values are currently unsupported! - - Generated: #[allow( non_camel_case_types, @@ -55,6 +21,28 @@ pub mod uds { #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] #[rasn(delegate)] pub struct AddrCoverage(pub AddrCoverageType); + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] + #[rasn(enumerated)] + pub enum AddrCoverageAsWeight { + low = 0, + high = 1, + } + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] + #[rasn(automatic_tags)] + pub struct AddrCoverageAs { + pub base: AddrCoverageType, + #[rasn(default = "addr_coverage_as_weight_default")] + pub weight: AddrCoverageAsWeight, + } + impl AddrCoverageAs { + pub fn new(base: AddrCoverageType, weight: AddrCoverageAsWeight) -> Self { + Self { base, weight } + } + } + fn addr_coverage_as_weight_default() -> AddrCoverageAsWeight { + HIGH + } #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] #[rasn(enumerated)] pub enum AddrCoverageType { @@ -66,6 +54,28 @@ pub mod uds { #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] #[rasn(delegate)] pub struct AddrRestriction(pub AddrRestrictionType); + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] + #[rasn(enumerated)] + pub enum AddrRestrictionAsWeight { + low = 0, + high = 1, + } + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] + #[rasn(automatic_tags)] + pub struct AddrRestrictionAs { + pub base: AddrRestrictionType, + #[rasn(default = "addr_restriction_as_weight_default")] + pub weight: AddrRestrictionAsWeight, + } + impl AddrRestrictionAs { + pub fn new(base: AddrRestrictionType, weight: AddrRestrictionAsWeight) -> Self { + Self { base, weight } + } + } + fn addr_restriction_as_weight_default() -> AddrRestrictionAsWeight { + HIGH + } #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] #[rasn(enumerated)] pub enum AddrRestrictionType { @@ -81,6 +91,28 @@ pub mod uds { #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] #[rasn(delegate)] pub struct AddrTariff(pub AddrTariffType); + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] + #[rasn(enumerated)] + pub enum AddrTariffAsWeight { + low = 0, + high = 1, + } + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] + #[rasn(automatic_tags)] + pub struct AddrTariffAs { + pub base: AddrTariffType, + #[rasn(default = "addr_tariff_as_weight_default")] + pub weight: AddrTariffAsWeight, + } + impl AddrTariffAs { + pub fn new(base: AddrTariffType, weight: AddrTariffAsWeight) -> Self { + Self { base, weight } + } + } + fn addr_tariff_as_weight_default() -> AddrTariffAsWeight { + HIGH + } #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] #[rasn(enumerated)] pub enum AddrTariffType { @@ -98,6 +130,28 @@ pub mod uds { #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] #[rasn(delegate)] pub struct AddrValidity(pub AddrValidityType); + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] + #[rasn(enumerated)] + pub enum AddrValidityAsWeight { + low = 0, + high = 1, + } + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] + #[rasn(automatic_tags)] + pub struct AddrValidityAs { + pub base: AddrValidityType, + #[rasn(default = "addr_validity_as_weight_default")] + pub weight: AddrValidityAsWeight, + } + impl AddrValidityAs { + pub fn new(base: AddrValidityType, weight: AddrValidityAsWeight) -> Self { + Self { base, weight } + } + } + fn addr_validity_as_weight_default() -> AddrValidityAsWeight { + HIGH + } #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] #[rasn(enumerated)] pub enum AddrValidityType { @@ -120,6 +174,34 @@ pub mod uds { addrTariffAs(AddrTariffAs), addrRestrictionAs(AddrRestrictionAs), } + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] + #[rasn(enumerated)] + pub enum AssertionAttrWeight { + low = 0, + high = 1, + } + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] + #[rasn(automatic_tags)] + pub struct AssertionAttr { + #[rasn(default = "assertion_attr_weight_default")] + pub weight: AssertionAttrWeight, + } + impl AssertionAttr { + pub fn new(weight: AssertionAttrWeight) -> Self { + Self { weight } + } + } + impl std::default::Default for AssertionAttr { + fn default() -> Self { + Self { + weight: assertion_attr_weight_default(), + } + } + } + fn assertion_attr_weight_default() -> AssertionAttrWeight { + HIGH + } #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] #[rasn(choice, automatic_tags)] pub enum Attribute { @@ -218,6 +300,109 @@ pub mod uds { Self { lang, base } } } + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] + #[rasn(enumerated)] + pub enum AnonymousBusinessCategorySubValueWordMatch { + exact = 0, + truncated = 1, + phonetic = 2, + } + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] + #[rasn(enumerated)] + pub enum AnonymousBusinessCategorySubValueCharacterMatch { + exact = 0, + caseIgnore = 1, + mapped = 2, + } + #[doc = " Anonymous SEQUENCE OF member "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] + #[rasn(automatic_tags, identifier = "SEQUENCE")] + pub struct AnonymousBusinessCategorySubValue { + pub base: Ub128, + #[rasn( + default = "anonymous_business_category_sub_value_word_match_default", + identifier = "wordMatch" + )] + pub word_match: AnonymousBusinessCategorySubValueWordMatch, + #[rasn( + default = "anonymous_business_category_sub_value_character_match_default", + identifier = "characterMatch" + )] + pub character_match: AnonymousBusinessCategorySubValueCharacterMatch, + } + impl AnonymousBusinessCategorySubValue { + pub fn new( + base: Ub128, + word_match: AnonymousBusinessCategorySubValueWordMatch, + character_match: AnonymousBusinessCategorySubValueCharacterMatch, + ) -> Self { + Self { + base, + word_match, + character_match, + } + } + } + fn anonymous_business_category_sub_value_word_match_default( + ) -> AnonymousBusinessCategorySubValueWordMatch { + CharacterMatchType::exact + } + fn anonymous_business_category_sub_value_character_match_default( + ) -> AnonymousBusinessCategorySubValueCharacterMatch { + CharacterMatchType::caseIgnore + } + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] + #[rasn(delegate, size("1.."))] + pub struct BusinessCategorySubValue(pub SequenceOf); + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] + #[rasn(enumerated)] + pub enum BusinessCategorySubString { + exact = 0, + deletion = 1, + restrDeletion = 2, + permutation = 3, + permutationAndDeletion = 4, + providerDefined = 5, + } + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] + #[rasn(enumerated)] + pub enum BusinessCategorySubWeight { + low = 0, + high = 1, + } + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] + #[rasn(automatic_tags)] + pub struct BusinessCategorySub { + pub value: BusinessCategorySubValue, + #[rasn(default = "business_category_sub_string_default")] + pub string: BusinessCategorySubString, + #[rasn(default = "business_category_sub_weight_default")] + pub weight: BusinessCategorySubWeight, + } + impl BusinessCategorySub { + pub fn new( + value: BusinessCategorySubValue, + string: BusinessCategorySubString, + weight: BusinessCategorySubWeight, + ) -> Self { + Self { + value, + string, + weight, + } + } + } + fn business_category_sub_string_default() -> BusinessCategorySubString { + CharacterMatchType::exact + } + fn business_category_sub_weight_default() -> BusinessCategorySubWeight { + HIGH + } #[doc = " Anonymous SEQUENCE OF member "] #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] #[rasn(choice, automatic_tags, identifier = "CHOICE")] @@ -260,9 +445,53 @@ pub mod uds { #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] #[rasn(delegate)] pub struct CommNetwork(pub NetworkType); + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] + #[rasn(enumerated)] + pub enum CommNetworkAsWeight { + low = 0, + high = 1, + } + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] + #[rasn(automatic_tags)] + pub struct CommNetworkAs { + pub base: NetworkType, + #[rasn(default = "comm_network_as_weight_default")] + pub weight: CommNetworkAsWeight, + } + impl CommNetworkAs { + pub fn new(base: NetworkType, weight: CommNetworkAsWeight) -> Self { + Self { base, weight } + } + } + fn comm_network_as_weight_default() -> CommNetworkAsWeight { + HIGH + } #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] #[rasn(delegate)] pub struct CommService(pub ComServiceTypes); + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] + #[rasn(enumerated)] + pub enum CommServiceAsWeight { + low = 0, + high = 1, + } + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] + #[rasn(automatic_tags)] + pub struct CommServiceAs { + pub base: ComServiceType, + #[rasn(default = "comm_service_as_weight_default")] + pub weight: CommServiceAsWeight, + } + impl CommServiceAs { + pub fn new(base: ComServiceType, weight: CommServiceAsWeight) -> Self { + Self { base, weight } + } + } + fn comm_service_as_weight_default() -> CommServiceAsWeight { + HIGH + } #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] #[rasn(automatic_tags)] pub struct CommsAddress { @@ -288,6 +517,28 @@ pub mod uds { #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] #[rasn(delegate)] pub struct Country(pub NMTOKEN); + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] + #[rasn(enumerated)] + pub enum CountryAsWeight { + low = 0, + high = 1, + } + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] + #[rasn(automatic_tags)] + pub struct CountryAs { + pub base: NMTOKEN, + #[rasn(default = "country_as_weight_default")] + pub weight: CountryAsWeight, + } + impl CountryAs { + pub fn new(base: NMTOKEN, weight: CountryAsWeight) -> Self { + Self { base, weight } + } + } + fn country_as_weight_default() -> CountryAsWeight { + HIGH + } #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] #[rasn(automatic_tags)] pub struct Description { @@ -302,6 +553,108 @@ pub mod uds { #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] #[rasn(delegate)] pub struct DmdName(pub Ub64); + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] + #[rasn(enumerated)] + pub enum AnonymousDmdNameSubValueWordMatch { + exact = 0, + truncated = 1, + phonetic = 2, + } + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] + #[rasn(enumerated)] + pub enum AnonymousDmdNameSubValueCharacterMatch { + exact = 0, + caseIgnore = 1, + mapped = 2, + } + #[doc = " Anonymous SEQUENCE OF member "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] + #[rasn(automatic_tags, identifier = "SEQUENCE")] + pub struct AnonymousDmdNameSubValue { + pub base: Ub64, + #[rasn( + default = "anonymous_dmd_name_sub_value_word_match_default", + identifier = "wordMatch" + )] + pub word_match: AnonymousDmdNameSubValueWordMatch, + #[rasn( + default = "anonymous_dmd_name_sub_value_character_match_default", + identifier = "characterMatch" + )] + pub character_match: AnonymousDmdNameSubValueCharacterMatch, + } + impl AnonymousDmdNameSubValue { + pub fn new( + base: Ub64, + word_match: AnonymousDmdNameSubValueWordMatch, + character_match: AnonymousDmdNameSubValueCharacterMatch, + ) -> Self { + Self { + base, + word_match, + character_match, + } + } + } + fn anonymous_dmd_name_sub_value_word_match_default() -> AnonymousDmdNameSubValueWordMatch { + CharacterMatchType::exact + } + fn anonymous_dmd_name_sub_value_character_match_default( + ) -> AnonymousDmdNameSubValueCharacterMatch { + CharacterMatchType::caseIgnore + } + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] + #[rasn(delegate, size("1.."))] + pub struct DmdNameSubValue(pub SequenceOf); + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] + #[rasn(enumerated)] + pub enum DmdNameSubString { + exact = 0, + deletion = 1, + restrDeletion = 2, + permutation = 3, + permutationAndDeletion = 4, + providerDefined = 5, + } + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] + #[rasn(enumerated)] + pub enum DmdNameSubWeight { + low = 0, + high = 1, + } + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] + #[rasn(automatic_tags)] + pub struct DmdNameSub { + pub value: DmdNameSubValue, + #[rasn(default = "dmd_name_sub_string_default")] + pub string: DmdNameSubString, + #[rasn(default = "dmd_name_sub_weight_default")] + pub weight: DmdNameSubWeight, + } + impl DmdNameSub { + pub fn new( + value: DmdNameSubValue, + string: DmdNameSubString, + weight: DmdNameSubWeight, + ) -> Self { + Self { + value, + string, + weight, + } + } + } + fn dmd_name_sub_string_default() -> DmdNameSubString { + CharacterMatchType::exact + } + fn dmd_name_sub_weight_default() -> DmdNameSubWeight { + HIGH + } #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] #[rasn(choice, automatic_tags)] pub enum Family { @@ -333,243 +686,1105 @@ pub mod uds { #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] #[rasn(delegate)] pub struct GivenName(pub Ub64); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate)] - pub struct HierarchySelectList(pub HierarchySelections); + #[doc = " Inner type "] #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] #[rasn(enumerated)] - pub enum HierarchySelection { - #[rasn(identifier = "self")] - R_self = 0, - children = 1, - parent = 2, - hierarchy = 3, - top = 4, - subtree = 5, - all = 6, + pub enum AnonymousGivenNameSubValueWordMatch { + exact = 0, + truncated = 1, + phonetic = 2, } - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate)] - pub struct HierarchySelections(pub SequenceOf); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate)] - pub struct HouseId(pub Ub64); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate)] - pub struct Language(pub super::xsd::Language); + #[doc = " Inner type "] #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] #[rasn(enumerated)] - pub enum LimitProblem { - adminLimit = 0, - permanentRestriction = 1, + pub enum AnonymousGivenNameSubValueCharacterMatch { + exact = 0, + caseIgnore = 1, + mapped = 2, } + #[doc = " Anonymous SEQUENCE OF member "] #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate)] - pub struct Locality(pub Ub128); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate)] - pub struct LocalityCode(pub Ub64); + #[rasn(automatic_tags, identifier = "SEQUENCE")] + pub struct AnonymousGivenNameSubValue { + pub base: Ub64, + #[rasn( + default = "anonymous_given_name_sub_value_word_match_default", + identifier = "wordMatch" + )] + pub word_match: AnonymousGivenNameSubValueWordMatch, + #[rasn( + default = "anonymous_given_name_sub_value_character_match_default", + identifier = "characterMatch" + )] + pub character_match: AnonymousGivenNameSubValueCharacterMatch, + } + impl AnonymousGivenNameSubValue { + pub fn new( + base: Ub64, + word_match: AnonymousGivenNameSubValueWordMatch, + character_match: AnonymousGivenNameSubValueCharacterMatch, + ) -> Self { + Self { + base, + word_match, + character_match, + } + } + } + fn anonymous_given_name_sub_value_word_match_default() -> AnonymousGivenNameSubValueWordMatch { + CharacterMatchType::exact + } + fn anonymous_given_name_sub_value_character_match_default( + ) -> AnonymousGivenNameSubValueCharacterMatch { + CharacterMatchType::caseIgnore + } + #[doc = " Inner type "] #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate)] - pub struct LocalityNDC(pub Ub16NumericString); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate)] - pub struct Mail(pub Ub256); + #[rasn(delegate, size("1.."))] + pub struct GivenNameSubValue(pub SequenceOf); + #[doc = " Inner type "] #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] #[rasn(enumerated)] - pub enum NetworkType { - pstn = 0, - isdn = 1, - gsm = 2, - umts = 3, - internet = 4, + pub enum GivenNameSubString { + exact = 0, + deletion = 1, + restrDeletion = 2, + permutation = 3, + permutationAndDeletion = 4, + providerDefined = 5, + } + #[doc = " Inner type "] + #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] + #[rasn(enumerated)] + pub enum GivenNameSubWeight { + low = 0, + high = 1, } #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate)] - pub struct NotSupported(pub Options); - #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(choice, automatic_tags)] - pub enum Notification { - limitProblem(LimitProblem), - serviceProblem(ServiceProblem), - searchType(SearchType), - attributeTypeList(AttributeTypeList), - filterNot(FilterNot), - filterItem(FilterItem), - providerName(ProviderName), - hierarchySelectList(HierarchySelectList), - searchControlOptionsList(SearchControlOptionsList), - attributeCombinations(AttributeCombinations), - wordRestriction(WordRestriction), - notSupported(NotSupported), + #[rasn(automatic_tags)] + pub struct GivenNameSub { + pub value: GivenNameSubValue, + #[rasn(default = "given_name_sub_string_default")] + pub string: GivenNameSubString, + #[rasn(default = "given_name_sub_weight_default")] + pub weight: GivenNameSubWeight, + } + impl GivenNameSub { + pub fn new( + value: GivenNameSubValue, + string: GivenNameSubString, + weight: GivenNameSubWeight, + ) -> Self { + Self { + value, + string, + weight, + } + } + } + fn given_name_sub_string_default() -> GivenNameSubString { + CharacterMatchType::exact + } + fn given_name_sub_weight_default() -> GivenNameSubWeight { + HIGH } #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] - #[rasn(delegate, identifier = "NumericString-1", from("\u{30}..=\u{39}"))] - pub struct NumericString1(pub Ia5String); + #[rasn(delegate)] + pub struct HierarchySelectList(pub HierarchySelections); #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash, Copy)] #[rasn(enumerated)] - pub enum Option { - paging = 0, - weighting = 1, + pub enum HierarchySelection { + #[rasn(identifier = "self")] + R_self = 0, + children = 1, + parent = 2, + hierarchy = 3, + top = 4, + subtree = 5, + all = 6, } #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)] #[rasn(delegate)] - pub struct Options(pub SequenceOf