From 44eb7673fea7cf1a08ad5219153056ec3898544a Mon Sep 17 00:00:00 2001 From: Blake Griffith Date: Sun, 30 Jun 2024 19:50:28 -0700 Subject: [PATCH] Make Storage Send --- src/storage/mod.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/storage/mod.rs b/src/storage/mod.rs index 438a87f..46268ba 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -22,10 +22,10 @@ impl StorageTraits for T {} /// Save data to a desired storage backend. #[derive(Debug)] pub struct Storage { - tree: Box, - data: Box, - bitfield: Box, - oplog: Box, + tree: Box, + data: Box, + bitfield: Box, + oplog: Box, } pub(crate) fn map_random_access_err(err: RandomAccessError) -> HypercoreError { @@ -60,8 +60,9 @@ impl Storage { Store, ) -> std::pin::Pin< Box< - dyn std::future::Future, RandomAccessError>> - + Send, + dyn std::future::Future< + Output = Result, RandomAccessError>, + > + Send, >, >, { @@ -236,7 +237,7 @@ impl Storage { Ok(()) } - fn get_random_access(&mut self, store: &Store) -> &mut Box { + fn get_random_access(&mut self, store: &Store) -> &mut Box { match store { Store::Tree => &mut self.tree, Store::Data => &mut self.data, @@ -249,7 +250,8 @@ impl Storage { #[instrument(err)] pub async fn new_memory() -> Result { let create = |_| { - async { Ok(Box::new(RandomAccessMemory::default()) as Box) }.boxed() + async { Ok(Box::new(RandomAccessMemory::default()) as Box) } + .boxed() }; // No reason to overwrite, as this is a new memory segment Self::open(create, false).await @@ -270,7 +272,7 @@ impl Storage { }; Ok( Box::new(RandomAccessDisk::open(dir.as_path().join(name)).await?) - as Box, + as Box, ) } .boxed()