aboutsummaryrefslogtreecommitdiffstats
path: root/log_db/src/common.rs
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2024-11-21 12:04:51 +0200
committerJan Tuomi <jan@jantuomi.fi>2024-11-21 12:04:51 +0200
commite89d515f9bc70e937c0183587cba956e207348a0 (patch)
treed1d2130409510846d519247861677d457d1bcf25 /log_db/src/common.rs
parentbfa8fab553eab1b0daa062010fb2ccf5d365d21f (diff)
Add Recordable trait
Diffstat (limited to 'log_db/src/common.rs')
-rw-r--r--log_db/src/common.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/log_db/src/common.rs b/log_db/src/common.rs
index d86e6c6..3590cf9 100644
--- a/log_db/src/common.rs
+++ b/log_db/src/common.rs
@@ -476,6 +476,14 @@ impl Record {
}
}
+/// A trait that describes how to convert a data structure into a database `Record` and vice versa.
+pub trait Recordable {
+ /// Convert the data structure implementing the `Recordable` trait into a database `Record`.
+ fn to_record(&self) -> Record;
+ /// Convert a database `Record` into the data structure implementing the `Recordable` trait.
+ fn from_record(record: &Record) -> Self;
+}
+
pub fn get_secondary_memtable_index_by_field<Field: Eq>(
sks: &Vec<Field>,
field: &Field,