JsonSlice

dev.constructive.eo.jsoniter.JsonSlice
See theJsonSlice companion class
object JsonSlice

Attributes

Companion
class
Source
JsonSlice.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
JsonSlice.type

Members list

Grouped members

Constructors

def apply(bytes: Array[Byte], offset: Int, length: Int): JsonSlice

The length bytes of bytes from offset on. Nothing is copied.

The length bytes of bytes from offset on. Nothing is copied.

Fails fast with an IndexOutOfBoundsException when the range doesn't lie inside bytes (offset or length negative, or offset + length > bytes.length) — the contract of java.util.Arrays.copyOfRange, ByteBuffer.wrap and jsoniter-scala's own readFromSubArray. Offsets are the caller's arithmetic over an array it holds, not data read off the wire, so a wrong one is a bug at the call site; checking here means no optic ever runs on one.

Attributes

Source
JsonSlice.scala
def apply(bytes: Array[Byte]): JsonSlice

The whole of bytes, as a slice. Nothing is copied.

The whole of bytes, as a slice. Nothing is copied.

Attributes

Source
JsonSlice.scala
def apply(buf: ByteBuffer): JsonSlice

The bytes between buf's position and its limit, as a slice. The buffer's position, limit and mark are left as they were.

The bytes between buf's position and its limit, as a slice. The buffer's position, limit and mark are left as they were.

  • A buffer with an accessible array (buf.hasArray: a heap buffer that isn't read-only) is '''not copied''': the slice is a view of buf.array from buf.arrayOffset + buf.position, buf.remaining bytes long, with the view's rules — don't change the bytes while it's in use, and it keeps the whole array reachable.
  • A '''direct''' or '''read-only''' buffer exposes no array, so its remaining bytes are '''copied once''', into an array of the slice's own.

Attributes

Source
JsonSlice.scala