Class MemorySegmentBuffer

java.lang.Object
io.netty5.buffer.internal.ResourceSupport<io.netty5.buffer.Buffer, MemorySegmentBuffer>
io.netty5.buffer.internal.AdaptableBuffer<MemorySegmentBuffer>
eu.cloudnetservice.driver.impl.network.netty.memory.MemorySegmentBuffer
All Implemented Interfaces:
io.netty5.buffer.Buffer, io.netty5.buffer.BufferAccessor, io.netty5.buffer.BufferComponent, io.netty5.buffer.ComponentIterator<MemorySegmentBuffer>, io.netty5.buffer.ComponentIterator.Next, io.netty5.util.Resource<io.netty5.buffer.Buffer>, io.netty5.util.SafeCloseable, AutoCloseable

final class MemorySegmentBuffer extends io.netty5.buffer.internal.AdaptableBuffer<MemorySegmentBuffer> implements io.netty5.buffer.BufferComponent, io.netty5.buffer.ComponentIterator<MemorySegmentBuffer>, io.netty5.buffer.ComponentIterator.Next
Netty buffer implementation that is backed by a memory segment.
Since:
4.0
  • Field Details

    • CLOSED_SEGMENT

      private static final MemorySegment CLOSED_SEGMENT
    • LAYOUT_BYTE

      private static final VarHandle LAYOUT_BYTE
    • LAYOUT_SHORT

      private static final VarHandle LAYOUT_SHORT
    • LAYOUT_INT

      private static final VarHandle LAYOUT_INT
    • LAYOUT_LONG

      private static final VarHandle LAYOUT_LONG
    • LAYOUT_FLOAT

      private static final VarHandle LAYOUT_FLOAT
    • LAYOUT_DOUBLE

      private static final VarHandle LAYOUT_DOUBLE
    • LAYOUT_CHAR

      private static final VarHandle LAYOUT_CHAR
    • UNCHECKED_LOAD_BYTE

      private static final io.netty5.buffer.internal.InternalBufferUtils.UncheckedLoadByte UNCHECKED_LOAD_BYTE
    • NO_BACKING_ARRAY

      private static final Supplier<UnsupportedOperationException> NO_BACKING_ARRAY
    • baseSegment

      private MemorySegment baseSegment
    • readSegment

      private MemorySegment readSegment
    • writeSegment

      private MemorySegment writeSegment
    • readerOffset

      private int readerOffset
    • writerOffset

      private int writerOffset
    • capacityLimit

      private int capacityLimit
  • Constructor Details

    • MemorySegmentBuffer

      MemorySegmentBuffer(@NonNull @NonNull MemorySegment baseSegment, @NonNull @NonNull io.netty5.buffer.AllocatorControl control, @NonNull @NonNull io.netty5.buffer.Drop<MemorySegmentBuffer> drop)
      Constructs a new memory segment buffer based on the given base segment.
      Parameters:
      baseSegment - the base segment for the buffer, also used for reading and writing.
      control - the controller for the allocator that requested the allocation.
      drop - the drop which is associated with this buffer.
      Throws:
      NullPointerException - if the given base segment, control or drop is null.
    • MemorySegmentBuffer

      private MemorySegmentBuffer(@NonNull @NonNull MemorySegment baseSegment, @NonNull @NonNull MemorySegment rwSegment, @NonNull @NonNull io.netty5.buffer.AllocatorControl control, @NonNull @NonNull io.netty5.buffer.Drop<MemorySegmentBuffer> drop)
      Constructs a new memory segment buffer based on the given memory segments.
      Parameters:
      baseSegment - the base segment for the buffer.
      rwSegment - the segment to use for reading and writing.
      control - the controller for the allocator that requested the allocation.
      drop - the drop which is associated with this buffer.
      Throws:
      NullPointerException - if the given base segment, rw-segment, control or drop is null.
    • MemorySegmentBuffer

      private MemorySegmentBuffer(@NonNull @NonNull MemorySegmentBuffer parent, @NonNull @NonNull io.netty5.buffer.Drop<MemorySegmentBuffer> drop)
      Constructs a buffer that represents a constant child of the given parent buffer.
      Parameters:
      parent - the parent buffer of this constant child buffer.
      drop - the drop that is associated with this child buffer.
      Throws:
      NullPointerException - if the given parent buffer or drop is null.
  • Method Details

    • layoutVarHandle

      @NonNull private static @NonNull VarHandle layoutVarHandle(@NonNull @NonNull ValueLayout layout)
      Creates a VarHandle that can be used for unaligned, big endian access into a memory segment.
      Parameters:
      layout - the layout to get the described var handle for.
      Returns:
      a var handle for unaligned, big endian access into a memory segment.
      Throws:
      NullPointerException - if the given value layout is null.
    • capacity

      public int capacity()
      Specified by:
      capacity in interface io.netty5.buffer.Buffer
    • readerOffset

      public int readerOffset()
      Specified by:
      readerOffset in interface io.netty5.buffer.Buffer
    • skipReadableBytes

      @NonNull public @NonNull MemorySegmentBuffer skipReadableBytes(int delta)
      Specified by:
      skipReadableBytes in interface io.netty5.buffer.Buffer
      Specified by:
      skipReadableBytes in interface io.netty5.buffer.BufferComponent
    • readerOffset

      @NonNull public @NonNull MemorySegmentBuffer readerOffset(int offset)
      Specified by:
      readerOffset in interface io.netty5.buffer.Buffer
    • writerOffset

      public int writerOffset()
      Specified by:
      writerOffset in interface io.netty5.buffer.Buffer
    • skipWritableBytes

      @NonNull public @NonNull MemorySegmentBuffer skipWritableBytes(int delta)
      Specified by:
      skipWritableBytes in interface io.netty5.buffer.Buffer
      Specified by:
      skipWritableBytes in interface io.netty5.buffer.BufferComponent
    • writerOffset

      @NonNull public @NonNull MemorySegmentBuffer writerOffset(int offset)
      Specified by:
      writerOffset in interface io.netty5.buffer.Buffer
    • readableBytes

      public int readableBytes()
      Specified by:
      readableBytes in interface io.netty5.buffer.Buffer
      Specified by:
      readableBytes in interface io.netty5.buffer.BufferComponent
    • writableBytes

      public int writableBytes()
      Specified by:
      writableBytes in interface io.netty5.buffer.Buffer
      Specified by:
      writableBytes in interface io.netty5.buffer.BufferComponent
    • fill

      @NonNull public @NonNull MemorySegmentBuffer fill(byte value)
      Specified by:
      fill in interface io.netty5.buffer.Buffer
    • makeReadOnly

      @NonNull public @NonNull MemorySegmentBuffer makeReadOnly()
      Specified by:
      makeReadOnly in interface io.netty5.buffer.Buffer
    • readOnly

      public boolean readOnly()
      Specified by:
      readOnly in interface io.netty5.buffer.Buffer
    • isDirect

      public boolean isDirect()
      Specified by:
      isDirect in interface io.netty5.buffer.Buffer
    • implicitCapacityLimit

      @NonNull public @NonNull MemorySegmentBuffer implicitCapacityLimit(int limit)
      Specified by:
      implicitCapacityLimit in interface io.netty5.buffer.Buffer
    • implicitCapacityLimit

      public int implicitCapacityLimit()
      Specified by:
      implicitCapacityLimit in interface io.netty5.buffer.Buffer
    • copyInto

      public void copyInto(int srcPos, byte[] dest, int destPos, int length)
      Specified by:
      copyInto in interface io.netty5.buffer.Buffer
    • copyInto

      public void copyInto(int srcPos, @NonNull @NonNull ByteBuffer dest, int destPos, int length)
      Specified by:
      copyInto in interface io.netty5.buffer.Buffer
    • copyInto

      public void copyInto(int srcPos, @NonNull @NonNull io.netty5.buffer.Buffer dest, int destPos, int length)
      Specified by:
      copyInto in interface io.netty5.buffer.Buffer
    • transferTo

      public int transferTo(@NonNull @NonNull WritableByteChannel channel, int length) throws IOException
      Specified by:
      transferTo in interface io.netty5.buffer.Buffer
      Throws:
      IOException
    • transferTo

      public int transferTo(@NonNull @NonNull FileChannel channel, long position, int length) throws IOException
      Specified by:
      transferTo in interface io.netty5.buffer.Buffer
      Throws:
      IOException
    • transferFrom

      public int transferFrom(@NonNull @NonNull FileChannel channel, long position, int length) throws IOException
      Specified by:
      transferFrom in interface io.netty5.buffer.Buffer
      Throws:
      IOException
    • transferFrom

      public int transferFrom(@NonNull @NonNull ReadableByteChannel channel, int length) throws IOException
      Specified by:
      transferFrom in interface io.netty5.buffer.Buffer
      Throws:
      IOException
    • writeCharSequence

      Specified by:
      writeCharSequence in interface io.netty5.buffer.Buffer
    • writeBytes

      @NonNull public @NonNull MemorySegmentBuffer writeBytes(byte[] source)
      Specified by:
      writeBytes in interface io.netty5.buffer.Buffer
    • writeBytes

      @NonNull public @NonNull MemorySegmentBuffer writeBytes(byte[] source, int srcPos, int length)
      Specified by:
      writeBytes in interface io.netty5.buffer.Buffer
    • writeBytes

      Specified by:
      writeBytes in interface io.netty5.buffer.Buffer
    • bytesBefore

      public int bytesBefore(byte needle)
      Specified by:
      bytesBefore in interface io.netty5.buffer.Buffer
    • bytesBefore

      public int bytesBefore(@NonNull @NonNull io.netty5.buffer.Buffer needle)
      Specified by:
      bytesBefore in interface io.netty5.buffer.Buffer
    • openCursor

      @NonNull public @NonNull io.netty5.buffer.ByteCursor openCursor()
      Specified by:
      openCursor in interface io.netty5.buffer.Buffer
      Specified by:
      openCursor in interface io.netty5.buffer.BufferComponent
    • openCursor

      @NonNull public @NonNull io.netty5.buffer.ByteCursor openCursor(int fromOffset, int length)
      Specified by:
      openCursor in interface io.netty5.buffer.Buffer
    • openReverseCursor

      @NonNull public @NonNull io.netty5.buffer.ByteCursor openReverseCursor()
      Specified by:
      openReverseCursor in interface io.netty5.buffer.Buffer
    • openReverseCursor

      @NonNull public @NonNull io.netty5.buffer.ByteCursor openReverseCursor(int fromOffset, int length)
      Specified by:
      openReverseCursor in interface io.netty5.buffer.Buffer
    • ensureWritable

      @NonNull public @NonNull MemorySegmentBuffer ensureWritable(int size)
      Specified by:
      ensureWritable in interface io.netty5.buffer.Buffer
    • ensureWritable

      @NonNull public @NonNull MemorySegmentBuffer ensureWritable(int size, int minimumGrowth, boolean allowCompaction)
      Specified by:
      ensureWritable in interface io.netty5.buffer.Buffer
    • copy

      Specified by:
      copy in interface io.netty5.buffer.Buffer
    • copy

      @NonNull public @NonNull MemorySegmentBuffer copy(int offset, int length)
      Specified by:
      copy in interface io.netty5.buffer.Buffer
    • copy

      @NonNull public @NonNull MemorySegmentBuffer copy(boolean readOnly)
      Specified by:
      copy in interface io.netty5.buffer.Buffer
    • copy

      @NonNull public @NonNull MemorySegmentBuffer copy(int offset, int length, boolean readOnly)
      Specified by:
      copy in interface io.netty5.buffer.Buffer
    • readSplit

      @NonNull public @NonNull MemorySegmentBuffer readSplit(int length)
      Specified by:
      readSplit in interface io.netty5.buffer.Buffer
    • writeSplit

      @NonNull public @NonNull MemorySegmentBuffer writeSplit(int length)
      Specified by:
      writeSplit in interface io.netty5.buffer.Buffer
    • split

      Specified by:
      split in interface io.netty5.buffer.Buffer
    • split

      @NonNull public @NonNull MemorySegmentBuffer split(int splitOffset)
      Specified by:
      split in interface io.netty5.buffer.Buffer
    • compact

      Specified by:
      compact in interface io.netty5.buffer.Buffer
    • countComponents

      public int countComponents()
      Specified by:
      countComponents in interface io.netty5.buffer.Buffer
    • countReadableComponents

      public int countReadableComponents()
      Specified by:
      countReadableComponents in interface io.netty5.buffer.Buffer
    • countWritableComponents

      public int countWritableComponents()
      Specified by:
      countWritableComponents in interface io.netty5.buffer.Buffer
    • forEachComponent

      @NonNull public <T extends io.netty5.buffer.BufferComponent & io.netty5.buffer.ComponentIterator.Next> @NonNull io.netty5.buffer.ComponentIterator<T> forEachComponent()
      Specified by:
      forEachComponent in interface io.netty5.buffer.Buffer
    • readByte

      public byte readByte()
      Specified by:
      readByte in interface io.netty5.buffer.BufferAccessor
    • getByte

      public byte getByte(int roff)
      Specified by:
      getByte in interface io.netty5.buffer.BufferAccessor
    • readUnsignedByte

      public int readUnsignedByte()
      Specified by:
      readUnsignedByte in interface io.netty5.buffer.BufferAccessor
    • getUnsignedByte

      public int getUnsignedByte(int roff)
      Specified by:
      getUnsignedByte in interface io.netty5.buffer.BufferAccessor
    • writeByte

      @NonNull public @NonNull MemorySegmentBuffer writeByte(byte value)
      Specified by:
      writeByte in interface io.netty5.buffer.BufferAccessor
    • setByte

      @NonNull public @NonNull MemorySegmentBuffer setByte(int woff, byte value)
      Specified by:
      setByte in interface io.netty5.buffer.BufferAccessor
    • writeUnsignedByte

      @NonNull public @NonNull MemorySegmentBuffer writeUnsignedByte(int value)
      Specified by:
      writeUnsignedByte in interface io.netty5.buffer.BufferAccessor
    • setUnsignedByte

      @NonNull public @NonNull MemorySegmentBuffer setUnsignedByte(int woff, int value)
      Specified by:
      setUnsignedByte in interface io.netty5.buffer.BufferAccessor
    • readChar

      public char readChar()
      Specified by:
      readChar in interface io.netty5.buffer.BufferAccessor
    • getChar

      public char getChar(int roff)
      Specified by:
      getChar in interface io.netty5.buffer.BufferAccessor
    • writeChar

      @NonNull public @NonNull MemorySegmentBuffer writeChar(char value)
      Specified by:
      writeChar in interface io.netty5.buffer.BufferAccessor
    • setChar

      @NonNull public @NonNull MemorySegmentBuffer setChar(int woff, char value)
      Specified by:
      setChar in interface io.netty5.buffer.BufferAccessor
    • readShort

      public short readShort()
      Specified by:
      readShort in interface io.netty5.buffer.BufferAccessor
    • getShort

      public short getShort(int roff)
      Specified by:
      getShort in interface io.netty5.buffer.BufferAccessor
    • readUnsignedShort

      public int readUnsignedShort()
      Specified by:
      readUnsignedShort in interface io.netty5.buffer.BufferAccessor
    • getUnsignedShort

      public int getUnsignedShort(int roff)
      Specified by:
      getUnsignedShort in interface io.netty5.buffer.BufferAccessor
    • writeShort

      @NonNull public @NonNull MemorySegmentBuffer writeShort(short value)
      Specified by:
      writeShort in interface io.netty5.buffer.BufferAccessor
    • setShort

      @NonNull public @NonNull MemorySegmentBuffer setShort(int woff, short value)
      Specified by:
      setShort in interface io.netty5.buffer.BufferAccessor
    • writeUnsignedShort

      @NonNull public @NonNull MemorySegmentBuffer writeUnsignedShort(int value)
      Specified by:
      writeUnsignedShort in interface io.netty5.buffer.BufferAccessor
    • setUnsignedShort

      @NonNull public @NonNull MemorySegmentBuffer setUnsignedShort(int woff, int value)
      Specified by:
      setUnsignedShort in interface io.netty5.buffer.BufferAccessor
    • readMedium

      public int readMedium()
      Specified by:
      readMedium in interface io.netty5.buffer.BufferAccessor
    • getMedium

      public int getMedium(int roff)
      Specified by:
      getMedium in interface io.netty5.buffer.BufferAccessor
    • readUnsignedMedium

      public int readUnsignedMedium()
      Specified by:
      readUnsignedMedium in interface io.netty5.buffer.BufferAccessor
    • getUnsignedMedium

      public int getUnsignedMedium(int roff)
      Specified by:
      getUnsignedMedium in interface io.netty5.buffer.BufferAccessor
    • writeMedium

      @NonNull public @NonNull MemorySegmentBuffer writeMedium(int value)
      Specified by:
      writeMedium in interface io.netty5.buffer.BufferAccessor
    • setMedium

      @NonNull public @NonNull MemorySegmentBuffer setMedium(int woff, int value)
      Specified by:
      setMedium in interface io.netty5.buffer.BufferAccessor
    • writeUnsignedMedium

      @NonNull public @NonNull MemorySegmentBuffer writeUnsignedMedium(int value)
      Specified by:
      writeUnsignedMedium in interface io.netty5.buffer.BufferAccessor
    • setUnsignedMedium

      @NonNull public @NonNull MemorySegmentBuffer setUnsignedMedium(int woff, int value)
      Specified by:
      setUnsignedMedium in interface io.netty5.buffer.BufferAccessor
    • readInt

      public int readInt()
      Specified by:
      readInt in interface io.netty5.buffer.BufferAccessor
    • getInt

      public int getInt(int roff)
      Specified by:
      getInt in interface io.netty5.buffer.BufferAccessor
    • readUnsignedInt

      public long readUnsignedInt()
      Specified by:
      readUnsignedInt in interface io.netty5.buffer.BufferAccessor
    • getUnsignedInt

      public long getUnsignedInt(int roff)
      Specified by:
      getUnsignedInt in interface io.netty5.buffer.BufferAccessor
    • writeInt

      @NonNull public @NonNull MemorySegmentBuffer writeInt(int value)
      Specified by:
      writeInt in interface io.netty5.buffer.BufferAccessor
    • setInt

      @NonNull public @NonNull MemorySegmentBuffer setInt(int woff, int value)
      Specified by:
      setInt in interface io.netty5.buffer.BufferAccessor
    • writeUnsignedInt

      @NonNull public @NonNull MemorySegmentBuffer writeUnsignedInt(long value)
      Specified by:
      writeUnsignedInt in interface io.netty5.buffer.BufferAccessor
    • setUnsignedInt

      @NonNull public @NonNull MemorySegmentBuffer setUnsignedInt(int woff, long value)
      Specified by:
      setUnsignedInt in interface io.netty5.buffer.BufferAccessor
    • readFloat

      public float readFloat()
      Specified by:
      readFloat in interface io.netty5.buffer.BufferAccessor
    • getFloat

      public float getFloat(int roff)
      Specified by:
      getFloat in interface io.netty5.buffer.BufferAccessor
    • writeFloat

      @NonNull public @NonNull MemorySegmentBuffer writeFloat(float value)
      Specified by:
      writeFloat in interface io.netty5.buffer.BufferAccessor
    • setFloat

      @NonNull public @NonNull MemorySegmentBuffer setFloat(int woff, float value)
      Specified by:
      setFloat in interface io.netty5.buffer.BufferAccessor
    • readLong

      public long readLong()
      Specified by:
      readLong in interface io.netty5.buffer.BufferAccessor
    • getLong

      public long getLong(int roff)
      Specified by:
      getLong in interface io.netty5.buffer.BufferAccessor
    • writeLong

      @NonNull public @NonNull MemorySegmentBuffer writeLong(long value)
      Specified by:
      writeLong in interface io.netty5.buffer.BufferAccessor
    • setLong

      @NonNull public @NonNull MemorySegmentBuffer setLong(int woff, long value)
      Specified by:
      setLong in interface io.netty5.buffer.BufferAccessor
    • readDouble

      public double readDouble()
      Specified by:
      readDouble in interface io.netty5.buffer.BufferAccessor
    • getDouble

      public double getDouble(int roff)
      Specified by:
      getDouble in interface io.netty5.buffer.BufferAccessor
    • writeDouble

      @NonNull public @NonNull MemorySegmentBuffer writeDouble(double value)
      Specified by:
      writeDouble in interface io.netty5.buffer.BufferAccessor
    • setDouble

      @NonNull public @NonNull MemorySegmentBuffer setDouble(int woff, double value)
      Specified by:
      setDouble in interface io.netty5.buffer.BufferAccessor
    • hasReadableArray

      public boolean hasReadableArray()
      Specified by:
      hasReadableArray in interface io.netty5.buffer.BufferComponent
    • hasWritableArray

      public boolean hasWritableArray()
      Specified by:
      hasWritableArray in interface io.netty5.buffer.BufferComponent
    • readableArray

      public byte[] readableArray()
      Specified by:
      readableArray in interface io.netty5.buffer.BufferComponent
    • writableArray

      public byte[] writableArray()
      Specified by:
      writableArray in interface io.netty5.buffer.BufferComponent
    • readableArrayOffset

      public int readableArrayOffset()
      Specified by:
      readableArrayOffset in interface io.netty5.buffer.BufferComponent
    • writableArrayOffset

      public int writableArrayOffset()
      Specified by:
      writableArrayOffset in interface io.netty5.buffer.BufferComponent
    • readableArrayLength

      public int readableArrayLength()
      Specified by:
      readableArrayLength in interface io.netty5.buffer.BufferComponent
    • writableArrayLength

      public int writableArrayLength()
      Specified by:
      writableArrayLength in interface io.netty5.buffer.BufferComponent
    • baseNativeAddress

      public long baseNativeAddress()
      Specified by:
      baseNativeAddress in interface io.netty5.buffer.BufferComponent
    • readableNativeAddress

      public long readableNativeAddress()
      Specified by:
      readableNativeAddress in interface io.netty5.buffer.BufferComponent
    • writableNativeAddress

      public long writableNativeAddress()
      Specified by:
      writableNativeAddress in interface io.netty5.buffer.BufferComponent
    • readableBuffer

      @NonNull public @NonNull ByteBuffer readableBuffer()
      Specified by:
      readableBuffer in interface io.netty5.buffer.BufferComponent
    • writableBuffer

      @NonNull public @NonNull ByteBuffer writableBuffer()
      Specified by:
      writableBuffer in interface io.netty5.buffer.BufferComponent
    • first

      Specified by:
      first in interface io.netty5.buffer.ComponentIterator<MemorySegmentBuffer>
    • next

      @Nullable public <N extends io.netty5.buffer.ComponentIterator.Next & io.netty5.buffer.BufferComponent> N next()
      Specified by:
      next in interface io.netty5.buffer.ComponentIterator.Next
    • createResourceClosedException

      @NonNull protected @NonNull RuntimeException createResourceClosedException()
      Specified by:
      createResourceClosedException in class io.netty5.buffer.internal.ResourceSupport<io.netty5.buffer.Buffer, MemorySegmentBuffer>
    • prepareSend

      @NonNull protected @NonNull io.netty5.buffer.Owned<MemorySegmentBuffer> prepareSend()
      Specified by:
      prepareSend in class io.netty5.buffer.internal.ResourceSupport<io.netty5.buffer.Buffer, MemorySegmentBuffer>
    • makeInaccessible

      protected void makeInaccessible()
      Overrides:
      makeInaccessible in class io.netty5.buffer.internal.ResourceSupport<io.netty5.buffer.Buffer, MemorySegmentBuffer>
    • toString

      @NonNull public @NonNull String toString()
      Overrides:
      toString in class Object
    • unsafeGetBase

      Unsafe method to access the base segment used by this buffer. Should only be used by internal methods.
      Returns:
      the base memory segment used by this buffer.
    • newConstChild

      Allocates a constant child which is similar to a read-only buffer but shares the memory region with this buffer.
      Returns:
      a constant child of this buffer.
      Throws:
      IllegalStateException - if this buffer has already been freed.
    • ensureAccessible

      private void ensureAccessible()
      Ensures that this buffer is still accessible (not closed).
      Throws:
      io.netty5.buffer.BufferClosedException - if this buffer is closed.
    • ensureOwned

      private void ensureOwned()
      Ensures that this buffer is owned and can be used freely.
      Throws:
      IllegalStateException - if the buffer is not owned.
    • ensureWriteable

      private void ensureWriteable()
      Ensures that this buffer is writeable (not read-only).
      Throws:
      io.netty5.buffer.BufferReadOnlyException - if this buffer is read-only.
    • ensureInSegmentBounds

      private void ensureInSegmentBounds(int index, int size)
      Ensures that the visit of the given size bytes starting at the given index happens within the bounds of the wrapped memory segment.
      Parameters:
      index - the index where the visit operation will start.
      size - the count of bytes that will be visited by the operation.
      Throws:
      io.netty5.buffer.BufferClosedException - if this buffer is closed.
      IndexOutOfBoundsException - if the given visit operation is beyond the size of the wrapped buffer.
    • ensureReadable

      private void ensureReadable(int index, int size)
      Ensures that at least size bytes were written into this buffer starting at the given index.
      Parameters:
      index - the index to check from.
      size - the count of bytes to check for.
      Throws:
      io.netty5.buffer.BufferClosedException - if this buffer is closed.
      IndexOutOfBoundsException - if not enough bytes were written into the buffer to satisfy the read operation.
    • ensureWriteable

      private void ensureWriteable(int index, int size, boolean canExpand)
      Ensures that at least size bytes can be written into this buffer starting at the given index. An attempt can be made to expand the buffer according to the needs if canExpand is true.
      Parameters:
      index - the index to check from.
      size - the count of bytes that must be available.
      canExpand - if the buffer can be expanded to fit the requested byte count.
      Throws:
      io.netty5.buffer.BufferClosedException - if this buffer is closed.
      io.netty5.buffer.BufferReadOnlyException - if this buffer is read-only.
      IndexOutOfBoundsException - if not enough bytes are available in this buffer for the write operation.