Skip to content

Commit

Permalink
tlv: add axiomatic RecordProducer implementation for Record
Browse files Browse the repository at this point in the history
This commit introduces a RecordProducer implementation for Record
that serves as the identity function. This makes it easier for us
to mix Primitive and Dynamic records in the same RecordProducer
collections.
  • Loading branch information
ProofOfKeags committed Apr 18, 2024
1 parent 2ccf58e commit 6257df3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tlv/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ type Record struct {
decoder Decoder
}

// Record (the function) is the trivial implementation of RecordProducer for
// Record (the type). This makes it seamless to mix primitive and dynamic
// records together in the same collections.
//
// NOTE: Part of the RecordProducer interface.
func (f *Record) Record() Record {
return *f
}

// Size returns the size of the Record's value. If no static size is known, the
// dynamic size will be evaluated.
func (f *Record) Size() uint64 {
Expand Down

0 comments on commit 6257df3

Please sign in to comment.