Open Nicceboy opened 2 weeks ago
Seems like that current option values are based on mapping the Result to Option, so Option value is not really based on the decoder logic:
impl rasn::Decode for SequenceOptionals {
fn decode_with_tag_and_constraints<'constraints, D: rasn::Decoder>(
decoder: &mut D,
tag: rasn::Tag,
constraints: rasn::types::Constraints<'constraints>,
) -> core::result::Result<Self, D::Error> {
decoder.decode_sequence(tag, None::<fn() -> Self>, |decoder| {
Ok(Self {
it: {
decoder
.decode_explicit_prefix(rasn::Tag::new(rasn::types::Class::Context, 0))
.map_err(|error| {
rasn::de::Error::field_error(
"SequenceOptionals.it",
error.into(),
decoder.codec(),
)
})?
},
is: {
decoder
.decode_explicit_prefix(rasn::Tag::new(rasn::types::Class::Context, 1))
.ok()
},
late: {
decoder
.decode_explicit_prefix(rasn::Tag::new(rasn::types::Class::Context, 2))
.ok()
},
})
})
}
}
Seems like there is also bug in OER. When resolved, it which fixes this particular case, but I am not sure if this is still issue on some other scenarios.
We can probably remove the ok and/or add an explicit type parameter to decode explicit prefix.
When explicit tags are used for optional fields, wrong decoding (maybe encoding too) functions are derived. Or maybe option type disappears somehow, as the code does not hit the
decode_optional_*
methods.This seemed to be rather hard to debug, if there are any hints where this check happens.
Output (decoder does not hit the
decode_option_*
With
tag()
it works fine and correct code is executed.