mirror of
https://github.com/valyala/bytebufferpool.git
synced 2026-06-14 13:26:35 +03:00
Added io.WriterTo implementation to ByteBuffer
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package bytebufferpool
|
||||
|
||||
import "io"
|
||||
|
||||
// ByteBuffer provides byte buffer, which can be used for minimizing
|
||||
// memory allocations.
|
||||
//
|
||||
@@ -14,6 +16,12 @@ type ByteBuffer struct {
|
||||
B []byte
|
||||
}
|
||||
|
||||
// WriteTo implements io.WriterTo
|
||||
func (b *ByteBuffer) WriteTo(w io.Writer) (int64, error) {
|
||||
n, err := w.Write(b.B)
|
||||
return int64(n), err
|
||||
}
|
||||
|
||||
// Bytes returns b.B, i.e. all the bytes accumulated in the buffer.
|
||||
//
|
||||
// The purpose of this function is bytes.Buffer compatibility.
|
||||
|
||||
Reference in New Issue
Block a user