package ppx_deriving_protobuf

  1. Overview
  2. Docs
A Protocol Buffers codec generator for OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

ppx_deriving_protobuf-v3.0.0.tbz
sha256=5287ef0db8d4f7a62b0bb7a21010172d602aa45a7fecc2d4cb9681366ddf81b5
sha512=6bc04d10c2448a35c9c2404be01aab616d51cdda563f6f3b8d213db18614233746c6bf2190a3f12881f544e91c18aa01d56f9aeeb7b01eddfe68123b88703625

doc/ppx_deriving_protobuf.runtime/Protobuf/Encoder/index.html

Module Protobuf.EncoderSource

Sourcetype error =
  1. | Overflow of string

Type of failures possible while encoding.

Sourceval error_to_string : error -> string

error_to_string e converts error e to its string representation.

Sourceexception Failure of error
Sourcetype t

Type of wire format encoders.

Sourceval create : unit -> t

create () creates a new encoder.

Sourceval to_string : t -> string

to_string e converts the message assembled in e to a string.

Sourceval to_bytes : t -> bytes

to_bytes e converts the message assembled in e to bytes.

Sourceval varint : int64 -> t -> unit

varint i e writes a varint i to e.

Sourceval zigzag : int64 -> t -> unit

zigzag i e zigzag-encodes a varint i and writes it to e.

Sourceval bits32 : int32 -> t -> unit

bits32 i e writes four bytes of i to e.

Sourceval bits64 : int64 -> t -> unit

bits64 i e writes eight bytes of i to e.

Sourceval bytes : bytes -> t -> unit

bytes b e writes a varint indicating length of b and then b to e.

Sourceval nested : (t -> unit) -> t -> unit

nested f e applies f to an encoder for a message nested in e.

Sourceval key : (int * payload_kind) -> t -> unit

key (k, pk) e writes a key and a payload kind to e.

Sourceval encode_exn : ('a -> t -> unit) -> 'a -> bytes

encode_exn f xlet e = create () in f x e; to_bytes f.

Sourceval encode : ('a -> t -> unit) -> 'a -> bytes option

encode f xtry Some (encode_exn f x) with Failure _ -> None.

Sourceval int32_of_int : string -> int -> int32

int32_of_int fld v returns v truncated to int32. If the value doesn't fit in the range of int32, raises Failure (Overflow fld).

Sourceval int32_of_int64 : string -> int64 -> int32

int32_of_int64 fld v returns v truncated to int32. If the value doesn't fit in the range of int32, raises Failure (Overflow fld).

OCaml

Innovation. Community. Security.