Bare_encoding
BARE runtime library.
See the spec.
module String_map : sig ... end
type 'a input = {
read_byte : 'a -> char;
Read a single byte.
*)read_i16 : 'a -> int;
Read 2 bytes, in little endian.
*)read_i32 : 'a -> int32;
Read 4 bytes, in little endian.
*)read_i64 : 'a -> int64;
Read 8 bytes, in little endian.
*)read_exact : 'a -> bytes -> int -> int -> unit;
read_exact buf i len
reads len
bytes into buf
, starting at offset i
}
Input type.
An input is a source of bytes, used to decode.
module Decode : sig ... end
Decoders.
type 'a output = {
write_byte : 'a -> char -> unit;
Write a single byte.
*)write_i16 : 'a -> int -> unit;
Write 2 bytes, in little endian.
*)write_i32 : 'a -> int32 -> unit;
Write 4 bytes, in little endian.
*)write_i64 : 'a -> int64 -> unit;
Write 8 bytes, in little endian.
*)write_exact : 'a -> bytes -> int -> int -> unit;
write_exact b i len
writes the slice of length len
of b
starting at i
.
flush : 'a -> unit;
Non specified hint that the data may be flushed onto the disk or network. Doing nothing is acceptable when this makes no sense (e.g. when writing to a Buffer.t
).
}
Output
An output is a sink where one can write bytes to encode data to BARE.
module Encode : sig ... end
Encoder type and some encoding utils.
module Pp : sig ... end
Pretty printer utils, using Format
.
val of_bytes_exn : ?off:int -> ?len:int -> 'a Decode.dec -> bytes -> 'a
of_bytes_exn dec bs
uses dec
to decode a value of type 'a
from bytes stored in bs
.
val of_bytes :
?off:int ->
?len:int ->
'a Decode.dec ->
bytes ->
('a, string) Stdlib.result
Same as of_bytes_exn
but doesn't raise.
val of_string_exn : ?off:int -> ?len:int -> 'a Decode.dec -> string -> 'a
Decode a value stored in the string. See of_bytes_exn
for more details.
val of_string :
?off:int ->
?len:int ->
'a Decode.dec ->
string ->
('a, string) Stdlib.result
Safe version of of_string_exn
val to_string : 'a Encode.enc -> 'a -> string
Encode a value of type 'a
into a string using the given encoder.