Package io.servicetalk.buffer.netty
Class BufferUtils
java.lang.Object
io.servicetalk.buffer.netty.BufferUtils
Internal utilities for
Buffer
s.-
Method Summary
Modifier and TypeMethodDescriptionstatic io.netty.buffer.ByteBuf
extractByteBufOrCreate
(Buffer buffer) Converts the passedbuffer
toByteBuf
, creating a newByteBuf
instance if required.static io.netty.buffer.ByteBufAllocator
getByteBufAllocator
(BufferAllocator allocator) Returns theByteBufAllocator
taking theBufferAllocator
into account.static int
maxUtf8Bytes
(CharSequence data) Calculate the max bytes length of UTF8 character sequence.static Buffer
newBufferFrom
(io.netty.buffer.ByteBuf buffer) Return aBuffer
for the givenByteBuf
.static io.netty.buffer.ByteBuf
Return aByteBuf
for the given buffer.static io.netty.buffer.ByteBuf
toByteBufNoThrow
(Buffer buffer) Converts the passedbuffer
toByteBuf
, or returnsnull
if not possible.
-
Method Details
-
toByteBuf
Return aByteBuf
for the given buffer.- Parameters:
buffer
- the buffer.- Returns:
- a
ByteBuf
.
-
extractByteBufOrCreate
Converts the passedbuffer
toByteBuf
, creating a newByteBuf
instance if required.- Parameters:
buffer
- the buffer.- Returns:
- a
ByteBuf
.
-
toByteBufNoThrow
Converts the passedbuffer
toByteBuf
, or returnsnull
if not possible.- Parameters:
buffer
- TheBuffer
to convert.- Returns:
- a
ByteBuf
equivalent ofbuffer
, ornull
if no equivalent can be found.
-
getByteBufAllocator
Returns theByteBufAllocator
taking theBufferAllocator
into account.- Parameters:
allocator
- theBufferAllocator
that is used.- Returns:
- the
ByteBufAllocator
to use.
-
newBufferFrom
Return aBuffer
for the givenByteBuf
.- Parameters:
buffer
- the buffer to wrap.- Returns:
- the created buffer.
-
maxUtf8Bytes
Calculate the max bytes length of UTF8 character sequence.- Parameters:
data
- the data to be encoded in UTF8.- Returns:
- max bytes length of UTF8 character sequence.
-