Module Evm_node_lib_dev_encoding.Rlp

A simple RLP encoding library, see https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/ for the specification.

type Mavryk_base.TzPervasives.error +=
  1. | Rlp_decoding_error of string
type item =
  1. | Value of bytes
  2. | List of item list

An RLP value is either a bytes value, or a list of RLP values.

val encode_int : int -> bytes

encode_int i encodes an integer in big endian in its smallest representation.

val encode_z : Z.t -> bytes

encode_z z encodes a big integer in big endian in its smallest representation.

val encode : item -> bytes

encode item takes an RLP item and returns its encoded form.

val decode_int : bytes -> int Mavryk_base.TzPervasives.tzresult

decode_int bytes decodes an integer encoded in big endian from the given bytes. Returns an Rlp_decoding_error if the bytes is not a valid RLP encoded integer.

val decode_z : bytes -> Z.t Mavryk_base.TzPervasives.tzresult

decode_z bytes decodes a big integer encoded in big endian from the given bytes. Returns an Rlp_decoding_error if the bytes is not a valid RLP encoded big integer.

decode bytes decodes an RLP value from the given bytes. Returns an Rlp_decoding_error if the bytes is not an RLP encoded value.

val decode_exn : bytes -> item

decode_exn bytes calls decode and raises Invalid_argument if it fails to decode.

decode_option decode_value optional_value decodes the option following Rust's RLP encoding.

decode_result decode_ok decode_error value decodes an encoded result type.

val pp : Stdlib.Format.formatter -> item -> unit

pp ppf item pretty-prints an item.