1use std::error::Error;
2use std::fmt;
3use std::cmp::PartialEq;
4use std::any::Any;
5use json::object::Object;
6use json::JsonValue;
7
8pub const CMD_DELIMITER: &str = "::";
9
10#[allow(unused_variables)]
11pub trait Events {
12 fn after_delete(&self, data: &json::JsonValue) -> json::JsonValue{
13 data.clone()
14 }
15
16 fn after_get(&self, data: &json::JsonValue) -> json::JsonValue{
17 data.clone()
18 }
19
20 fn after_post(&self, data: &json::JsonValue) -> json::JsonValue{
21 data.clone()
22 }
23
24 fn after_put(&self, data: &json::JsonValue) -> json::JsonValue{
25 data.clone()
26 }
27
28 fn before_delete(&self, data: &json::JsonValue) -> json::JsonValue{
29 data.clone()
30 }
31
32 fn before_get(&self, data: &json::JsonValue) -> json::JsonValue{
33 data.clone()
34 }
35
36 fn before_post(&self, data: &json::JsonValue) -> json::JsonValue{
37 data.clone()
38 }
39
40 fn before_put(&self, data: &json::JsonValue) -> json::JsonValue{
41 data.clone()
42 }
43
44 fn on_error(&self, err: DataDotError) -> DataDotError{
45 err
46 }
47
48 fn on_load_plugin(&self, data: &json::JsonValue) -> json::JsonValue{
49 data.clone()
50 }
51
52 fn on_shutdown(&self, data: &json::JsonValue) -> json::JsonValue{
53 data.clone()
54 }
55
56 fn on_unload_plugin(&self, data: &json::JsonValue) -> json::JsonValue{
57 data.clone()
58 }
59
60 fn process_command(&self, message: &[u8], data: &json::JsonValue) -> json::JsonValue{
61 data.clone()
62 }
63}
64
65#[derive(Debug)]
66pub struct DataDotError {
67 details: String
68}
69
70impl DataDotError {
71 pub fn new(msg: &str) -> DataDotError {
72 DataDotError{
73 details: msg.to_string()
74 }
75 }
76}
77
78impl fmt::Display for DataDotError {
79 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
80 write!(f,"{}",self.details)
81 }
82}
83
84impl Error for DataDotError {
85 fn description(&self) -> &str {
86 &self.details
87 }
88}
89
90impl PartialEq for DataDotError {
91 fn eq(&self, other: &DataDotError) -> bool {
92 self.description() == other.description()
93 }
94}