Skip to main content

graphrecords_query/
cast.rs

1use std::{
2    fmt::{self, Display, Formatter},
3    hash::Hash,
4};
5
6pub trait CastTarget: Clone + Display + Eq + Hash + 'static + Send + Sync {}
7
8#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
9pub struct Bool;
10
11#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
12pub struct DateTime;
13
14#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
15pub struct Duration;
16
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
18pub struct Float;
19
20#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
21pub struct Int;
22
23#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
24pub struct String;
25
26impl CastTarget for Bool {}
27
28impl CastTarget for DateTime {}
29
30impl CastTarget for Duration {}
31
32impl CastTarget for Float {}
33
34impl CastTarget for Int {}
35
36impl CastTarget for String {}
37
38impl Display for Bool {
39    fn fmt(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
40        formatter.write_str("Bool")
41    }
42}
43
44impl Display for DateTime {
45    fn fmt(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
46        formatter.write_str("DateTime")
47    }
48}
49
50impl Display for Duration {
51    fn fmt(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
52        formatter.write_str("Duration")
53    }
54}
55
56impl Display for Float {
57    fn fmt(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
58        formatter.write_str("Float")
59    }
60}
61
62impl Display for Int {
63    fn fmt(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
64        formatter.write_str("Int")
65    }
66}
67
68impl Display for String {
69    fn fmt(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
70        formatter.write_str("String")
71    }
72}