Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Encode and Decode for non-empty tuple types? #403

Open
repnop opened this issue Jan 7, 2025 · 1 comment
Open

Implement Encode and Decode for non-empty tuple types? #403

repnop opened this issue Jan 7, 2025 · 1 comment

Comments

@repnop
Copy link
Contributor

repnop commented Jan 7, 2025

I've been messing around with a library for some work stuff and had an interesting idea that would utilize tuple types, though they would need the Encode and Decode impls for this to work. my thought is that the tuples would be encoded as a SEQUENCE type, similar to arrays and Vecs, but allowing for heterogeneous types in the sequence. thoughts? only complication I think would be perhaps in the decoding step since right now the decode_sequence_of API expects a single type and the decode_sequence seems somewhat complicated for something like this (and I didn't quite understand exactly what the purpose of some of the parameters and args was).

@XAMPPRocky
Copy link
Collaborator

It would need to use decode_sequence, because as you said, heterogenous types. It would also need to still have field information for codecs like JER, which I think is the bigger issue, since if you need field names, why have a tuple? I think maybe one possibility is for small fixed inner sequence. I think this would be supplanted if anonymous struct language feature was ever stabilised.

#[derive(AsnType)]
struct Foo {
    #[rasn(sequence(field_1, field_2))]
    inner: (u32, u32),
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants