tape: Add tag functions to the encoder

This commit is contained in:
Sasha Koshka 2025-06-21 19:26:15 -04:00
parent 663cab6b77
commit 7b8240cec6
2 changed files with 12 additions and 0 deletions

View File

@ -140,3 +140,10 @@ func (this *Decoder) ReadFloat64() (value float64, n int, err error) {
n += nn; if err != nil { return 0, n, err }
return math.Float64frombits(bits), n, nil
}
// ReadTag decodes a [Tag] from the input reader.
func (this *Decoder) ReadTag() (value Tag, n int, err error) {
uncasted, nn, err := this.ReadUint8()
n += nn; if err != nil { return 0, n, err }
return Tag(uncasted), n, nil
}

View File

@ -129,3 +129,8 @@ func (this *Encoder) WriteFloat32(value float32) (n int, err error) {
func (this *Encoder) WriteFloat64(value float64) (n int, err error) {
return this.WriteUint64(math.Float64bits(value))
}
// WriteTag encodes a [Tag] to the output writer.
func (this *Encoder) WriteTag(value Tag) (n int, err error) {
return this.WriteUint8(uint8(value))
}