-
Notifications
You must be signed in to change notification settings - Fork 18
Description
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?