package qcow-types

  1. Overview
  2. Docs

Source file qcow_s.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
(*
 * 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 *)

module type LOG = sig
  (** Common logging functions *)

  val debug : ('a, unit, string, unit) format4 -> 'a

  val info : ('a, unit, string, unit) format4 -> 'a

  val error : ('a, unit, string, unit) format4 -> 'a
end

module type SERIALISABLE = sig
  (** Values which can be read and written *)

  (** Instances of this type can be read and written *)
  type t

  val sizeof : t -> int
  (** The size of a buffer needed to hold [t] *)

  val read : Cstruct.t -> (t * Cstruct.t, [`Msg of string]) 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.*)

  val write : t -> Cstruct.t -> (Cstruct.t, [`Msg of string]) 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.*)
end

module type PRINTABLE = sig
  (** Values which can be pretty-printed *)

  (** Instances of this type can be pretty-printed *)
  type t

  val to_string : t -> string
  (** Produce a pretty human-readable string from a value *)
end

module type RESIZABLE_BLOCK = sig
  include Mirage_block.S

  val resize : t -> int64 -> (unit, write_error) result Lwt.t
  (** Resize the file to the given number of sectors. *)

  val flush : t -> (unit, write_error) result Lwt.t
  (** [flush t] flushes any buffers, if the file has been opened in buffered
      mode *)
end

module type NUM = sig
  type t

  val zero : t

  val pred : t -> t

  val succ : t -> t

  val add : t -> t -> t

  val sub : t -> t -> t

  val mul : t -> t -> t

  val div : t -> t -> t

  val of_int64 : int64 -> t

  val to_int64 : t -> int64

  val of_int : int -> t

  val to_int : t -> int

  val to_string : t -> string

  val shift_left : t -> int -> t

  val shift_right_logical : t -> int -> t

  val logor : t -> t -> t

  val rem : t -> t -> t
end