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

Add support for union types #1

Closed
mchitre opened this issue Sep 29, 2023 · 1 comment
Closed

Add support for union types #1

mchitre opened this issue Sep 29, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@mchitre
Copy link
Member

mchitre commented Sep 29, 2023

Currently PDUs cannot contain union types, where a field may contain different types of nested PDUs depending on the value of another field. This is a common use case in many protocols, and so we should support it.

Support could be added by allowing a declaration of fieldtype(...) for a PDU field, similar to what we do for length(...). The function will return a field type based on inspecting the PDU. If it returns nothing, we wire-encode a field type in the PDU, otherwise we use the returned type to correctly decode the PDU.

@mchitre mchitre self-assigned this Sep 29, 2023
@mchitre mchitre added the enhancement New feature or request label Sep 29, 2023
@mchitre
Copy link
Member Author

mchitre commented Sep 30, 2023

Implemented support for Union and nothing.

Wire-encoding is not supported as there is no way in Julia currently to enumerate union component types in a documented way. Undocumented ways exist, but are likely to break with Julia versions. It is better for users to explicitly define the header type field to avoid this risk.

@mchitre mchitre closed this as completed Sep 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant