package rlp

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Rlp: Recursive Length Prefix format.

RLP Trees

type t =
  1. | RlpData of Rope.t
  2. | RlpList of t list

t is the type for RLP tree structures.

val rlpInt : int -> t

rlpInt i encodes i into an RlpData element with big-endian with no zeros in front. Zero is encoded as the empty byte sequence. Raises Invalid_argument when i is negative.

val rlpBigInt : Big_int.big_int -> t

rlpBigInt is similar to rlpInt.

val displayRope : t -> Rope.t

displayRope t converts the RLP tree t into a JSON-like string (represented as a Rope.t).

val display : t -> string

displayRope t converts the RLP tree t into a JSON-like string (represented as a Rope.t).

Encoding and Decoding

val encode : t -> Rope.t

encode t encodes the RLP tree structure into a byte string represented as a Rope.t

exception InvalidRlp
val decode : Rope.t -> t

decode r reads the given byte string into the RLP tree structure. Raises InvalidRlp when r is not a "canonical" encoding. decode (encode t) should be equal to t up to the Rope content equality.