Skip to content

Inner Subtype Constraints #101

@Nicceboy

Description

@Nicceboy

Hi,

I have been playing on inner subtype constraints on rasn side, that is something compiler likely wants to have also in some point. These constraints are very complex and compiler would need to maintain the whole dependency graph of the constraint context to have the understanding of all the types.

Without compiler, I think there is no other way but introduce additional DSL that adds type information manually.

Something like this

#[derive(AsnType, Debug, Decode, Encode, PartialEq, InnerSubtypeConstraint)]
#[inner_subtype_constraint(
    content => {
        kind = "choice:Ieee1609Dot2Content",
        signedData => {
            kind = "sequence:SignedData", // not necessary since sequence can be unpacked without knowing the type
            tbsData => {
                headerInfo => {
                    generationTime => present,
                    p2pcdLearningRequest => absent,
                    missingCrlIdentifier => absent
                }
            },
            signer => {
                certificate => (EtsiTs103097Certificate, size(1))
            }
        },
        encryptedData => {
            recipients => {
                pskRecipInfo => absent,
                symmRecipInfo=> absent,
                rekRecipInfo => absent
            }
        },
        signedCertificateRequest => absent
    },
)]
pub struct EtsiTs103097Data(Ieee1609Dot2Data);

Proc-macros can then use this DSL to generate constraint checks. At some level it already works, but only with subset of features and it can be difficult to maintain and support everything.

I was kinda wondering what is the state of these constraints in the compiler side and does it make sense for compiler to generate this DSL or just generate the validation functions/ additional constraints directly and bypass it completely? Compiler likely can handle this much better, but would we like to support usage without compiler as well?

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