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
val of_input : input -> t

create input makes a decoder for the given input.

  • since 0.2
val of_string : ?off:int -> ?len:int -> string -> t

Decoder reading from the string.

  • parameter off

    initial offset in the string

  • parameter len

    length of the slice of the string

  • raises Invalid_arg

    if off,off+len is not a valid slice in the string.

  • since 0.2
val of_bytes : ?off:int -> ?len:int -> bytes -> t

See of_string

  • since 0.2
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.