From 8f6026de5ecd44cbe0fc0bcd47638a1ece860439 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 14 Dec 2021 12:34:01 +0100 Subject: Make table name a const in trait --- src/model/block_ref_table.rs | 2 ++ src/model/bucket_table.rs | 2 ++ src/model/garage.rs | 19 ++----------------- src/model/key_table.rs | 2 ++ src/model/object_table.rs | 2 ++ src/model/version_table.rs | 2 ++ 6 files changed, 12 insertions(+), 17 deletions(-) (limited to 'src/model') diff --git a/src/model/block_ref_table.rs b/src/model/block_ref_table.rs index f8f529c4..7dc973d5 100644 --- a/src/model/block_ref_table.rs +++ b/src/model/block_ref_table.rs @@ -44,6 +44,8 @@ pub struct BlockRefTable { } impl TableSchema for BlockRefTable { + const TABLE_NAME: &'static str = "block_ref"; + type P = Hash; type S = Uuid; type E = BlockRef; diff --git a/src/model/bucket_table.rs b/src/model/bucket_table.rs index 168ed713..2cb206ce 100644 --- a/src/model/bucket_table.rs +++ b/src/model/bucket_table.rs @@ -114,6 +114,8 @@ impl Crdt for Bucket { pub struct BucketTable; impl TableSchema for BucketTable { + const TABLE_NAME: &'static str = "bucket"; + type P = EmptyKey; type S = String; type E = Bucket; diff --git a/src/model/garage.rs b/src/model/garage.rs index d12c781f..a874cca8 100644 --- a/src/model/garage.rs +++ b/src/model/garage.rs @@ -93,7 +93,6 @@ impl Garage { meta_rep_param.clone(), system.clone(), &db, - "block_ref".to_string(), ); info!("Initialize version_table..."); @@ -105,7 +104,6 @@ impl Garage { meta_rep_param.clone(), system.clone(), &db, - "version".to_string(), ); info!("Initialize object_table..."); @@ -117,26 +115,13 @@ impl Garage { meta_rep_param, system.clone(), &db, - "object".to_string(), ); info!("Initialize bucket_table..."); - let bucket_table = Table::new( - BucketTable, - control_rep_param.clone(), - system.clone(), - &db, - "bucket".to_string(), - ); + let bucket_table = Table::new(BucketTable, control_rep_param.clone(), system.clone(), &db); info!("Initialize key_table_table..."); - let key_table = Table::new( - KeyTable, - control_rep_param, - system.clone(), - &db, - "key".to_string(), - ); + let key_table = Table::new(KeyTable, control_rep_param, system.clone(), &db); info!("Initialize Garage..."); let garage = Arc::new(Self { diff --git a/src/model/key_table.rs b/src/model/key_table.rs index a6186aa9..225f51c7 100644 --- a/src/model/key_table.rs +++ b/src/model/key_table.rs @@ -120,6 +120,8 @@ pub enum KeyFilter { } impl TableSchema for KeyTable { + const TABLE_NAME: &'static str = "key"; + type P = EmptyKey; type S = String; type E = Key; diff --git a/src/model/object_table.rs b/src/model/object_table.rs index d743a2b6..9eec47ff 100644 --- a/src/model/object_table.rs +++ b/src/model/object_table.rs @@ -217,6 +217,8 @@ pub struct ObjectTable { } impl TableSchema for ObjectTable { + const TABLE_NAME: &'static str = "object"; + type P = String; type S = String; type E = Object; diff --git a/src/model/version_table.rs b/src/model/version_table.rs index bff7d4bb..18ec8e1d 100644 --- a/src/model/version_table.rs +++ b/src/model/version_table.rs @@ -114,6 +114,8 @@ pub struct VersionTable { } impl TableSchema for VersionTable { + const TABLE_NAME: &'static str = "version"; + type P = Hash; type S = EmptyKey; type E = Version; -- cgit v1.2.3