// Write implements the io.Writer interface.
// This function assures that the capacity of the underlying byte array is
// enough to store the incoming amount of data. Subsequent writes will allways
// append to the end of the stream until Reset() is called.
Write implements the io.Writer interface.
This function assures that the capacity of the underlying byte array is
enough to store the incoming amount of data. Subsequent writes will allways
append to the end of the stream until Reset() is called.
// Write implements the io . Writer interface . // This function assures that the capacity of the underlying byte array is // enough to store the incoming amount of data . Subsequent writes will allways // append to the end of the stream until Reset () is called .
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 ) 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 }
Write implements the io.Writer interface.
Write implements the io . Writer interface .