aboutsummaryrefslogtreecommitdiffstats
path: root/log_db/src/record.rs
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-01-17 15:43:52 +0200
committerJan Tuomi <jan@jantuomi.fi>2025-01-17 15:57:37 +0200
commit75a9d560a69312bcf4dd0b9d3f00564a78e7c120 (patch)
treef1a6ba1ae39a73a2fcf4b9bd137144cd9247a63e /log_db/src/record.rs
parent98430c35eeb27b1bb3c7ac7a9e30a6918514358a (diff)
Refactor public interface
Diffstat (limited to 'log_db/src/record.rs')
-rw-r--r--log_db/src/record.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/log_db/src/record.rs b/log_db/src/record.rs
index cbb1faa..a464520 100644
--- a/log_db/src/record.rs
+++ b/log_db/src/record.rs
@@ -49,7 +49,7 @@ impl Record {
&self.values[index]
}
- pub fn validate<Field: Eq>(&self, schema: &Vec<(Field, ValueType)>) -> DBResult<()> {
+ pub fn validate<Field: Eq>(&self, schema: &Vec<(Field, Type)>) -> DBResult<()> {
// Validate the record length
if self.values.len() != schema.len() {
return Err(DBError::ValidationError(format!(
@@ -64,36 +64,36 @@ impl Record {
match (&self.values[i], field) {
(
Value::Null,
- ValueType {
+ Type {
nullable: true,
- prim_value_type: _,
+ primitive: _,
},
) => {}
(
Value::Int(_),
- ValueType {
- prim_value_type: PrimValueType::Int,
+ Type {
+ primitive: PrimitiveType::Int,
..
},
) => {}
(
Value::String(_),
- ValueType {
- prim_value_type: PrimValueType::String,
+ Type {
+ primitive: PrimitiveType::String,
..
},
) => {}
(
Value::Bytes(_),
- ValueType {
- prim_value_type: PrimValueType::Bytes,
+ Type {
+ primitive: PrimitiveType::Bytes,
..
},
) => {}
_ => {
return Err(DBError::ValidationError(format!(
"Record field {} has incorrect type: {:?}, expected {:?}",
- &i, &self.values[i], &field.prim_value_type
+ &i, &self.values[i], &field.primitive
)));
}
}
@@ -107,7 +107,7 @@ pub trait Recordable {
/// The field type of the data structure implementing the `Recordable` trait.
type Field: Eq + Clone + Debug;
/// Define the schema of the instance implementing the `Recordable` trait.
- fn schema() -> Vec<(Self::Field, ValueType)>;
+ fn schema() -> Vec<(Self::Field, Type)>;
/// Define the primary key of the instance implementing the `Recordable` trait.
fn primary_key() -> Self::Field;
/// Define the secondary keys of the instance implementing the `Recordable` trait.