package pbrt

  1. Overview
  2. Docs

Types

type t

Creator

val of_bytes : bytes -> t

of_bytes b creates a decoder positioned at start of bytes b.

val of_string : string -> t

of_string s creates a decoder positioned at start of string s.

Errors

type error =
  1. | Incomplete
  2. | Overlong_varint
  3. | Malformed_field
  4. | Overflow of string
  5. | Unexpected_payload of string * payload_kind
  6. | Missing_field of string
  7. | Malformed_variant of string
val error_to_string : error -> string

error_to_string e converts error e to its string representation.

exception Failure of error
val malformed_variant : string -> 'a

malformed_variant variant_name raises the exception Protobuf.Decoder.Failure (Malformed_variant variant_name)

val unexpected_payload : string -> payload_kind -> 'a

unexpected_payload field_name pk raises the exception Protobuf.Decoder.Failure (Unexpected_payload (field_name, pk))

val missing_field : string -> 'a

missing_field field_name raises the exception Protobuf.Decoder.Failure (Missing_field field_name)

Decoding Functions

val key : t -> (int * payload_kind) option

key d reads a key and a payload kind from d. If d has exhausted its input when the function is called, returns None. If d has exhausted its input while reading, raises Failure Incomplete. If the payload kind is unknown, raises Failure Malformed_field.

val skip : t -> payload_kind -> unit

skip d pk skips the next value of kind pk in d. If skipping the value would exhaust input of d, raises Encoding_error Incomplete.

val nested : t -> t

nested d returns a decoder for a message nested in d. If reading the message would exhaust input of d, raises Failure Incomplete.

val map_entry : t -> decode_key:(t -> 'a) -> decode_value:(t -> 'b) -> 'a * 'b
val empty_nested : t -> unit

empty_nested d skips an empty message of 0 length. If reading the message would exhaust input of d, raises Failure Incomplete.

val packed_fold : ('a -> t -> 'a) -> 'a -> t -> 'a

packed_fold f e0 d folds over the a packed encoding with f acc d and initial value e0. If reading the message would exhaust input of d, raises Failure Incomplete.

val int_as_varint : t -> int

int_as_varint d reads an int value from d with Varint encoding. If the integer value read cannot be converted to int raises Failure Overflow "". If reading the message would exhaust input of d, raises Failure Incomplete.

val int_as_zigzag : t -> int

int_as_zigzag d reads an int value from d with zigzag encoding. If the integer value read cannot be converted to int raises Failure Overflow "". If reading the message would exhaust input of d, raises Failure Incomplete.

val int32_as_varint : t -> int32

int32_as_varint d reads an int32 value from d with Varint encoding. If the integer value read cannot be converted to int32 raises Failure Overflow "". If reading the message would exhaust input of d, raises Failure Incomplete.

val int32_as_zigzag : t -> int32

int32_as_varint d reads an int32 value from d with zigzag encoding. If the integer value read cannot be converted to int32 raises Failure Overflow "". If reading the message would exhaust input of d, raises Failure Incomplete.

val int64_as_varint : t -> int64

int64_as_varint d reads an int64 value from d with Varint encoding. If reading the message would exhaust input of d, raises Failure Incomplete.

val int64_as_zigzag : t -> int64

int64_as_varint d reads an int64 value from d with zigzag encoding. If reading the message would exhaust input of d, raises Failure Incomplete.

val int32_as_bits32 : t -> int32

int32_as_bits32 d reads an int32 value from d with 32 bit encoding. If reading the message would exhaust input of d, raises Failure Incomplete.

val int64_as_bits64 : t -> int64

int64_as_bits64 d reads an int64 value from d with 64 bit encoding. If reading the message would exhaust input of d, raises Failure Incomplete.

val bool : t -> bool

bool d reads a bool value from d with varing encoding. If the boolean value in d is neither 0 or 1 raises Failure Overflow "". If reading the message would exhaust input of d, raises Failure Incomplete.

val float_as_bits32 : t -> float

float_as_bits32 d reads a float value from d with 32 bit encoding. If reading the message would exhaust input of d, raises Failure Incomplete.

val float_as_bits64 : t -> float

float_as_bits64 d reads a float value from d with 64 bit encoding. If reading the message would exhaust input of d, raises Failure Incomplete.

val int_as_bits32 : t -> int

int_as_bits32 d reads a int value from d with 32 bit encoding. If the integer value read cannot be converted to int raises Failure Overflow "". If reading the message would exhaust input of d, raises Failure Incomplete.

val int_as_bits64 : t -> int

int_as_bits64 d reads a int value from d with 64 bit encoding. If the integer value read cannot be converted to int raises Failure Overflow "". If reading the message would exhaust input of d, raises Failure Incomplete.

val string : t -> string

string d reads a string value from d. If reading the message would exhaust input of d, raises Failure Incomplete.

val bytes : t -> bytes

bytes d reads a bytes value from d. If reading the message would exhaust input of d, raises Failure Incomplete.

val wrapper_double_value : t -> float option
val wrapper_float_value : t -> float option
val wrapper_int64_value : t -> int64 option
val wrapper_int32_value : t -> int32 option
val wrapper_bool_value : t -> bool option
val wrapper_string_value : t -> string option
val wrapper_bytes_value : t -> bytes option