package bare_encoding

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

Module Bare_encoding.EncodeSource

Encoder type and some encoding utils.

The type Encode.t is passed to type-specific encoders so they can serialize values into bytes. This module also provides a host of functions that encode specific types (mostly integers and strings) into the Encode.t.

Sourcetype t

Encoding state.

Sourceval of_buffer : Buffer.t -> t

Encoding state that emits bytes into the given buffer. After using a type encoder on this encoder, the buffer will contain the bytes.

Sourcetype 'a enc = t -> 'a -> unit

A type encoder for values of type 'a.

Sourceval uint : t -> int64 -> unit

Encode unsigned integers using the varint encoding

Sourceval int : t -> int64 -> unit

Encode signed integers using the varint encoding

Sourceval u8 : t -> char -> unit

Encode a single byte

Sourceval u16 : t -> int -> unit

Encode a two byte unsigned integers in little endian

Sourceval u32 : t -> int32 -> unit

Encode an unsigned int32 integer in little endian

Sourceval u64 : t -> int64 -> unit

Encode an unsigned int64 integer in little endian

Sourceval i8 : t -> char -> unit

Same as u8

Sourceval i16 : t -> int -> unit

Encode a two byte unsigned integers in little endian

Sourceval i32 : t -> int32 -> unit

Encode a int32 integer in little endian

Sourceval i64 : t -> int64 -> unit

Encode a int64 integer in little endian

Sourceval bool : t -> bool -> unit

Encode a boolean as a single byte 0 or 1.

Sourceval f64 : t -> float -> unit

Encode a float.

Sourceval string : t -> string -> unit

Encode a string, prefixed by its length

Sourceval data : t -> bytes -> unit

Encode a blob, prefixed by its length

Sourceval data_of : size:int -> t -> bytes -> unit

Encode a blob of fixed size.

  • raises Failure

    if the blob's length in bytes is not equal to size

Sourceval optional : 'a enc -> 'a option enc

Encode an optional value, as either 0 for None or 1 followed by the encoding of x for Some x.

OCaml

Innovation. Community. Security.