package mirage-qubes

  1. Overview
  2. Docs

Source file 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
type 'a or_eof =
  [ `Ok of 'a
  | `Eof ]

module type MSG_CHAN = sig
  type t

  val recv : t -> (string * string) or_eof Lwt.t
  (** Receive one packet (header and body) *)

  val recv_fixed : t -> int -> string or_eof Lwt.t
  (** Receive one packet of known size (no header) *)

  val recv_raw : t -> string or_eof Lwt.t
  (** Read a chunk of data from the stream.
      Blocks if no data is available yet. *)

  val send : t -> string list -> unit or_eof Lwt.t
  (** Send one or more packets (takes the mutex) *)
end

module type FLOW = sig
  type t

  val write : t -> string -> unit Lwt.t
  (** Write to stdout *)

  val writef : t -> ('a, unit, string, unit Lwt.t) format4 -> 'a
  (** Write a formatted line to stdout. *)

  val ewrite : t -> string -> unit Lwt.t
  (** Write to stderr *)

  val ewritef : t -> ('a, unit, string, unit Lwt.t) format4 -> 'a
  (** Write a formatted line to stderr. *)

  val read : t -> [`Ok of string | `Eof] Lwt.t
  (** Read from stdin. *)

  val read_line : t -> [`Ok of string | `Eof] Lwt.t
  (** Read a complete line from stdin. *)
end

module type DB = sig
  type t

  module KeyMap : Map.S with type key = string

  val read :  t -> string -> string option
  (** [read t key] is the last known value of [key]. *)

  val write :  t -> string -> string -> unit Lwt.t
  (** [write t key value] sets [key] to [value]. *)

  val bindings : t -> string KeyMap.t
  (** [bindings t] is the bindings of [t] at the time of the call. *)

  val after : t -> string KeyMap.t -> string KeyMap.t Lwt.t
  (** [after prev] waits until the current bindings are different to [prev]
      and then returns the new bindings. *)

  val got_new_commit : t -> string -> string KeyMap.t -> string KeyMap.t Lwt.t
  (** [got_new_commit t key prev] either waits until a new commit (empty write)
      has been written to [key] into the qubesDB [t], or the entries starting
      with [key] are different from [prev]. Returns the entries starting with
      [key]. *)
end