trait ByteReader extends AutoCloseable
A ByteReader provides a stateful API to extract bytes from an underlying buffer, which in most cases is a Buf. This conveniently allows codec implementations to decode frames, specifically when they need to decode and interpret the bytes as a numeric value.
- Note
Unless otherwise stated, ByteReader implementations are not thread safe.
- Alphabetic
- By Inheritance
- ByteReader
- AutoCloseable
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def close(): Unit
- Definition Classes
- AutoCloseable
- Annotations
- @throws(classOf[java.lang.Exception])
- abstract def process(from: Int, until: Int, processor: Processor): Int
Process the underlying buffer 1-byte at a time using the given Buf.Processor, starting at index
from
of the underlying buffer until indexuntil
of the underlying buffer.Process the underlying buffer 1-byte at a time using the given Buf.Processor, starting at index
from
of the underlying buffer until indexuntil
of the underlying buffer. Processing will halt if the processor returnsfalse
or after processing the final byte.- from
the starting index, inclusive. Must be non-negative.
- until
the ending index, exclusive. Must be non-negative.
- returns
-1 if the processor processed all bytes or the last processed index if the processor returns
false
. Will return -1 iffrom
is greater than or equal tountil
orlength
of the underlying buffer. Will return -1 ifuntil
is greater than or equal tolength
of the underlying buffer.
- Note
this does not advance the byte cursor.
- abstract def process(processor: Processor): Int
Process the underlying buffer 1-byte at a time using the given Buf.Processor, starting at index
0
of the underlying buffer until indexlength
of the underlying buffer.Process the underlying buffer 1-byte at a time using the given Buf.Processor, starting at index
0
of the underlying buffer until indexlength
of the underlying buffer. Processing will halt if the processor returnsfalse
or after processing the final byte.- returns
-1 if the processor processed all bytes or the last processed index if the processor returns
false
.
- Note
this does not advance the byte cursor.
- abstract def readAll(): Buf
Like
read
, but extracts the remainder of bytes from cursor to the length.Like
read
, but extracts the remainder of bytes from cursor to the length. Note, this advances the cursor to the end of the buf. - abstract def readByte(): Byte
Extract 8 bits and interpret as a signed integer, advancing the byte cursor by 1.
- abstract def readBytes(n: Int): Buf
Returns a new buffer representing a slice of this buffer, delimited by the indices
[cursor, remaining)
.Returns a new buffer representing a slice of this buffer, delimited by the indices
[cursor, remaining)
. Out of bounds indices are truncated. Negative indices are not accepted. - abstract def readDoubleBE(): Double
Extract 64 bits and interpret as a big endian floating point, advancing the byte cursor by 4.
- abstract def readDoubleLE(): Double
Extract 64 bits and interpret as a little endian floating point, advancing the byte cursor by 4.
- abstract def readFloatBE(): Float
Extract 32 bits and interpret as a big endian floating point, advancing the byte cursor by 4.
- abstract def readFloatLE(): Float
Extract 32 bits and interpret as a little endian floating point, advancing the byte cursor by 4.
- abstract def readIntBE(): Int
Extract 32 bits and interpret as a big endian integer, advancing the byte cursor by 4.
- abstract def readIntLE(): Int
Extract 32 bits and interpret as a little endian int, advancing the byte cursor by 4.
- abstract def readLongBE(): Long
Extract 64 bits and interpret as a big endian integer, advancing the byte cursor by 8.
- abstract def readLongLE(): Long
Extract 64 bits and interpret as a little endian integer, advancing the byte cursor by 8.
- abstract def readMediumBE(): Int
Extract 24 bits and interpret as a big endian integer, advancing the byte cursor by 3.
- abstract def readMediumLE(): Int
Extract 24 bits and interpret as a little endian integer, advancing the byte cursor by 3.
- abstract def readShortBE(): Short
Extract 16 bits and interpret as a big endian integer, advancing the byte cursor by 2.
- abstract def readShortLE(): Short
Extract 16 bits and interpret as a little endian integer, advancing the byte cursor by 2.
- abstract def readString(bytes: Int, charset: Charset): String
Extract exactly the specified number of bytes into a
String
using the specifiedCharset
, advancing the byte cursor bybytes
.Extract exactly the specified number of bytes into a
String
using the specifiedCharset
, advancing the byte cursor bybytes
.- Exceptions thrown
ByteReader.UnderflowException
if there are <bytes
bytes available
- abstract def readUnsignedByte(): Short
Extract 8 bits and interpret as an unsigned integer, advancing the byte cursor by 1.
- abstract def readUnsignedIntBE(): Long
Extract 32 bits and interpret as a big endian unsigned integer, advancing the byte cursor by 4.
- abstract def readUnsignedIntLE(): Long
Extract 32 bits and interpret as a little endian unsigned integer, advancing the byte cursor by 4.
- abstract def readUnsignedLongBE(): BigInt
Extract 64 bits and interpret as a big endian unsigned integer, advancing the byte cursor by 8.
- abstract def readUnsignedLongLE(): BigInt
Extract 64 bits and interpret as a little endian unsigned integer, advancing the byte cursor by 8.
- abstract def readUnsignedMediumBE(): Int
Extract 24 bits and interpret as a big endian unsigned integer, advancing the byte cursor by 3.
- abstract def readUnsignedMediumLE(): Int
Extract 24 bits and interpret as a little endian unsigned integer, advancing the byte cursor by 3.
- abstract def readUnsignedShortBE(): Int
Extract 16 bits and interpret as a big endian unsigned integer, advancing the byte cursor by 2.
- abstract def readUnsignedShortLE(): Int
Extract 16 bits and interpret as a little endian unsigned integer, advancing the byte cursor by 2.
- abstract def remaining: Int
The remainder of bytes that the reader is capable of reading.
- abstract def remainingUntil(byte: Byte): Int
The remainder of bytes until the first occurrence of
byte
(exclusive).The remainder of bytes until the first occurrence of
byte
(exclusive). Returns-1
whenbyte
is not found on the underlying resource.- Note
All util and finagle Buf implementations will not copy onto the heap, but for other implementations, it may trigger a copy.
- abstract def skip(n: Int): Unit
Skip over the next
n
bytes.Skip over the next
n
bytes.- Exceptions thrown
ByteReader.UnderflowException
if there are <n
bytes available
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()