rlp / org.apache.tuweni.rlp / RLP

RLP

class RLP (source)

Recursive Length Prefix (RLP) encoding and decoding.

Functions

decode

static fun <T : Any> decode(source: Bytes, fn: Function<RLPReader, T>): T
static fun <T : Any> decode(source: Bytes, lenient: Boolean, fn: Function<RLPReader, T>): T

Read and decode RLP from a Bytes value.

Important: this method does not consume any list prefix from the source data. If you are reading a RLP encoded list of values, you usually want to use #decodeList(Bytes, Function).

decodeBigInteger

static fun decodeBigInteger(source: Bytes): BigInteger
static fun decodeBigInteger(source: Bytes, lenient: Boolean): BigInteger

Read an RLP encoded big integer from a Bytes value.

decodeInt

static fun decodeInt(source: Bytes): Int
static fun decodeInt(source: Bytes, lenient: Boolean): Int

Read an RLP encoded integer from a Bytes value.

decodeList

static fun <T : Any> decodeList(source: Bytes, fn: Function<RLPReader, T>): T
static fun <T : Any> decodeList(source: Bytes, lenient: Boolean, fn: Function<RLPReader, T>): T

Read an RLP encoded list of values from a Bytes value.

decodeLong

static fun decodeLong(source: Bytes): Long
static fun decodeLong(source: Bytes, lenient: Boolean): Long

Read an RLP encoded long from a Bytes value.

decodeString

static fun decodeString(source: Bytes): String
static fun decodeString(source: Bytes, lenient: Boolean): String

Read an RLP encoded string from a Bytes value.

decodeToList

static fun decodeToList(source: Bytes, fn: BiConsumer<RLPReader, MutableList<Any>>): MutableList<Any>
static fun decodeToList(source: Bytes, lenient: Boolean, fn: BiConsumer<RLPReader, MutableList<Any>>): MutableList<Any>
static fun <T : Any> decodeToList(source: Bytes, lenient: Boolean, fn: Function<RLPReader, T>): MutableList<T>

Read an RLP encoded list of values from a Bytes value, populating a mutable output list.

static fun <T : Any> decodeToList(source: Bytes, fn: Function<RLPReader, T>): MutableList<T>

Read a list of values from the RLP source, populating a list using a function interpreting each value.

decodeValue

static fun decodeValue(source: Bytes): Bytes
static fun decodeValue(source: Bytes, lenient: Boolean): Bytes

Read an RLP encoded value from a Bytes value.

encode

static fun encode(fn: Consumer<RLPWriter>): Bytes

Encode values to a Bytes value.

Important: this method does not write any list prefix to the result. If you are writing a RLP encoded list of values, you usually want to use #encodeList(Consumer).

encodeBigInteger

static fun encodeBigInteger(value: BigInteger): Bytes

Encode a big integer to a Bytes value.

encodeByteArray

static fun encodeByteArray(value: ByteArray): Bytes

Encode a value to a Bytes value.

encodeInt

static fun encodeInt(value: Int): Bytes

Encode a integer to a Bytes value.

encodeList

static fun encodeList(fn: Consumer<RLPWriter>): Bytes
static fun <T : Any> encodeList(elements: MutableList<T>, fn: BiConsumer<RLPWriter, T>): Bytes

Encode a list of values to a Bytes value.

encodeListTo

static fun <T : ByteBuffer> encodeListTo(buffer: T, fn: Consumer<RLPWriter>): T

Encode a list of values to a ByteBuffer.

encodeLong

static fun encodeLong(value: Long): Bytes

Encode a long to a Bytes value.

encodeString

static fun encodeString(str: String): Bytes

Encode a string to a Bytes value.

encodeTo

static fun <T : ByteBuffer> encodeTo(buffer: T, fn: Consumer<RLPWriter>): T

Encode values to a ByteBuffer.

Important: this method does not write any list prefix to the result. If you are writing a RLP encoded list of values, you usually want to use #encodeList(Consumer).

encodeValue

static fun encodeValue(value: Bytes): Bytes

Encode a value to a Bytes value.

isList

static fun isList(value: Bytes): Boolean

Check if the Bytes value contains an RLP encoded list.