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.
This commit is contained in:
Olaoluwa Osuntokun 2024-02-24 16:44:15 -08:00
parent afde7162c6
commit 3dd01cdc78
No known key found for this signature in database
GPG Key ID: 3BBD59E99B280306

View File

@ -140,6 +140,11 @@ func (o *OptionalRecordT[T, V]) UnwrapOrErrV(err error) (V, error) {
return inner.Val, nil
}
// Zero returns a zero value of the record type.
func (t *OptionalRecordT[T, V]) Zero() RecordT[T, V] {
return ZeroRecordT[T, V]()
}
// SomeRecordT creates a new OptionalRecordT type from a given RecordT type.
func SomeRecordT[T TlvType, V any](record RecordT[T, V]) OptionalRecordT[T, V] {
return OptionalRecordT[T, V]{