package b0
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=00a6868b4dfa34565d0141b335622a81a0e8d5b9e3c6dfad025dabfa3df2db2a1302b492953bbbce30c3a4406c324fcec25250a00b38f6d18a69e15605e3b07e
doc/b0.std/B0_std/Bincode/index.html
Module B0_std.Bincode
Binary coding of values.
Encoders
type 'a enc = Buffer.t -> 'a -> unitThe type for encoders of values of type 'a. The call enc b v must encode v in buffer b.
Decoders
val err : int -> ('a, Format.formatter, unit, 'b) format4 -> 'aerr i fmt reports a decoding error for position i formatted according to fmt.
err_byte ~kind i byte report an error for the unexpected byte byte at position i for decoding a value of type kind.
get_byte s i is the byte s.[i]. Does not check that i is in bounds.
dec_eoi s i asserts that i is exactly at the end of input, i.e. String.length s.
Codecs
encode c v encodes v using c (and buf if provided, it is the client's duty to reset it before an encoding).
of_string ~file c s decodes a value from s using c and dec_eoi. In case of error file is mentioned in the error message (defaults to Os.File.dash).
Base codecs
Magic numbers
val enc_magic : string -> unit encenc_magic m encodes string m as a magic number.
val dec_magic : string -> unit decdec_magic m decodes magic number m and returns the next index to read from.
val magic : string -> unit tmagic m is a codec for magic number m.
Bytes
val enc_byte : int encenc_byte is a byte encoder. Values larger than 0xFF are truncated.
val dec_byte : kind:string -> int decdec_byte decodes a byte for a value of type kind (used with err_byte)
unit
val enc_unit : unit encenc_unit encodes unit.
val dec_unit : unit decdec_unit decodes unit.
val unit : unit tunti is a codec for unit.
bool
val enc_bool : bool encenc_bool encodes a boolean.
val dec_bool : bool decdec_bool decodes a boolean.
val bool : bool tbool is a codec for bool.
int
val enc_int : int encenc_int encodes an integer. The encoding does not depend on Sys.word_size.
val dec_int : int decdec_int dedodes an integer. Warning. An int encoded on a 64-bit platform may end up being truncated if read back on 32-bit platform.
val int : int tint is a codec for integers.
int64
val enc_int64 : int64 encenc_int64 encodes an int64.
val dec_int64 : int64 decdec_int64 decodes an int64.
val int64 : int64 tint64 is a coded for int64.
string
val enc_string : string encenc_string encodes a string.
val dec_string : string decdec_string decodes a string.
val string : string tstring is a codec for string.
Fpath.t
list
option
enc_option enc encodes an option using enc for the Some case value.
dec_option dec decodes an option using dec for the Some case value.
result
enc_result ~ok ~error encodes a result value with the corresponding case encoders.
dec_result ~ok ~error decodes a result value with the corresponding case decoders.
result is a codec for results with Ok elements coded with ok and Error elements coded with error.
Set.t
enc_set (module S) enc encodes S.t sets using enc for its elements.
dec_set (module S) dec decodes S.t sets with dec for its elements.
set (module S) c is a codec for S.t sets using c for its elements.
Hash.t
Time.span
val enc_time_span : Mtime.span encenc_time_span encodes a Mtime.span.
val dec_time_span : Mtime.span decdec_time_span decodes a Mtime.span.
val time_span : Mtime.span ttime_span is a codec for Mtime.span.
Time.cpu_span
val enc_cpu_time_span : Os.Cpu.Time.span encenc_cpu_time_span encodes a Os.Cpu.Time.span.
val dec_cpu_time_span : Os.Cpu.Time.span decdec_cpu_time_span decodes a Os.Cpu.Time.span.
val cpu_time_span : Os.Cpu.Time.span tcpu_time_span is a codec for Os.Cpu.Time.span.