1use std::fmt::Debug;
2
3use crate::Predicate;
4
5#[derive(Copy, Clone, PartialEq, Debug)]
6pub enum Type {
7 INT,
8}
9
10pub fn get_type_length(t: Type) -> usize {
11 match t {
12 Type::INT => 4,
13 }
14}
15
16#[derive(PartialEq, Debug, Clone)]
17pub struct FieldItem {
18 pub field_type: Type,
19 pub field_name: String,
20}
21
22#[derive(Copy, Clone, PartialEq, Eq, Ord, Debug, PartialOrd)]
23pub struct IntField {
24 pub value: i32,
25}
26
27impl IntField {
28 pub fn new(v: i32) -> IntField {
29 IntField { value: v }
30 }
31
32 pub fn len(&self) -> usize {
33 4
34 }
35
36 pub fn satisfy(&self, predicate: &Predicate) -> bool {
37 match predicate.op {
38 crate::Op::Equals => self.value == predicate.field.value,
39 crate::Op::GreaterThan => self.value > predicate.field.value,
40 crate::Op::LessThan => self.value < predicate.field.value,
41 crate::Op::LessThanOrEq => self.value <= predicate.field.value,
42 crate::Op::GreaterThanOrEq => self.value >= predicate.field.value,
43 crate::Op::Like => todo!(),
44 crate::Op::NotEquals => self.value != predicate.field.value,
45 }
46 }
47}