Pbrt.EncoderEncoding protobufs.
A (mutable) encoder.
This encoder can be re-used, see clear.
val error_to_string : error -> stringexception Failure of errorval create : ?size:int -> unit -> tCreate a new encoder.
val clear : t -> unitClear the content of the internal buffer(s), but does not release memory. This makes the encoder ready to encode another message.
val reset : t -> unitClears the content and resets internal storage to its initial memory consumption.
This is more costly than clear but can be useful after a very large message was encoded.
val to_bytes : t -> bytesExtract the content of the encoder to bytes.
val to_string : t -> stringExtract the content of the encoder to a string. Call this after encoding a message into the encoder.
val write_chunks : (bytes -> int -> int -> unit) -> t -> unitwrite_chunks w e calls the write function w (e.g output oc for some output channel oc) on every chunk inside e. The number of chunks is an implementation detail.
These combinators are used by generated code (or user combinators) to encode a OCaml value into the wire representation of protobufs.
val key : int -> payload_kind -> t -> unitkey k pk e writes a key and a payload kind to e.
nested f x e applies f x to an encoder for a message nested in e.
val map_entry :
encode_key:('a -> t -> unit) ->
encode_value:('b -> t -> unit) ->
(('a * payload_kind) * ('b * payload_kind)) ->
t ->
unitval empty_nested : t -> unitnested f e encodes a zero length empty message
val int_as_varint : int -> t -> unitint_as_varint i e encodes i in e with Varint encoding
val int_as_zigzag : int -> t -> unitint_as_zigzag i e encodes i in e with Varint zigzag encoding
val int32_as_varint : int32 -> t -> unitint32_as_varint i e encodes i in e with Varint encoding
val int32_as_zigzag : int32 -> t -> unitint32_as_varint i e encodes i in e with Varint zigzag encoding
val int64_as_varint : int64 -> t -> unitint64_as_varint i e encodes i in e with Varint encoding
val int64_as_zigzag : int64 -> t -> unitint64_as_varint i e encodes i in e with Varint zigzag encoding
val int32_as_bits32 : int32 -> t -> unitint32_as_varint i e encodes i in e with Bits32 encoding
val int64_as_bits64 : int64 -> t -> unitint64_as_varint i e encodes i in e with Bits64 encoding
val uint32_as_varint : [ `unsigned of int32 ] -> t -> unitval uint32_as_zigzag : [ `unsigned of int32 ] -> t -> unitval uint64_as_varint : [ `unsigned of int64 ] -> t -> unitval uint64_as_zigzag : [ `unsigned of int64 ] -> t -> unitval uint32_as_bits32 : [ `unsigned of int32 ] -> t -> unitval uint64_as_bits64 : [ `unsigned of int64 ] -> t -> unitval bool : bool -> t -> unitencode b e encodes b in e with Varint encoding
val float_as_bits32 : float -> t -> unitfloat_as_bits32 f e encodes f in e with Bits32 encoding
val float_as_bits64 : float -> t -> unitfloat_as_bits64 f e encodes f in e with Bits64 encoding
val int_as_bits32 : int -> t -> unitint_as_bits32 i e encodes i in e with Bits32 encoding TODO : add error handling
val int_as_bits64 : int -> t -> unitint_as_bits64 i e encodes i in e with Bits64 encoding
val string : string -> t -> unitstring s e encodes s in e
val bytes : bytes -> t -> unitstring s e encodes s in e
val wrapper_double_value : float option -> t -> unitval wrapper_float_value : float option -> t -> unitval wrapper_int64_value : int64 option -> t -> unitval wrapper_int32_value : int32 option -> t -> unitval wrapper_bool_value : bool option -> t -> unitval wrapper_string_value : string option -> t -> unitval wrapper_bytes_value : bytes option -> t -> unit