func (stream *ByteStream) WriteByte(source byte) error {
	stream.SetCapacity(stream.writeOffset + 1)
	stream.data[stream.writeOffset] = source
	stream.writeOffset++
	return nil
}
WriteByte writes a single byte to the stream. Capacity will be ensured.
package tio
import "io"
type ByteStream struct {
	data        []byte
	writeOffset int
	readOffset  int
}
func NewByteStream(capacity int) ByteStream {
	return ByteStream{
		data:        make([]byte, capacity),
		writeOffset: 0,
	}
}
func NewByteStreamFrom(data []byte) ByteStream {
	return ByteStream{
		data:        data,
		writeOffset: len(data),
	}
}
func (stream *ByteStream) SetCapacity(capacity int) {
	if stream.Cap() < capacity {
		current := stream.data
		stream.data = make([]byte, capacity)
		if stream.writeOffset > 0 {
			copy(stream.data, current[:stream.writeOffset])
		}
	}
}
func (stream *ByteStream) Reset() {
	stream.writeOffset = 0
	stream.ResetRead()
}
func (stream *ByteStream) ResetRead() {
	stream.readOffset = 0
}
func (stream ByteStream) Len() int {
	return stream.writeOffset
}
func (stream ByteStream) Cap() int {
	return len(stream.data)
}
func (stream ByteStream) Bytes() []byte {
	return stream.data[:stream.writeOffset]
}
func (stream ByteStream) String() string {
	return string(stream.data[:stream.writeOffset])
}
func (stream *ByteStream) Write(source []byte) (int, error) {
	sourceLen := len(source)
	if sourceLen == 0 {
		return 0, nil
	}
	stream.SetCapacity(stream.writeOffset + sourceLen)
	copy(stream.data[stream.writeOffset:], source[:sourceLen])
	stream.writeOffset += sourceLen
	return sourceLen, nil
}
func (stream *ByteStream) WriteString(source string) (int, error) {
	return stream.Write([]byte(source))
}