<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <link rel="Start" href="index.html"> <link rel="previous" href="Map_to_safe.html"> <link rel="Up" href="index.html"> <link title="Index of types" rel=Appendix href="index_types.html"> <link title="Index of exceptions" rel=Appendix href="index_exceptions.html"> <link title="Index of values" rel=Appendix href="index_values.html"> <link title="Index of modules" rel=Appendix href="index_modules.html"> <link title="Index of module types" rel=Appendix href="index_module_types.html"> <link title="Binable" rel="Chapter" href="Binable.html"> <link title="Nat0" rel="Chapter" href="Nat0.html"> <link title="Common" rel="Chapter" href="Common.html"> <link title="Unsafe_common" rel="Chapter" href="Unsafe_common.html"> <link title="Unsafe_write_c" rel="Chapter" href="Unsafe_write_c.html"> <link title="Unsafe_read_c" rel="Chapter" href="Unsafe_read_c.html"> <link title="Size" rel="Chapter" href="Size.html"> <link title="Write_ml" rel="Chapter" href="Write_ml.html"> <link title="Read_ml" rel="Chapter" href="Read_ml.html"> <link title="Write_c" rel="Chapter" href="Write_c.html"> <link title="Read_c" rel="Chapter" href="Read_c.html"> <link title="Std" rel="Chapter" href="Std.html"> <link title="Type_class" rel="Chapter" href="Type_class.html"> <link title="Map_to_safe" rel="Chapter" href="Map_to_safe.html"> <link title="Utils" rel="Chapter" href="Utils.html"><title>Utils</title> </head> <body> <div class="navbar"><a class="pre" href="Map_to_safe.html" title="Map_to_safe">Previous</a> <a class="up" href="index.html" title="Index">Up</a> </div> <h1>Module <a href="type_Utils.html">Utils</a></h1> <pre><span class="keyword">module</span> Utils: <code class="code">sig</code> <a href="Utils.html">..</a> <code class="code">end</code></pre><div class="info module top"> Utility functions for user convenience<br> </div> <hr width="100%"> <pre><span id="VALbin_dump"><span class="keyword">val</span> bin_dump</span> : <code class="type">?header:bool -> 'a <a href="Type_class.html#TYPEwriter">Type_class.writer</a> -> 'a -> <a href="Common.html#TYPEbuf">Common.buf</a></code></pre><div class="info "> <code class="code">bin_dump ?header writer v</code> uses <code class="code">writer</code> to first compute the size of <code class="code">v</code> in the binary protocol, then allocates a buffer of exactly this size, and then writes out the value. If <code class="code">header</code> is <code class="code">true</code>, the size of the resulting binary string will be prefixed as a signed 64bit integer.<br> <b>Raises</b> <code>Failure</code> if the size of the value changes during writing, and any other exceptions that the binary writer in <code class="code">writer</code> can raise.<br> <b>Returns</b> the buffer containing the written out value.<br> </div> <div class="param_info"><code class="code">header</code> : default = <code class="code">false</code></div> <pre><span id="VALbin_read_stream"><span class="keyword">val</span> bin_read_stream</span> : <code class="type">?max_size:int -><br> read:(<a href="Common.html#TYPEbuf">Common.buf</a> -> pos:int -> len:int -> unit) -> 'a <a href="Type_class.html#TYPEreader">Type_class.reader</a> -> 'a</code></pre><div class="info "> <code class="code">bin_read_stream ?max_size ~read reader</code> reads binary protocol data from a stream as generated by the <code class="code">read</code> function, which places data of a given length into a given buffer. Requires a header. The <code class="code">reader</code> type class will be used for conversion to OCaml-values.<br> <b>Raises</b><ul><li><code>Failure</code> if the size of the value disagrees with the one specified in the header, and any other exceptions that the binary reader associated with <code class="code">reader</code> can raise.</li> <li><code>Failure</code> if the size reported in the data header is longer than <code class="code">max_size</code>.</li> </ul> </div> <div class="param_info"><code class="code">max_size</code> : = nothing</div> <br> Conversion of binable types<br> <pre><span class="keyword">module type</span> <a href="Utils.Make_binable_spec.html">Make_binable_spec</a> = <code class="code">sig</code> <a href="Utils.Make_binable_spec.html">..</a> <code class="code">end</code></pre> <pre><span class="keyword">module</span> <a href="Utils.Make_binable.html">Make_binable</a>: <div class="sig_block"><code class="code">functor (</code><code class="code">Bin_spec</code><code class="code"> : </code><code class="type"><a href="Utils.Make_binable_spec.html">Make_binable_spec</a></code><code class="code">) -> </code><code class="type"><a href="Binable.S.html">Binable.S</a></code><code class="type"> with type t := Bin_spec.t</code></div></pre> <pre><span class="keyword">module type</span> <a href="Utils.Make_binable1_spec.html">Make_binable1_spec</a> = <code class="code">sig</code> <a href="Utils.Make_binable1_spec.html">..</a> <code class="code">end</code></pre> <pre><span class="keyword">module</span> <a href="Utils.Make_binable1.html">Make_binable1</a>: <div class="sig_block"><code class="code">functor (</code><code class="code">Bin_spec</code><code class="code"> : </code><code class="type"><a href="Utils.Make_binable1_spec.html">Make_binable1_spec</a></code><code class="code">) -> </code><code class="type"><a href="Binable.S1.html">Binable.S1</a></code><code class="type"> with type 'a t := 'a Bin_spec.t</code></div></pre> <pre><span class="keyword">module type</span> <a href="Utils.Make_binable2_spec.html">Make_binable2_spec</a> = <code class="code">sig</code> <a href="Utils.Make_binable2_spec.html">..</a> <code class="code">end</code></pre> <pre><span class="keyword">module</span> <a href="Utils.Make_binable2.html">Make_binable2</a>: <div class="sig_block"><code class="code">functor (</code><code class="code">Bin_spec</code><code class="code"> : </code><code class="type"><a href="Utils.Make_binable2_spec.html">Make_binable2_spec</a></code><code class="code">) -> </code><code class="type"><a href="Binable.S2.html">Binable.S2</a></code><code class="type"> with type ('a, 'b) t := ('a, 'b) Bin_spec.t</code></div></pre><br> Conversion of iterable types<br> <pre><span class="keyword">module type</span> <a href="Utils.Make_iterable_binable_spec.html">Make_iterable_binable_spec</a> = <code class="code">sig</code> <a href="Utils.Make_iterable_binable_spec.html">..</a> <code class="code">end</code></pre> <pre><span class="keyword">module</span> <a href="Utils.Make_iterable_binable.html">Make_iterable_binable</a>: <div class="sig_block"><code class="code">functor (</code><code class="code">Iterable_spec</code><code class="code"> : </code><code class="type"><a href="Utils.Make_iterable_binable_spec.html">Make_iterable_binable_spec</a></code><code class="code">) -> </code><code class="type"><a href="Binable.S.html">Binable.S</a></code><code class="type"> with type t := Iterable_spec.t</code></div></pre> <pre><span class="keyword">module type</span> <a href="Utils.Make_iterable_binable1_spec.html">Make_iterable_binable1_spec</a> = <code class="code">sig</code> <a href="Utils.Make_iterable_binable1_spec.html">..</a> <code class="code">end</code></pre> <pre><span class="keyword">module</span> <a href="Utils.Make_iterable_binable1.html">Make_iterable_binable1</a>: <div class="sig_block"><code class="code">functor (</code><code class="code">Iterable_spec</code><code class="code"> : </code><code class="type"><a href="Utils.Make_iterable_binable1_spec.html">Make_iterable_binable1_spec</a></code><code class="code">) -> </code><code class="type"><a href="Binable.S1.html">Binable.S1</a></code><code class="type"> with type 'a t := 'a Iterable_spec.t</code></div></pre> <pre><span class="keyword">module type</span> <a href="Utils.Make_iterable_binable2_spec.html">Make_iterable_binable2_spec</a> = <code class="code">sig</code> <a href="Utils.Make_iterable_binable2_spec.html">..</a> <code class="code">end</code></pre> <pre><span class="keyword">module</span> <a href="Utils.Make_iterable_binable2.html">Make_iterable_binable2</a>: <div class="sig_block"><code class="code">functor (</code><code class="code">Iterable_spec</code><code class="code"> : </code><code class="type"><a href="Utils.Make_iterable_binable2_spec.html">Make_iterable_binable2_spec</a></code><code class="code">) -> </code><code class="type"><a href="Binable.S2.html">Binable.S2</a></code><code class="type"> with type ('a, 'b) t := ('a, 'b) Iterable_spec.t</code></div></pre></body></html>