Library
Module
Module type
Parameter
Class
Class type
val break : indent:int -> len:int -> ('v, 'v) order
break ~indent ~len
tries to add len
spaces into the current line. If it fails - if we overflow the current line - we insert a new_line
and fill the beginning of the new line with indent
space characters.
val fws : ('v, 'v) order
fws
is a specialization of break
with indent = 1
and spaces = 1
. This is the most used token to express an opportunity to break the line and be conform to RFC 822
and the folding-whitespace token.
val cut : ('v, 'v) order
cut
gives an opportunity to add a break line without indentation and spaces.
val new_line : ('v, 'v) order
new_line
inserts a new line regardless how many bytes the current line has.
val tbox : int -> ('v, 'v) order
tbox indent
creates a new box to indent any contents inside with indent
spaces.
val bbox : ('v, 'v) order
bbox
creates a new box to indent any contents at the current position of the serializer.
val box : ('v, 'v) order
val close : ('v, 'v) order
close
closes any boxes.
using f pp
apply f
on the value and use pp
then to serialize the result.
val string : string t
string
permits to serialize a string
.
val bytes : Stdlib.Bytes.t t
bytes
permits to serialize a bytes
.
val bigstring : Bigstringaf.t t
bigstring
permits to serialize a bigstring.
val breakable : string t
val char : char t
char
permits to serialize a char
.
list ~sep pp
permits to serialize a list of values which can be serialized with pp
. Between each values, we apply sep
.
module Buffer : sig ... end
module IOVec : sig ... end
create ?margin ?new_line ~emitter weight
creates a serializer bounded to weight
elements. The serializer is limiter to emit margin
bytes per lines and break the line with new_line
(default to "\r\n"
).
emitter
is called when the serializer is full. It gives to user what it needs to transmit to the output and it asks how many bytes the user was able to transmit.
val is_empty : ppf -> bool
is_empty ppf
returns true
if the serializer is empty. Otherwise, it returns false
.
flush ppf
enforces the serializer to call the internal emitter
to transmit out what is serialized - even if ppf
is not full.
val to_string : ?margin:int -> ?new_line:string -> 'a t -> 'a -> string
to_string ?margin ?new_line pp v
serializes a value v
with the serializer pp
into a string
.
val to_stream :
?margin:int ->
?new_line:string ->
'a t ->
'a ->
unit ->
string option
to_stream ?margin ?new_line pp v
serializes a value v
with the serializer pp
and it returns a function unit -> string option
to transmit out the result chunk by chunk of the serialization.