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
pub mod error;
pub mod http;
pub mod query;
pub mod response;
use edn_rs::{Deserialize, Edn, EdnError, Serialize};
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord)]
pub struct CruxId(String);
impl Serialize for CruxId {
fn serialize(mut self) -> String {
self.0.insert(0, ':');
format!("{}", self.0.replace(" ", "-"))
}
}
impl Deserialize for CruxId {
fn deserialize(edn: &Edn) -> Result<Self, EdnError> {
match edn {
Edn::Key(k) => Ok(Self::new(k)),
Edn::Str(s) => Ok(Self::new(s)),
_ => Err(EdnError::Deserialize(format!(
"couldn't convert {} into CruxId",
edn
))),
}
}
}
impl CruxId {
pub fn new(id: &str) -> Self {
let clean_id = id.replace(":", "");
Self {
0: clean_id.to_string(),
}
}
}
pub use http::{Actions, Order};