package bare_encoding

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

Decoders.

This module provides a decoder type Decode.t to hold the decoding state, along with functions to decode specific primitives.

type t = {
  1. bs : bytes;
  2. mutable off : int;
}

A decoder state, operating on a slice of bytes.

exception Error of string
type 'a dec = t -> 'a

A decoder for values of type 'a. Decoders will raise Error to indicate failure.

val uint : t -> int64

Decode a varint-encoded unsigned integer

val int : t -> int64

Decode a varint-encoded integer

val u8 : t -> char
val u16 : t -> int
val u32 : t -> int32
val u64 : t -> int64
val i8 : t -> char
val i16 : t -> int
val i32 : t -> int32
val i64 : t -> int64
val bool : t -> bool
val f32 : t -> float
val f64 : t -> float
val string : t -> string
val data : t -> bytes
val data_of : size:int -> t -> bytes
val optional : 'a dec -> 'a option dec
OCaml

Innovation. Community. Security.