mirror of
https://github.com/fumiama/orbyte.git
synced 2026-06-05 02:00:30 +08:00
feat(pbuf): add api BufferItemToBytes
This commit is contained in:
@@ -13,6 +13,16 @@ type Bytes struct {
|
||||
dat []byte
|
||||
}
|
||||
|
||||
// BufferItemToBytes convert between *orbyte.Item[bytes.Buffer]
|
||||
// and Bytes.
|
||||
//
|
||||
// Please notice that Bytes cannnot convert back to
|
||||
// *orbyte.Item[bytes.Buffer] again.
|
||||
func BufferItemToBytes(buf *orbyte.Item[bytes.Buffer]) Bytes {
|
||||
x := buf.Unwrap()
|
||||
return Bytes{buf: buf, dat: x.Bytes()}
|
||||
}
|
||||
|
||||
// NewBytes alloc sz bytes.
|
||||
func (bufferPool BufferPool) NewBytes(sz int) Bytes {
|
||||
buf := bufferPool.p.New(sz)
|
||||
|
||||
Reference in New Issue
Block a user