aboutsummaryrefslogtreecommitdiffstats
path: root/lib/abstract/Storage.ml
blob: afd1a3cb3e0bb4c7de436393b26d610ab9efdd5c (plain) (blame)
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
module type STORAGE = sig
  type connection
  type transaction

  type address = Label of string | Hash of Concepts.Hash.hash

  val connect : Concepts.Configuration.term -> (connection, Concepts.Condition.condition) result

  (** close `connection`, after which none of its transactions may be used *)
  val disconnect : connection -> unit

  (** begin a transaction within `connection` *)
  val start : connection -> (transaction, Concepts.Condition.condition) result

  (** begin a read-only transaction, which may be held alongside others *)
  val start_read : connection -> (transaction, Concepts.Condition.condition) result

  (** `commit` the current transaction *)
  val commit : transaction -> (unit, Concepts.Condition.condition) result

  (** `abort` the current transaction *)
  val abort : transaction -> (unit, Concepts.Condition.condition) result

  (** within a transaction, fetch a blob from disk *)
  val get :
    transaction ->
    address ->
    (Concepts.Blob.t option, Concepts.Condition.condition) result

  (** within a transaction, associate a hash with a blob on disk *)
  val put :
    transaction ->
    address ->
    Concepts.Blob.t ->
    (unit, Concepts.Condition.condition) result
end