-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
protocol.capnp
60 lines (46 loc) · 1021 Bytes
/
protocol.capnp
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
@0xca7b236fb6fb07c3;
using Go = import "/go.capnp";
$Go.package("protocol");
$Go.import("zenhack.net/go/ocap-md/pkg/schema/protocol");
interface Map(K, V) {
find @0 (key: K) -> (value: V);
}
interface Getter(T) {
get @0 () -> (value :T);
}
interface Ref(T) extends(Getter(T)) {
getStored @0 () -> (storedValue :Stored(T));
}
interface Setter(T) {
set @0 (value :T);
}
interface Cell(T) extends (Setter(T), Getter(T)) {
}
interface TxCell(T) extends(Cell(T)) {
txGet @0 () -> (value :T, setter :Setter(T));
}
interface RootPtr extends(TxCell(Ref(Dynamic))) {
}
interface Storage {
put @0 [T] (value: T) -> (ref :Ref(T));
}
struct Dynamic {
ref @0 :Ref(AnyPointer);
typeId @1 :UInt64;
}
struct ContentId {
digest @0 :Data;
algo @1 :Algo;
enum Algo {
sha256 @0;
}
}
struct Stored(T) {
data @0 :T;
refs @1 :List(ContentId);
}
interface RootApi {
blobMap @0 () -> (map :Map(ContentId, Ref(AnyPointer)));
root @1 () -> (root :RootPtr);
storage @2 () -> (storage :Storage);
}