tape: Encoder inherits bufio.Writer, need to do same for decoder
This commit is contained in:
parent
3eb826735b
commit
08fe3d45dd
@ -2,6 +2,7 @@ package tape
|
||||
|
||||
import "io"
|
||||
import "math"
|
||||
import "bufio"
|
||||
|
||||
// Encodable is any type that can write itself to an encoder.
|
||||
type Encodable interface {
|
||||
@ -10,14 +11,16 @@ type Encodable interface {
|
||||
Encode(encoder *Encoder) (n int, err error)
|
||||
}
|
||||
|
||||
// Encoder wraps an [io.Writer] and encodes data to it.
|
||||
// Encoder encodes data to an io.Writer.
|
||||
type Encoder struct {
|
||||
io.Writer
|
||||
bufio.Writer
|
||||
}
|
||||
|
||||
// WriteByte encodes a single byte to the output writer.
|
||||
func (this *Encoder) WriteByte(value byte) (n int, err error) {
|
||||
return this.WriteByte(uint8(value))
|
||||
// NewEncoder creates a new encoder that writes to writer.
|
||||
func NewEncoder(writer io.Writer) *Encoder {
|
||||
encoder := &Encoder { }
|
||||
encoder.Reset(writer)
|
||||
return encoder
|
||||
}
|
||||
|
||||
// WriteInt8 encodes an 8-bit signed integer to the output writer.
|
||||
|
Loading…
Reference in New Issue
Block a user