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

Methods for serialising and deserialising Nat to/from bytes #83

Open
2 tasks
saxbophone opened this issue May 24, 2022 · 1 comment
Open
2 tasks

Methods for serialising and deserialising Nat to/from bytes #83

saxbophone opened this issue May 24, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@saxbophone
Copy link
Owner

saxbophone commented May 24, 2022

  • convert Nat object to sequence of bytes

  • convert sequence of bytes to Nat object

  • Note: these methods should be documented as portable between compatible versions of arby and across different platforms (i.e. you can safely send output of object bytes from v0.4.0 running on macOS to v0.4.5 on Windows and get the same number value out at the other end).

  • To be able to do this at compile-time, requires a dynamic-size container type like that used for our _digits array in Nat. This could be reused, of course...

    • A neater way could be to create a proxy-object that just wraps _digits in a way that access into the proxy object is indexed to the individual bytes of the digits, without additional heap allocation. This could be a better way of doing it, really. We could even convert bytes back to object via such a technique!
  • We will encode/decode the value as big-endian sequences of bytes, and we will document it as such

@saxbophone saxbophone added the enhancement New feature or request label May 24, 2022
@saxbophone saxbophone added this to the v0.5 milestone May 26, 2022
@saxbophone saxbophone self-assigned this Jun 9, 2022
@saxbophone saxbophone modified the milestones: v0.5, v0.6 Jul 4, 2022
@saxbophone
Copy link
Owner Author

Can we use iterator pairs to sidestep the limitations around returning a constexpr-allocated object?

@saxbophone saxbophone removed this from the v0.6 milestone Feb 19, 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