From 0d82862d55087f632328e4646cfd6938b813ef15 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Mon, 5 Jun 2023 18:45:19 +0200 Subject: [PATCH] generic GetReconstructPathError --- libs/layer_map/src/lib.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/libs/layer_map/src/lib.rs b/libs/layer_map/src/lib.rs index a03a3adf37..74c5e3a677 100644 --- a/libs/layer_map/src/lib.rs +++ b/libs/layer_map/src/lib.rs @@ -107,6 +107,7 @@ pub trait Types { type HistoricLayer; type InMemoryLayer: InMemoryLayer + Clone; type HistoricStuff: HistoricStuff + Clone; + type GetReconstructPathError; } /// Error returned by [`InMemoryLayer::put`]. @@ -149,9 +150,6 @@ pub trait InMemoryLayer: std::fmt::Debug + Default + Clone { ) -> Vec<::DeltaRecord>; } -#[derive(Debug, thiserror::Error)] -pub enum GetReconstructPathError {} - /// The manager of [`Types::HistoricLayer`]s. pub trait HistoricStuff { type Types: Types; @@ -159,7 +157,10 @@ pub trait HistoricStuff { &self, key: ::Key, lsn: ::Lsn, - ) -> Result::HistoricLayer>, GetReconstructPathError>; + ) -> Result< + Vec<::HistoricLayer>, + ::GetReconstructPathError, + >; /// Produce a new version of `self` that includes the given inmem layer. fn make_historic(&self, inmem: ::InMemoryLayer) -> Self; } @@ -208,11 +209,11 @@ pub fn new(lsn: T::LsnCounter, historic: T::HistoricStuff) -> (Reader< /// Error returned by the get-page operations. #[derive(Debug, thiserror::Error)] -pub enum GetError { +pub enum GetError { #[error(transparent)] - SeqWait(#[from] seqwait::SeqWaitError), + SeqWait(seqwait::SeqWaitError), #[error(transparent)] - GetReconstructPath(#[from] GetReconstructPathError), + GetReconstructPath(T::GetReconstructPathError), } /// Self-contained set of objects required to reconstruct a page image for the given `key` @ `lsn`. @@ -234,7 +235,7 @@ impl Reader { /// This is the `GetPage@LSN` operation. /// /// See the [`crate`]-level docs for why we return [`ReconstructWork`] instead of a Page Image here. - pub async fn get(&self, key: T::Key, lsn: T::Lsn) -> Result, GetError> { + pub async fn get(&self, key: T::Key, lsn: T::Lsn) -> Result, GetError> { // XXX dedup with Writer::get_nowait let state = self.wait.wait_for(lsn).await?; let inmem_records = state @@ -364,7 +365,7 @@ impl Writer { &self, key: T::Key, lsn: T::Lsn, - ) -> Result, GetError> { + ) -> Result, GetError> { // XXX dedup with Reader::get let state = self .advance