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
pub mod generated;
#[allow(unused_imports)]
pub use generated::*;
#[macro_use]
#[cfg(feature = "guest")]
extern crate serde_derive;
#[cfg(feature = "guest")]
mod results;
#[cfg(feature = "guest")]
pub use results::FromTable;
#[cfg(feature = "guest")]
mod conversions;
#[cfg(feature = "guest")]
mod errors;
#[cfg(feature = "guest")]
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Sync + Send>>;
#[doc(hidden)]
#[macro_export]
#[cfg(feature = "guest")]
macro_rules! client_type_error {
($($arg:tt)*) => {
Err($crate::errors::GraphError::ClientTypeError(format!($($arg)*)))
};
}
#[cfg(feature = "guest")]
impl Host {
pub fn query_graph<T: FromTable>(
&self,
graph_name: String,
query: String,
) -> ::wapc_guest::HandlerResult<T> {
let res = self
._query_graph(graph_name.into(), query.into())
.map(|res| T::from_table(&res.result_set));
match res {
Ok(Ok(l)) => Ok(l),
_ => Err("Graph conversion error".into()),
}
}
}
pub const OP_QUERY: &str = "QueryGraph";
pub const OP_DELETE: &str = "DeleteGraph";