Is there a function to turn a Num to a byte array? I could not find anything.
I don't think so currently. I believe we want to add a form that goes from numbers to the correct sized tuple.
I see, that would make accessing bytes easier. Is there an easy way to turn a tuple to List. The Encoding Ability needs a List U8, so it might be helpful to have.
None currenlty
Would have to deconstruct and assign
(a, b, c, d) = tup
list = [a, b, c, d]
That or use the getters
list = [tup.0, tup.1, tup.2, tup.3]
Brendan Hansknecht said:
I don't think so currently. I believe we want to add a form that goes from numbers to the correct sized tuple.
Do we need to discuss this more with a specific proposal? Or can we go straight to an Issue and imementation if it's pretty straightforward? I'm keen to progress this as I would really like to use it.
Might be worth discussing a bit due to:
Kinda minor, but probably worth discussing. Cause I think as the current plan stands, fromBytes
would take a list, but toBytes
would generate a tuple. Need to decide the trade off between convenience and avoiding allocation. Might be a case where we also need functions to convert tuples to lists and back, but not fully sure.
I assume both toBytes and fromBytes will need an endianness parameter?
Yep. That is the plan
Ohk, I'm definitely thinking a proposal will help then. My thoughts were both sides should be tuples. I'll try and write something up then.
Last updated: Jul 06 2025 at 12:14 UTC