aboutsummaryrefslogtreecommitdiffstats
path: root/log_db/src/record.rs
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-01-06 19:28:41 +0200
committerJan Tuomi <jan@jantuomi.fi>2025-01-06 19:34:51 +0200
commita4b813881a47bb9d8aa528a9598cfdb052ae231e (patch)
treef9a57b5049a69b6272c5da90a9abdb0d6ff17607 /log_db/src/record.rs
parent21d0b647d6916c4dbbde8a310a0760872d44f7a2 (diff)
Move primary_key and secondary_keys configuration to Recordable
Diffstat (limited to 'log_db/src/record.rs')
-rw-r--r--log_db/src/record.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/log_db/src/record.rs b/log_db/src/record.rs
index 1b882ed..8d518f0 100644
--- a/log_db/src/record.rs
+++ b/log_db/src/record.rs
@@ -104,8 +104,15 @@ impl Record {
pub trait Recordable {
/// The field type of the data structure implementing the `Recordable` trait.
type Field: Eq + Clone + Debug;
- /// Define the schema of the data structure implementing the `Recordable` trait.
+ /// Define the schema of the instance implementing the `Recordable` trait.
fn schema() -> Vec<(Self::Field, ValueType)>;
+ /// 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.
+ fn secondary_keys() -> Vec<Self::Field> {
+ Vec::new()
+ }
+
/// Convert the data structure implementing the `Recordable` trait into a vector of database values.
fn into_record(self) -> Vec<Value>;
/// Convert a vector of database values into the data structure implementing the `Recordable` trait.