public class NettyBufferFactory extends Object implements BufferFactory<ByteBuf>
Buffer
instances from wrapped ByteBuf
instances.Constructor and Description |
---|
NettyBufferFactory() |
Modifier and Type | Method and Description |
---|---|
Buffer |
create(ByteBuf value)
Creates a new
Buffer given a T instance. |
static void |
readRaw(Buffer buffer,
Consumer<ByteBuf> consumer)
Utility method to allow reading from the underlying bytes using a Netty
ByteBuf instance for
interoperability, advancing the reader index of the Buffer after the consumer is called. |
Buffer |
wrap(ByteBuffer value)
Wraps a NIO buffer.
|
static void |
writeRaw(Buffer buffer,
Consumer<ByteBuf> consumer)
Allows writing from the underlying bytes using a Netty
ByteBuf instance for interoperability,
advancing the writer index of the Buffer after the consumer is called. |
public Buffer create(ByteBuf value)
BufferFactory
Buffer
given a T
instance.create
in interface BufferFactory<ByteBuf>
public Buffer wrap(ByteBuffer value)
BufferFactory
wrap
in interface BufferFactory<ByteBuf>
public static void readRaw(Buffer buffer, Consumer<ByteBuf> consumer)
ByteBuf
instance for
interoperability, advancing the reader index of the Buffer
after the consumer is called.
Note that the ByteBuf
used by the consumer should not be released by the caller.
In case the provided Buffer
instance is not a NettyBuffer
, it will create a ByteBuf
wrapper for the consumer to use, releasing it after use.public static void writeRaw(Buffer buffer, Consumer<ByteBuf> consumer)
ByteBuf
instance for interoperability,
advancing the writer index of the Buffer
after the consumer is called.
Note that the ByteBuf
used by the consumer should not be released by the caller.
In case the provided Buffer
instance is not a NettyBuffer
, it will create a ByteBuf
wrapper for the consumer to use, releasing it after use.Copyright © 2013–2021 Apache Software Foundation. All rights reserved.