8000 Eliminate "Anonymous" wrapper struct for `SEQUENCE OF` element · Issue #86 · librasn/compiler · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
8000
Skip to content
Eliminate "Anonymous" wrapper struct for SEQUENCE OF element #86
Open
@DavidLeeds

Description

@DavidLeeds

As a follow-up to #84, it would be helpful to eliminate the gratuitous wrapper struct for anonymous SEQUENCE OF declarations. For example:

For:

   Ticket ::= SEQUENCE {
        ages		SEQUENCE OF INTEGER (1..5),	 
        passenger	Passenger OPTIONAL
    }
    Passenger ::= ENUMERATED {
        adult	(0),
        youth	(1),
        ...
    }

Go from:

        #[doc = " Anonymous SEQUENCE OF member "]
        #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
        #[rasn(delegate, value("1..=5"), identifier = "INTEGER")]
        pub struct AnonymousTicketAges(pub u8);
        #[doc = " Inner type "]
        #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
        #[rasn(delegate)]
        pub struct TicketAges(pub SequenceOf<AnonymousTicketAges>);
        #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
        #[rasn(automatic_tags)]
        pub struct Ticket {
            pub ages: TicketAges,
            pub passenger: Option<Passenger>,
        }

To:

        #[doc = "Ticket::ages SEQUENCE OF element"]
        #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
        #[rasn(delegate, value("1..=5"), identifier = "INTEGER")]
        pub struct TicketAgesElement(pub u8);
        #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
        #[rasn(automatic_tags)]
        pub struct Ticket {
            pub ages: SequenceOf<TicketAgesElement>,
            pub passenger: Option<Passenger>,
        }

This would reduce a significant amount of boilerplate code for complex ASN.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0