Interface BinaryWriter

All Known Implementing Classes:
SegmentBinaryWriter

public interface BinaryWriter
An interface for writing binary data sequentially to an underlying sink. This provides a high-level, fluent abstraction for zero-copy encoding operations.
  • Method Details

    • position

      long position()
      Gets the current write offset in bytes.
    • position

      void position(long newPosition)
      Sets the current write offset in bytes.
    • remaining

      long remaining()
      Gets the number of remaining writable bytes.
    • writeByte

      BinaryWriter writeByte(byte value)
    • writeShortBE

      BinaryWriter writeShortBE(short value)
    • writeIntBE

      BinaryWriter writeIntBE(int value)
    • writeLongBE

      BinaryWriter writeLongBE(long value)
    • writeFloatBE

      BinaryWriter writeFloatBE(float value)
    • writeDoubleBE

      BinaryWriter writeDoubleBE(double value)
    • writeBoolean

      BinaryWriter writeBoolean(boolean value)
    • writeShortLE

      BinaryWriter writeShortLE(short value)
    • writeIntLE

      BinaryWriter writeIntLE(int value)
    • writeLongLE

      BinaryWriter writeLongLE(long value)
    • writeFloatLE

      BinaryWriter writeFloatLE(float value)
    • writeDoubleLE

      BinaryWriter writeDoubleLE(double value)
    • writeVarInt

      BinaryWriter writeVarInt(int value)
      Writes a 32-bit integer in a variable-length format.
    • writeVarLong

      BinaryWriter writeVarLong(long value)
      Writes a 64-bit integer in a variable-length format.
    • writeString

      BinaryWriter writeString(String value, MemorySegment scratchBuffer)
    • writeBytes

      BinaryWriter writeBytes(byte[] value)
    • writeNullableByte

      BinaryWriter writeNullableByte(Byte value)
    • writeNullableShortBE

      BinaryWriter writeNullableShortBE(Short value)
    • writeNullableIntBE

      BinaryWriter writeNullableIntBE(Integer value)
    • writeNullableIntLE

      BinaryWriter writeNullableIntLE(Integer value)
    • writeNullableFloatBE

      BinaryWriter writeNullableFloatBE(Float value)
    • writeNullableFloatLE

      BinaryWriter writeNullableFloatLE(Float value)
    • writeNullableDoubleBE

      BinaryWriter writeNullableDoubleBE(Double value)
    • writeNullableDoubleLE

      BinaryWriter writeNullableDoubleLE(Double value)
    • writeNullableBoolean

      BinaryWriter writeNullableBoolean(Boolean value)
    • writeNullableLongLE

      BinaryWriter writeNullableLongLE(Long value)
    • writeNullableLongBE

      BinaryWriter writeNullableLongBE(Long value)
    • writeNullableString

      BinaryWriter writeNullableString(String value, MemorySegment scratchBuffer)
    • writeNullableBytes

      BinaryWriter writeNullableBytes(byte[] value)
    • writeSegment

      BinaryWriter writeSegment(MemorySegment source)
      Writes all bytes from the source MemorySegment to this writer's underlying sink.
      Parameters:
      source - The MemorySegment to read from.
      Returns:
      This writer instance for chaining.
    • writeSegmentRaw

      BinaryWriter writeSegmentRaw(MemorySegment source, long offset, long length)
      Writes raw bytes from the source MemorySegment without a length prefix. This is useful when the length is already known or stored elsewhere.
      Parameters:
      source - The MemorySegment to copy from.
      offset - Starting offset in the source segment.
      length - Number of bytes to copy.
      Returns:
      This writer instance for chaining.
    • skip

      BinaryWriter skip(long bytesToSkip)
      Advances the writer's position by the given number of bytes.
      Parameters:
      bytesToSkip - The number of bytes to skip.
      Returns:
      This writer instance, for chaining.