From a4b813881a47bb9d8aa528a9598cfdb052ae231e Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Mon, 6 Jan 2025 19:28:41 +0200 Subject: Move primary_key and secondary_keys configuration to Recordable --- log_db/src/record.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'log_db/src/record.rs') 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 { + Vec::new() + } + /// Convert the data structure implementing the `Recordable` trait into a vector of database values. fn into_record(self) -> Vec; /// Convert a vector of database values into the data structure implementing the `Recordable` trait. -- cgit v1.3