You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a proposal that needs further discussion before implementing.
Currently, the smallest granularity that Codama supports when it comes to type definition is one byte.
However, there may be cases were, within a byte, some bits are being used for different things. For instance, a byte could be used to store 8 booleans using bit flags.
There are several ways we could achieve this.
From one end of the spectrum, we could analyse the concrete use-cases where such thing would be needed and offer specific type nodes from them. For instance, a BitFlagTypeNode could represent an array or struct of booleans such that each boolean is store in a single bit.
On the other end of the spectrum, we could reduce the overall number granularity supported by Codama by adding number formats such as u1, u2, etc. This makes the whole type system a lot more flexible as we can now construct things like bit flats using TupleTypeNodes or even StructTypeNodes if we wanted them to be named. The issue with the approach is we now need to handle bit-granularity at every level (Codecs for JS, custom types for Rust, etc.) and ensure we do not end up with incomplete bytes.
The text was updated successfully, but these errors were encountered:
This is a proposal that needs further discussion before implementing.
Currently, the smallest granularity that Codama supports when it comes to type definition is one byte.
However, there may be cases were, within a byte, some bits are being used for different things. For instance, a byte could be used to store 8 booleans using bit flags.
There are several ways we could achieve this.
From one end of the spectrum, we could analyse the concrete use-cases where such thing would be needed and offer specific type nodes from them. For instance, a
BitFlagTypeNode
could represent an array or struct of booleans such that each boolean is store in a single bit.On the other end of the spectrum, we could reduce the overall number granularity supported by Codama by adding number formats such as
u1
,u2
, etc. This makes the whole type system a lot more flexible as we can now construct things like bit flats usingTupleTypeNodes
or evenStructTypeNodes
if we wanted them to be named. The issue with the approach is we now need to handle bit-granularity at every level (Codecs for JS, custom types for Rust, etc.) and ensure we do not end up with incomplete bytes.The text was updated successfully, but these errors were encountered: