// Read implements the io.Reader interface.
// The underlying array is copied to target and io.EOF is returned once no data
// is left to be read. Please note that ResetRead can rewind the internal read
// index for this operation.
Read implements the io.Reader interface.
The underlying array is copied to target and io.EOF is returned once no data
is left to be read. Please note that ResetRead can rewind the internal read
index for this operation.
// Read implements the io . Reader interface . // The underlying array is copied to target and io . EOF is returned once no data // is left to be read . Please note that ResetRead can rewind the internal read // index for this operation .
func (stream *ByteStream) Read(target []byte) (int, error) {
	if stream.readOffset >= stream.writeOffset {
		return 0, io.EOF 
	}
	bytesCopied := copy(target, stream.data[stream.readOffset:stream.writeOffset])
	stream.readOffset += bytesCopied
	if stream.readOffset >= stream.writeOffset {
		return bytesCopied, io.EOF
	}
	return bytesCopied, nil
}
func ( stream * ByteStream ) Read ( target [ ] byte ) ( int , error ) { if stream . readOffset >= stream . writeOffset { return 0 , io . EOF } bytesCopied := copy ( target , stream . data [ stream . readOffset : stream . writeOffset ] ) stream . readOffset += bytesCopied if stream . readOffset >= stream . writeOffset { return bytesCopied , io . EOF } return bytesCopied , nil }
Read implements the io.Reader interface.
Read implements the io . Reader interface .
// ### return, no new data to read ###