1 /// Contains all the HiRPC DART crud commands
2 module tagion.dart.DARTcrud;
3 
4 import std.algorithm.iteration : filter;
5 import std.range : ElementType, isInputRange;
6 import tagion.basic.Types : Buffer, isBufferType;
7 import tagion.communication.HiRPC;
8 import tagion.dart.DART : DART;
9 import tagion.dart.DARTBasic : DARTIndex;
10 import tagion.dart.DARTRim;
11 import tagion.dart.Recorder;
12 import tagion.hibon.HiBON : HiBON;
13 
14 /**
15        * Constructs a HiRPC method for dartRead 
16        * Params:
17        *   dart_indices = List of hash-pointers 
18        *   hirpc = HiRPC credentials 
19        *   id = HiRPC id 
20        * Returns: 
21        *   HiRPC Sender
22        */
23 const(HiRPC.Sender) dartRead(Range)(
24         Range dart_indices,
25         HiRPC hirpc = HiRPC(null),
26         uint id = 0) @safe if (isInputRange!Range && is(ElementType!Range : const(DARTIndex))) {
27     auto params = new HiBON;
28     auto params_dart_indices = new HiBON;
29     params_dart_indices = dart_indices.filter!(b => b.length !is 0);
30     params[DART.Params.dart_indices] = params_dart_indices;
31     return hirpc.dartRead(params, id);
32 }
33 
34 const(HiRPC.Sender) dartCheckRead(Range)(
35         Range dart_indices,
36         HiRPC hirpc = HiRPC(null),
37         uint id = 0) @safe if (isInputRange!Range && is(ElementType!Range : const(DARTIndex))) {
38 
39     auto params = new HiBON;
40     auto params_dart_indices = new HiBON;
41     params_dart_indices = dart_indices.filter!(b => b.length !is 0);
42     params[DART.Params.dart_indices] = params_dart_indices;
43     return hirpc.dartCheckRead(params, id);
44 }
45 
46 /**
47         * Constructs a HiRPC method for dartRim
48         * Params:
49         *   rims = rim-path to the DART sub-tree
50         *   hirpc = HiRPC credentials
51         *   id = HiRPC id
52         * Returns: 
53         *   HiRPC sender
54         */
55 const(HiRPC.Sender) dartRim(
56         ref const Rims rims,
57         HiRPC hirpc = HiRPC(null),
58         uint id = 0) @safe {
59     return hirpc.dartRim(rims, id);
60 }
61 
62 /**
63         * Constructs a HiRPC method for dartModify
64         * Params:
65         *   recorder = recoreder of archives
66         *   hirpc = HiRPC credentials
67         *   id = HiRPC id
68         * Returns: 
69         *   HiRPC sender
70         */
71 const(HiRPC.Sender) dartModify(
72         ref const RecordFactory.Recorder recorder,
73         HiRPC hirpc = HiRPC(null),
74         uint id = 0) @safe {
75     return hirpc.dartModify(recorder, id);
76 }
77 
78 /**
79          * Constructs a HiRPC method for the dartBullseye 
80          * Params:
81          *   hirpc = HiRPC credentials
82          *   id = HiRPC id
83          * Returns: 
84          *   HiRPC sender
85          */
86 const(HiRPC.Sender) dartBullseye(
87         HiRPC hirpc = HiRPC(null),
88         uint id = 0) @safe {
89     return hirpc.dartBullseye(null, id);
90 }