diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-01-17 15:43:52 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-01-17 15:57:37 +0200 |
| commit | 75a9d560a69312bcf4dd0b9d3f00564a78e7c120 (patch) | |
| tree | f1a6ba1ae39a73a2fcf4b9bd137144cd9247a63e /log_db/src/common.rs | |
| parent | 98430c35eeb27b1bb3c7ac7a9e30a6918514358a (diff) | |
Refactor public interface
Diffstat (limited to 'log_db/src/common.rs')
| -rw-r--r-- | log_db/src/common.rs | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/log_db/src/common.rs b/log_db/src/common.rs index 09de2d7..6b7cac8 100644 --- a/log_db/src/common.rs +++ b/log_db/src/common.rs @@ -210,7 +210,7 @@ pub enum IndexableValue { /// A primitive type #[derive(Debug, Clone)] -pub enum PrimValueType { +pub enum PrimitiveType { Int, Decimal, String, @@ -219,36 +219,36 @@ pub enum PrimValueType { /// A primitive type + a nullability bit #[derive(Debug, Clone)] -pub struct ValueType { - pub prim_value_type: PrimValueType, +pub struct Type { + pub primitive: PrimitiveType, pub nullable: bool, } -impl ValueType { +impl Type { pub fn int() -> Self { - ValueType { - prim_value_type: PrimValueType::Int, + Type { + primitive: PrimitiveType::Int, nullable: false, } } pub fn decimal() -> Self { - ValueType { - prim_value_type: PrimValueType::Decimal, + Type { + primitive: PrimitiveType::Decimal, nullable: false, } } pub fn string() -> Self { - ValueType { - prim_value_type: PrimValueType::String, + Type { + primitive: PrimitiveType::String, nullable: false, } } pub fn bytes() -> Self { - ValueType { - prim_value_type: PrimValueType::Bytes, + Type { + primitive: PrimitiveType::Bytes, nullable: false, } } @@ -364,37 +364,37 @@ impl Value { } } -pub fn type_check(value: &Value, value_type: &ValueType) -> bool { +pub fn type_check(value: &Value, value_type: &Type) -> bool { match (value, value_type) { ( Value::Int(_), - ValueType { - prim_value_type: PrimValueType::Int, + Type { + primitive: PrimitiveType::Int, .. }, ) => true, ( Value::Decimal(_), - ValueType { - prim_value_type: PrimValueType::Decimal, + Type { + primitive: PrimitiveType::Decimal, .. }, ) => true, ( Value::Bytes(_), - ValueType { - prim_value_type: PrimValueType::Bytes, + Type { + primitive: PrimitiveType::Bytes, .. }, ) => true, ( Value::String(_), - ValueType { - prim_value_type: PrimValueType::String, + Type { + primitive: PrimitiveType::String, .. }, ) => true, - (Value::Null, ValueType { nullable: true, .. }) => true, + (Value::Null, Type { nullable: true, .. }) => true, _ => false, } } |
