Skip to content

Commit 3dd01cd

Browse files
committed
tlv: add Zero() method for OptionalRecordT
Most of the time with wire messages, we'll have the wrapped record, so this is useful when decoding into a blank instance of the record's value.
1 parent afde716 commit 3dd01cd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tlv/record_type.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ func (o *OptionalRecordT[T, V]) UnwrapOrErrV(err error) (V, error) {
140140
return inner.Val, nil
141141
}
142142

143+
// Zero returns a zero value of the record type.
144+
func (t *OptionalRecordT[T, V]) Zero() RecordT[T, V] {
145+
return ZeroRecordT[T, V]()
146+
}
147+
143148
// SomeRecordT creates a new OptionalRecordT type from a given RecordT type.
144149
func SomeRecordT[T TlvType, V any](record RecordT[T, V]) OptionalRecordT[T, V] {
145150
return OptionalRecordT[T, V]{

0 commit comments

Comments
 (0)