colossus.core

DataBuffer

final case class DataBuffer(data: ByteBuffer) extends AnyVal with Product with Serializable

A thin wrapper around a NIO ByteBuffer with data to read

DataBuffers are the primary way that data is read from and written to a connection. DataBuffers are mutable and not thread safe. They can only be read from once and cannot be reset.

Linear Supertypes
Serializable, Serializable, Product, Equals, AnyVal, NotNull, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. DataBuffer
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyVal
  7. NotNull
  8. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new DataBuffer(data: ByteBuffer)

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  2. final def ##(): Int

    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  4. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. val data: ByteBuffer

  6. def getClass(): Class[_ <: AnyVal]

    Definition Classes
    AnyVal → Any
  7. def hasNext: Boolean

    Returns true if this DataBuffer still has unread data, false otherwise

  8. def hasUnreadData: Boolean

    Returns true if this DataBuffer still has unread data, false otherwise

  9. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  10. def next(): Byte

    Get the next byte, removing it from the buffer

    Get the next byte, removing it from the buffer

    WARNING : This method will throw an exception if no data is left. It is up to you to use hasUnreadData to figure out if you should call this. This is done to avoid unnecessary object allocation with using Option

    returns

    the next byte in the buffer

  11. def remaining: Int

  12. def size: Int

    Returns the total size of this DataBuffer

  13. def take(n: Int): Array[Byte]

    Get some bytes

    Get some bytes

    n

    how many bytes you want.

    returns

    an filled array of size min(n, remaining)

  14. def takeAll: Array[Byte]

    Returns an array containing all of the unread data in this Databuffer

  15. def takeCopy: DataBuffer

    Copy the unread data in this buffer to a new buffer

    Copy the unread data in this buffer to a new buffer

    Data will not be shared between the buffers. The position of this buffer will be completed

    returns

    a new DataBuffer containing only the unread data in this buffer

  16. def takeInto(buffer: Array[Byte], offset: Int, length: Int): Unit

    Directly copy data into a target byte array

    Directly copy data into a target byte array

    buffer

    the array to copy into

    offset

    the first index of buffer to start writing to

    length

    how many bytes to write

    Exceptions thrown
    ArrayOutOfBoundsException

    if target array is too small or buffer doesn't have sufficient bytes available

  17. def taken: Int

    Returns how many bytes have already been read from this DataBuffer

  18. def writeTo(channel: SocketChannel): Int

    Write the buffer into a SocketChannel

    Write the buffer into a SocketChannel

    The buffer's taken and remaining values will be updated to reflect how much data was written. Be aware that buffer's containing large amounts of data will probably not be written in one call

    channel

    the channel to write to

    returns

    how many bytes were written

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyVal

Inherited from NotNull

Inherited from Any

Ungrouped