From 85ce5c77a71603feadb647b12b1c951499cadc52 Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Tue, 10 Sep 2024 12:09:58 +0200 Subject: [PATCH] chore(store): make the store OVs agnostic Signed-off-by: Antonio Murdaca --- store/src/directory.rs | 5 ++--- store/src/lib.rs | 10 +++------- store/src/pg.rs | 28 ++++++++++++---------------- store/src/sqlite.rs | 28 ++++++++++++---------------- 4 files changed, 29 insertions(+), 42 deletions(-) diff --git a/store/src/directory.rs b/store/src/directory.rs index 71bc0d425..98abf6244 100644 --- a/store/src/directory.rs +++ b/store/src/directory.rs @@ -1,4 +1,3 @@ -use fdo_data_formats::ownershipvoucher::OwnershipVoucher; use std::collections::HashSet; use std::convert::TryInto; use std::fs::{self, File}; @@ -298,7 +297,7 @@ where })) } - async fn query_ovs_db(&self) -> Result, StoreError> { + async fn query_ovs_db(&self) -> Result, StoreError> { Err(StoreError::MethodNotAvailable) } @@ -306,7 +305,7 @@ where &self, _to2: bool, _to0_max: i64, - ) -> Result, StoreError> { + ) -> Result, StoreError> { Err(StoreError::MethodNotAvailable) } diff --git a/store/src/lib.rs b/store/src/lib.rs index 07620b16f..dbcbd3a02 100644 --- a/store/src/lib.rs +++ b/store/src/lib.rs @@ -4,7 +4,7 @@ use core::pin::Pin; use serde::{Deserialize, Serialize}; use thiserror::Error; -use fdo_data_formats::{ownershipvoucher::OwnershipVoucher, Serializable}; +use fdo_data_formats::Serializable; #[derive(Debug, Error)] pub enum StoreError { @@ -190,9 +190,7 @@ pub trait Store: Send + Sync { fn query_ovs_db<'life0, 'async_trait>( &'life0 self, - ) -> Pin< - Box, StoreError>> + 'async_trait + Send>, - > + ) -> Pin, StoreError>> + 'async_trait + Send>> where 'life0: 'async_trait, Self: 'async_trait; @@ -201,9 +199,7 @@ pub trait Store: Send + Sync { &'life0 self, to2: bool, to0_max: i64, - ) -> Pin< - Box, StoreError>> + 'async_trait + Send>, - > + ) -> Pin, StoreError>> + 'async_trait + Send>> where 'life0: 'async_trait, Self: 'async_trait; diff --git a/store/src/pg.rs b/store/src/pg.rs index 833659b5d..777738070 100644 --- a/store/src/pg.rs +++ b/store/src/pg.rs @@ -146,7 +146,7 @@ where Err(StoreError::MethodNotAvailable) } - async fn query_ovs_db(&self) -> Result, StoreError> { + async fn query_ovs_db(&self) -> Result, StoreError> { Err(StoreError::MethodNotAvailable) } @@ -154,7 +154,7 @@ where &self, _to2: bool, _to0_max: i64, - ) -> Result, StoreError> { + ) -> Result, StoreError> { Err(StoreError::MethodNotAvailable) } @@ -332,7 +332,7 @@ where Err(StoreError::MethodNotAvailable) } - async fn query_ovs_db(&self) -> Result, StoreError> { + async fn query_ovs_db(&self) -> Result, StoreError> { let mut ret = vec![]; let conn = &mut self .connection_pool @@ -350,11 +350,9 @@ where )) })?; for db_ov in db_ovs { - ret.push( - OwnershipVoucher::from_pem_or_raw(&db_ov.contents).map_err(|e| { - StoreError::Unspecified(format!("Error parsing OV contents from DB: {e:?}")) - })?, - ); + ret.push(V::deserialize_data(&db_ov.contents).map_err(|e| { + StoreError::Unspecified(format!("Error deserializing value: {e:?}")) + })?); } Ok(ret) } @@ -363,7 +361,7 @@ where &self, to2: bool, to0_max: i64, - ) -> Result, StoreError> { + ) -> Result, StoreError> { let mut ret = vec![]; let conn = &mut self .connection_pool @@ -379,11 +377,9 @@ where )) })?; for db_ov in db_ovs { - ret.push( - OwnershipVoucher::from_pem_or_raw(&db_ov.contents).map_err(|e| { - StoreError::Unspecified(format!("Error parsing OV contents from DB: {e:?}")) - })?, - ); + ret.push(V::deserialize_data(&db_ov.contents).map_err(|e| { + StoreError::Unspecified(format!("Error deserializing value: {e:?}")) + })?); } Ok(ret) } @@ -529,7 +525,7 @@ where Err(StoreError::MethodNotAvailable) } - async fn query_ovs_db(&self) -> Result, StoreError> { + async fn query_ovs_db(&self) -> Result, StoreError> { Err(StoreError::MethodNotAvailable) } @@ -537,7 +533,7 @@ where &self, _to2: bool, _to0_max: i64, - ) -> Result, StoreError> { + ) -> Result, StoreError> { Err(StoreError::MethodNotAvailable) } diff --git a/store/src/sqlite.rs b/store/src/sqlite.rs index 88d350004..b99e5397b 100644 --- a/store/src/sqlite.rs +++ b/store/src/sqlite.rs @@ -147,7 +147,7 @@ where Err(StoreError::MethodNotAvailable) } - async fn query_ovs_db(&self) -> Result, StoreError> { + async fn query_ovs_db(&self) -> Result, StoreError> { Err(StoreError::MethodNotAvailable) } @@ -155,7 +155,7 @@ where &self, _to2: bool, _to0_max: i64, - ) -> Result, StoreError> { + ) -> Result, StoreError> { Err(StoreError::MethodNotAvailable) } @@ -331,7 +331,7 @@ where Err(StoreError::MethodNotAvailable) } - async fn query_ovs_db(&self) -> Result, StoreError> { + async fn query_ovs_db(&self) -> Result, StoreError> { let mut ret = vec![]; let conn = &mut self .connection_pool @@ -348,11 +348,9 @@ where )) })?; for db_ov in db_ovs { - ret.push( - OwnershipVoucher::from_pem_or_raw(&db_ov.contents).map_err(|e| { - StoreError::Unspecified(format!("Error parsing OV contents from DB: {e:?}")) - })?, - ); + ret.push(V::deserialize_data(&db_ov.contents).map_err(|e| { + StoreError::Unspecified(format!("Error deserializing value: {e:?}")) + })?); } Ok(ret) } @@ -361,7 +359,7 @@ where &self, to2: bool, to0_max: i64, - ) -> Result, StoreError> { + ) -> Result, StoreError> { let mut ret = vec![]; let conn = &mut self .connection_pool @@ -376,11 +374,9 @@ where )) })?; for db_ov in db_ovs { - ret.push( - OwnershipVoucher::from_pem_or_raw(&db_ov.contents).map_err(|e| { - StoreError::Unspecified(format!("Error parsing OV contents from DB: {e:?}")) - })?, - ); + ret.push(V::deserialize_data(&db_ov.contents).map_err(|e| { + StoreError::Unspecified(format!("Error deserializing value: {e:?}")) + })?); } Ok(ret) } @@ -526,7 +522,7 @@ where Err(StoreError::MethodNotAvailable) } - async fn query_ovs_db(&self) -> Result, StoreError> { + async fn query_ovs_db(&self) -> Result, StoreError> { Err(StoreError::MethodNotAvailable) } @@ -534,7 +530,7 @@ where &self, _to2: bool, _to0_max: i64, - ) -> Result, StoreError> { + ) -> Result, StoreError> { Err(StoreError::MethodNotAvailable) }