123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163(*
* Copyright (C) 2015 David Scott <dave@recoil.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*)(** Common signatures used by the library *)openResultmoduletypeLOG=sig(** Common logging functions *)valdebug:('a,unit,string,unit)format4->'avalinfo:('a,unit,string,unit)format4->'avalerror:('a,unit,string,unit)format4->'aendmoduletypeSERIALISABLE=sig(** Values which can be read and written *)typet(** Instances of this type can be read and written *)valsizeof:t->int(** The size of a buffer needed to hold [t] *)valread:Cstruct.t->(t*Cstruct.t,[`Msgofstring])result(** Read a [t] from the given buffer and return it, along with the
unused remainder of the buffer. If the buffer cannot
be parsed then return an error.*)valwrite:t->Cstruct.t->(Cstruct.t,[`Msgofstring])result(** Write a [t] into the given buffer. If the buffer is too small,
then return an error. Return the unused remainder of the buffer.*)endmoduletypePRINTABLE=sig(** Values which can be pretty-printed *)typet(** Instances of this type can be pretty-printed *)valto_string:t->string(** Produce a pretty human-readable string from a value *)endmoduletypeRESIZABLE_BLOCK=sigincludeMirage_block.Svalresize:t->int64->(unit,write_error)resultLwt.t(** Resize the file to the given number of sectors. *)valflush:t->(unit,write_error)resultLwt.t(** [flush t] flushes any buffers, if the file has been opened in buffered
mode *)endmoduletypeINTERVAL_SET=sigtypeelt(** The type of the set elements *)typeinterval(** An interval: a range (x, y) of set values where all the elements from
x to y inclusive are in the set *)moduleInterval:sigvalmake:elt->elt->interval(** [make first last] construct an interval describing all the elements from
[first] to [last] inclusive. *)valx:interval->elt(** the starting element of the interval *)valy:interval->elt(** the ending element of the interval *)endtypet[@@derivingsexp](** The type of sets *)valempty:t(** The empty set *)valis_empty:t->bool(** Test whether a set is empty or not *)valcardinal:t->elt(** [cardinal t] is the number of elements in the set [t] *)valmem:elt->t->bool(** [mem elt t] tests whether [elt] is in set [t] *)valfold:(interval->'a->'a)->t->'a->'a(** [fold f t acc] folds [f] across all the intervals in [t] *)valfold_s:(interval->'a->'aLwt.t)->t->'a->'aLwt.t(** [fold_s f t acc] folds [f] across all the intervals in [t] *)valfold_individual:(elt->'a->'a)->t->'a->'a(** [fold_individual f t acc] folds [f] across all the individual elements of [t] *)valadd:interval->t->t(** [add interval t] returns the set consisting of [t] plus [interval] *)valremove:interval->t->t(** [remove interval t] returns the set consisting of [t] minus [interval] *)valmin_elt:t->interval(** [min_elt t] returns the smallest (in terms of the ordering) interval in
[t], or raises [Not_found] if the set is empty. *)valmax_elt:t->interval(** [max_elt t] returns the largest (in terms of the ordering) interval in
[t], or raises [Not_found] if the set is empty. *)valchoose:t->interval(** [choose t] returns one interval, or raises Not_found if the set is empty *)valtake:t->elt->(t*t)option(** [take n] returns [Some a, b] where [cardinal a = n] and [diff t a = b]
or [None] if [cardinal t < n] *)valunion:t->t->t(** set union *)valdiff:t->t->t(** set difference *)valinter:t->t->t(** set intersection *)endmoduletypeNUM=sigtypetvalzero:tvalpred:t->tvalsucc:t->tvaladd:t->t->tvalsub:t->t->tvalmul:t->t->tvaldiv:t->t->tvalof_int64:int64->tvalto_int64:t->int64valof_int:int->tvalto_int:t->intvalto_string:t->stringvalshift_left:t->int->tvalshift_right_logical:t->int->tvallogor:t->t->tvalrem:t->t->tend