HashConsedFlat

scalus.serialization.flat.HashConsedFlat
See theHashConsedFlat companion object
trait HashConsedFlat[A] extends Flat[A]

Attributes

Companion
object
Graph
Supertypes
trait Flat[A]
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def bitSizeHC(a: A, encoderState: State): Int
def decodeHC(decoderState: HashConsedDecoderState): A
def encodeHC(a: A, encoderState: HashConsedEncoderState): Unit

Concrete methods

final override def bitSize(a: A): Int

Exact size of the encoding of a in bits. Callers use it to size the EncoderState buffer, so it must never under-estimate.

Exact size of the encoding of a in bits. Callers use it to size the EncoderState buffer, so it must never under-estimate.

Attributes

Definition Classes
def decode(decode: DecoderState): A

Reads an A, advancing decode past the bits it consumed.

Reads an A, advancing decode past the bits it consumed.

Decoding stops as soon as it has an A; it does not check for trailing input, so a caller that requires the whole buffer to be consumed must check that itself.

Attributes

Throws
FlatDecodingError

if the input is truncated or is not a valid encoding of A. Bytes from an untrusted source are expected to fail this way; any other exception is a defect.

final override def encode(a: A, encoderState: EncoderState): Unit

Writes a into encode.

Writes a into encode.

The buffer does not grow, so it must already have room for bitSize bits. Failing that is a defect in this instance rather than a problem with a: an under-estimating bitSize overruns the buffer with an ArrayIndexOutOfBoundsException, and a negative size is rejected by EncoderState with an IllegalArgumentException. Use [[FlatCodec.encodeA*]] to get the sizing right.

Attributes

Definition Classes