mirror of
https://github.com/fumiama/orbyte.git
synced 2026-06-05 10:10:30 +08:00
23 lines
613 B
Go
23 lines
613 B
Go
package pbuf
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
"github.com/fumiama/orbyte"
|
|
)
|
|
|
|
// NewBuffer wraps bytes.NewBuffer into Item.
|
|
func (bufferPool BufferPool) NewBuffer(buf []byte) *orbyte.Item[bytes.Buffer] {
|
|
return bufferPool.p.New(buf)
|
|
}
|
|
|
|
// InvolveBuffer involve external *bytes.Buffer into Item.
|
|
func (bufferPool BufferPool) InvolveBuffer(buf *bytes.Buffer) *orbyte.Item[bytes.Buffer] {
|
|
return bufferPool.p.Involve(buf.Len(), buf)
|
|
}
|
|
|
|
// ParseBuffer convert external *bytes.Buffer into Item.
|
|
func (bufferPool BufferPool) ParseBuffer(buf *bytes.Buffer) *orbyte.Item[bytes.Buffer] {
|
|
return bufferPool.p.Parse(buf.Len(), buf)
|
|
}
|