gitql_ast/types/
interval.rs1use std::any::Any;
2
3use crate::types::integer::IntType;
4
5use super::base::DataType;
6
7#[derive(Clone)]
8pub struct IntervalType;
9
10impl DataType for IntervalType {
11 fn literal(&self) -> String {
12 "Interval".to_string()
13 }
14
15 fn equals(&self, other: &Box<dyn DataType>) -> bool {
16 other.is_any() || other.is_interval() || other.is_variant_with(|t| t.is_interval())
17 }
18
19 fn as_any(&self) -> &dyn Any {
20 self
21 }
22
23 fn can_perform_add_op_with(&self) -> Vec<Box<dyn DataType>> {
24 vec![Box::new(IntervalType)]
25 }
26
27 fn add_op_result_type(&self, _other: &Box<dyn DataType>) -> Box<dyn DataType> {
28 Box::new(IntervalType)
29 }
30
31 fn can_perform_sub_op_with(&self) -> Vec<Box<dyn DataType>> {
32 vec![Box::new(IntervalType)]
33 }
34
35 fn sub_op_result_type(&self, _other: &Box<dyn DataType>) -> Box<dyn DataType> {
36 Box::new(IntervalType)
37 }
38
39 fn can_perform_mul_op_with(&self) -> Vec<Box<dyn DataType>> {
40 vec![Box::new(IntType)]
41 }
42
43 fn mul_op_result_type(&self, _other: &Box<dyn DataType>) -> Box<dyn DataType> {
44 Box::new(IntervalType)
45 }
46
47 fn can_perform_div_op_with(&self) -> Vec<Box<dyn DataType>> {
48 vec![Box::new(IntType)]
49 }
50
51 fn div_op_result_type(&self, _other: &Box<dyn DataType>) -> Box<dyn DataType> {
52 Box::new(IntervalType)
53 }
54
55 fn can_perform_eq_op_with(&self) -> Vec<Box<dyn DataType>> {
56 vec![Box::new(IntervalType)]
57 }
58
59 fn can_perform_bang_eq_op_with(&self) -> Vec<Box<dyn DataType>> {
60 vec![Box::new(IntervalType)]
61 }
62
63 fn can_perform_gt_op_with(&self) -> Vec<Box<dyn DataType>> {
64 vec![Box::new(IntervalType)]
65 }
66
67 fn can_perform_gte_op_with(&self) -> Vec<Box<dyn DataType>> {
68 vec![Box::new(IntervalType)]
69 }
70
71 fn can_perform_lt_op_with(&self) -> Vec<Box<dyn DataType>> {
72 vec![Box::new(IntervalType)]
73 }
74
75 fn can_perform_lte_op_with(&self) -> Vec<Box<dyn DataType>> {
76 vec![Box::new(IntervalType)]
77 }
78}