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

tlv: add new RecordT[T] utility type #8121

Merged
merged 3 commits into from
Dec 13, 2023

Commits on Dec 13, 2023

  1. tlv/internal: add new internal package for generating TLV type structs

    In this commit, we add some new code generation to the codebase. As
    we'll see in a future commit, this'll allow us to create a new Record[T,
    V] type, where T is actually a concrete _struct_ that implements a
    special interface that deems it as a valid TLV type.
    Roasbeef committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    78d5806 View commit details
    Browse the repository at this point in the history
  2. tlv: run go generate for new set of TLV types

    This shouldn't need to be run again, as this implementation restricts
    things to just values 0-99, due to a hard upper limit with the way Go
    unions work under the hood.
    Roasbeef committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    c304c2a View commit details
    Browse the repository at this point in the history
  3. tlv: add new RecordT[T, V] utility type

    In this commit, we add a new type, `RecordT[T, V]` to reduce some of the
    common boiler plate for TLV types. This type lets you take either a
    primitive type, or an existing Record, and gain common methods used to
    create tlv streams.
    
    It also serves as extra type annotation as well, since wire structs can
    use this to wrap any existing type and gain the relevant record methods.
    
    This implementation ensures that the very definition of the field also
    binds the TLV type value. It does this by using the generated code to
    map a struct like TlvType1 to an actually Type like Type(1).
    Roasbeef committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    63e86b7 View commit details
    Browse the repository at this point in the history