From 29cc3cbd90076d1756313459c09b2f5aebf593ae Mon Sep 17 00:00:00 2001 From: Blake Griffith Date: Thu, 27 Jun 2024 23:24:58 -0700 Subject: [PATCH 1/4] Remove generic from Storage Replaces generic usage on storage with trait objects Add dummy field to Hypercore so we can remove it's generic in a seperate commit --- benches/memory.rs | 8 ++++++- examples/disk.rs | 5 ++-- examples/memory.rs | 3 ++- src/builder.rs | 18 ++++++-------- src/core.rs | 6 +++-- src/lib.rs | 2 +- src/storage/mod.rs | 60 +++++++++++++++++++++++++--------------------- tests/core.rs | 9 +++---- tests/model.rs | 3 ++- 9 files changed, 64 insertions(+), 50 deletions(-) diff --git a/benches/memory.rs b/benches/memory.rs index b439b1e..2323391 100644 --- a/benches/memory.rs +++ b/benches/memory.rs @@ -22,8 +22,14 @@ fn bench_create_memory(c: &mut Criterion) { async fn create_hypercore( page_size: usize, ) -> Result, HypercoreError> { + use hypercore::StorageTraits; + let storage = Storage::open( - |_| Box::pin(async move { Ok(RandomAccessMemory::new(page_size)) }), + |_| { + Box::pin(async move { + Ok(Box::new(RandomAccessMemory::new(page_size)) as Box) + }) + }, false, ) .await?; diff --git a/examples/disk.rs b/examples/disk.rs index 9999089..ccd1c7e 100644 --- a/examples/disk.rs +++ b/examples/disk.rs @@ -1,6 +1,7 @@ #[cfg(feature = "async-std")] use async_std::main as async_main; use hypercore::{HypercoreBuilder, HypercoreError, Storage}; +use random_access_memory::RandomAccessMemory; use tempfile::Builder; #[cfg(feature = "tokio")] use tokio::main as async_main; @@ -24,7 +25,7 @@ async fn main() { // Build a new disk hypercore let mut hypercore = HypercoreBuilder::new(storage) - .build() + .build::() .await .expect("Could not create disk hypercore"); @@ -43,7 +44,7 @@ async fn main() { .expect("Could not open existing disk storage"); let mut hypercore = HypercoreBuilder::new(storage) .open(true) - .build() + .build::() .await .expect("Could not open disk hypercore"); diff --git a/examples/memory.rs b/examples/memory.rs index a510ed6..15ae4cf 100644 --- a/examples/memory.rs +++ b/examples/memory.rs @@ -1,6 +1,7 @@ #[cfg(feature = "async-std")] use async_std::main as async_main; use hypercore::{HypercoreBuilder, HypercoreError, Storage}; +use random_access_memory::RandomAccessMemory; #[cfg(feature = "tokio")] use tokio::main as async_main; @@ -14,7 +15,7 @@ async fn main() { // Build hypercore let mut hypercore = HypercoreBuilder::new(storage) - .build() + .build::() .await .expect("Could not create memory hypercore"); diff --git a/src/builder.rs b/src/builder.rs index 4e18dad..dfece90 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -53,20 +53,14 @@ impl CacheOptionsBuilder { /// Build a Hypercore instance with options. #[derive(Debug)] -pub struct HypercoreBuilder -where - T: RandomAccess + Debug + Send, -{ - storage: Storage, +pub struct HypercoreBuilder { + storage: Storage, options: HypercoreOptions, } -impl HypercoreBuilder -where - T: RandomAccess + Debug + Send, -{ +impl HypercoreBuilder { /// Create a hypercore builder with a given storage - pub fn new(storage: Storage) -> Self { + pub fn new(storage: Storage) -> Self { Self { storage, options: HypercoreOptions::new(), @@ -94,7 +88,9 @@ where /// Build a new Hypercore. #[instrument(err, skip_all)] - pub async fn build(self) -> Result, HypercoreError> { + pub async fn build( + self, + ) -> Result, HypercoreError> { Hypercore::new(self.storage, self.options).await } } diff --git a/src/core.rs b/src/core.rs index fe49e9a..9de0bef 100644 --- a/src/core.rs +++ b/src/core.rs @@ -45,13 +45,14 @@ where T: RandomAccess + Debug, { pub(crate) key_pair: PartialKeypair, - pub(crate) storage: Storage, + pub(crate) storage: Storage, pub(crate) oplog: Oplog, pub(crate) tree: MerkleTree, pub(crate) block_store: BlockStore, pub(crate) bitfield: Bitfield, skip_flush_count: u8, // autoFlush in Javascript header: Header, + _foo: Option, } /// Response from append, matches that of the Javascript result @@ -85,7 +86,7 @@ where { /// Creates/opens new hypercore using given storage and options pub(crate) async fn new( - mut storage: Storage, + mut storage: Storage, mut options: HypercoreOptions, ) -> Result, HypercoreError> { let key_pair: Option = if options.open { @@ -254,6 +255,7 @@ where bitfield, header, skip_flush_count: 0, + _foo: None, }) } diff --git a/src/lib.rs b/src/lib.rs index a403e38..24d8627 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -94,7 +94,7 @@ pub use crate::common::{ }; pub use crate::core::{AppendOutcome, Hypercore, Info}; pub use crate::crypto::{generate_signing_key, sign, verify, PartialKeypair}; -pub use crate::storage::Storage; +pub use crate::storage::{Storage, StorageTraits}; pub use ed25519_dalek::{ SecretKey, Signature, SigningKey, VerifyingKey, KEYPAIR_LENGTH, PUBLIC_KEY_LENGTH, SECRET_KEY_LENGTH, diff --git a/src/storage/mod.rs b/src/storage/mod.rs index 7eb3776..6ed4966 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -15,16 +15,17 @@ use crate::{ HypercoreError, }; +/// rmme +pub trait StorageTraits: RandomAccess + Debug {} +impl StorageTraits for T {} + /// Save data to a desired storage backend. #[derive(Debug)] -pub struct Storage -where - T: RandomAccess + Debug, -{ - tree: T, - data: T, - bitfield: T, - oplog: T, +pub struct Storage { + tree: Box, + data: Box, + bitfield: Box, + oplog: Box, } pub(crate) fn map_random_access_err(err: RandomAccessError) -> HypercoreError { @@ -51,17 +52,17 @@ pub(crate) fn map_random_access_err(err: RandomAccessError) -> HypercoreError { } } -impl Storage -where - T: RandomAccess + Debug + Send, -{ +impl Storage { /// Create a new instance. Takes a callback to create new storage instances and overwrite flag. pub async fn open(create: Cb, overwrite: bool) -> Result where Cb: Fn( Store, ) -> std::pin::Pin< - Box> + Send>, + Box< + dyn std::future::Future, RandomAccessError>> + + Send, + >, >, { let mut tree = create(Store::Tree).await.map_err(map_random_access_err)?; @@ -235,7 +236,7 @@ where Ok(()) } - fn get_random_access(&mut self, store: &Store) -> &mut T { + fn get_random_access(&mut self, store: &Store) -> &mut Box { match store { Store::Tree => &mut self.tree, Store::Data => &mut self.data, @@ -243,31 +244,36 @@ where Store::Oplog => &mut self.oplog, } } -} -impl Storage { /// New storage backed by a `RandomAccessMemory` instance. #[instrument(err)] pub async fn new_memory() -> Result { - let create = |_| async { Ok(RandomAccessMemory::default()) }.boxed(); + let create = |_| { + 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 } -} -#[cfg(not(target_arch = "wasm32"))] -impl Storage { /// New storage backed by a `RandomAccessDisk` instance. + #[cfg(not(target_arch = "wasm32"))] #[instrument(err)] pub async fn new_disk(dir: &PathBuf, overwrite: bool) -> Result { let storage = |store: Store| { - let name = match store { - Store::Tree => "tree", - Store::Data => "data", - Store::Bitfield => "bitfield", - Store::Oplog => "oplog", - }; - RandomAccessDisk::open(dir.as_path().join(name)).boxed() + let dir = dir.clone(); + async move { + let name = match store { + Store::Tree => "tree", + Store::Data => "data", + Store::Bitfield => "bitfield", + Store::Oplog => "oplog", + }; + Ok( + Box::new(RandomAccessDisk::open(dir.as_path().join(name)).await?) + as Box, + ) + } + .boxed() }; Self::open(storage, overwrite).await } diff --git a/tests/core.rs b/tests/core.rs index f3e8d2e..c6b42b7 100644 --- a/tests/core.rs +++ b/tests/core.rs @@ -2,7 +2,8 @@ pub mod common; use anyhow::Result; use common::{create_hypercore, get_test_key_pair, open_hypercore, storage_contains_data}; -use hypercore::{HypercoreBuilder, Storage}; +use hypercore::{Hypercore, HypercoreBuilder, Storage}; +use random_access_memory::RandomAccessMemory; use tempfile::Builder; use test_log::test; @@ -14,7 +15,7 @@ use tokio::test as async_test; #[test(async_test)] async fn hypercore_new() -> Result<()> { let storage = Storage::new_memory().await?; - let _hypercore = HypercoreBuilder::new(storage).build(); + let _hypercore = HypercoreBuilder::new(storage).build::(); Ok(()) } @@ -22,7 +23,7 @@ async fn hypercore_new() -> Result<()> { async fn hypercore_new_with_key_pair() -> Result<()> { let storage = Storage::new_memory().await?; let key_pair = get_test_key_pair(); - let _hypercore = HypercoreBuilder::new(storage) + let _hypercore: Hypercore = HypercoreBuilder::new(storage) .key_pair(key_pair) .build() .await?; @@ -36,7 +37,7 @@ async fn hypercore_open_with_key_pair_error() -> Result<()> { assert!(HypercoreBuilder::new(storage) .key_pair(key_pair) .open(true) - .build() + .build::() .await .is_err()); Ok(()) diff --git a/tests/model.rs b/tests/model.rs index e6a52fe..3f81ead 100644 --- a/tests/model.rs +++ b/tests/model.rs @@ -3,6 +3,7 @@ pub mod common; use proptest::prelude::*; use proptest::test_runner::FileFailurePersistence; use proptest_derive::Arbitrary; +use random_access_memory::RandomAccessMemory; const MAX_FILE_SIZE: u64 = 50000; @@ -66,7 +67,7 @@ async fn assert_implementation_matches_model(ops: Vec) -> bool { .await .expect("Memory storage creation should be successful"); let mut hypercore = HypercoreBuilder::new(storage) - .build() + .build::() .await .expect("Hypercore creation should be successful"); From 7d404ddaa6029822dcd6e45b7523648cec0d7195 Mon Sep 17 00:00:00 2001 From: Blake Griffith Date: Fri, 28 Jun 2024 18:08:27 -0700 Subject: [PATCH 2/4] Remove generic param from Hypercore --- benches/disk.rs | 5 ++--- benches/memory.rs | 16 +++++++++------- examples/disk.rs | 5 ++--- examples/memory.rs | 3 +-- examples/replication.rs | 6 ++---- src/builder.rs | 5 +---- src/core.rs | 22 +++++----------------- tests/common/mod.rs | 5 ++--- tests/core.rs | 9 ++++----- tests/model.rs | 3 +-- 10 files changed, 29 insertions(+), 50 deletions(-) diff --git a/benches/disk.rs b/benches/disk.rs index 326f57b..a1ad5b7 100644 --- a/benches/disk.rs +++ b/benches/disk.rs @@ -4,7 +4,6 @@ use std::time::{Duration, Instant}; use criterion::async_executor::AsyncStdExecutor; use criterion::{black_box, criterion_group, criterion_main, Criterion}; use hypercore::{Hypercore, HypercoreBuilder, HypercoreError, Storage}; -use random_access_disk::RandomAccessDisk; use tempfile::Builder as TempfileBuilder; fn bench_create_disk(c: &mut Criterion) { @@ -24,7 +23,7 @@ fn bench_create_disk(c: &mut Criterion) { } #[cfg(feature = "cache")] -async fn create_hypercore(name: &str) -> Result, HypercoreError> { +async fn create_hypercore(name: &str) -> Result { let dir = TempfileBuilder::new() .prefix(name) .tempdir() @@ -38,7 +37,7 @@ async fn create_hypercore(name: &str) -> Result, Hyp } #[cfg(not(feature = "cache"))] -async fn create_hypercore(name: &str) -> Result, HypercoreError> { +async fn create_hypercore(name: &str) -> Result { let dir = TempfileBuilder::new() .prefix(name) .tempdir() diff --git a/benches/memory.rs b/benches/memory.rs index 2323391..bb97685 100644 --- a/benches/memory.rs +++ b/benches/memory.rs @@ -19,9 +19,7 @@ fn bench_create_memory(c: &mut Criterion) { } #[cfg(feature = "cache")] -async fn create_hypercore( - page_size: usize, -) -> Result, HypercoreError> { +async fn create_hypercore(page_size: usize) -> Result { use hypercore::StorageTraits; let storage = Storage::open( @@ -40,11 +38,15 @@ async fn create_hypercore( } #[cfg(not(feature = "cache"))] -async fn create_hypercore( - page_size: usize, -) -> Result, HypercoreError> { +async fn create_hypercore(page_size: usize) -> Result { + use hypercore::StorageTraits; + let storage = Storage::open( - |_| Box::pin(async move { Ok(RandomAccessMemory::new(page_size)) }), + |_| { + Box::pin(async move { + Ok(Box::new(RandomAccessMemory::new(page_size)) as Box) + }) + }, false, ) .await?; diff --git a/examples/disk.rs b/examples/disk.rs index ccd1c7e..9999089 100644 --- a/examples/disk.rs +++ b/examples/disk.rs @@ -1,7 +1,6 @@ #[cfg(feature = "async-std")] use async_std::main as async_main; use hypercore::{HypercoreBuilder, HypercoreError, Storage}; -use random_access_memory::RandomAccessMemory; use tempfile::Builder; #[cfg(feature = "tokio")] use tokio::main as async_main; @@ -25,7 +24,7 @@ async fn main() { // Build a new disk hypercore let mut hypercore = HypercoreBuilder::new(storage) - .build::() + .build() .await .expect("Could not create disk hypercore"); @@ -44,7 +43,7 @@ async fn main() { .expect("Could not open existing disk storage"); let mut hypercore = HypercoreBuilder::new(storage) .open(true) - .build::() + .build() .await .expect("Could not open disk hypercore"); diff --git a/examples/memory.rs b/examples/memory.rs index 15ae4cf..a510ed6 100644 --- a/examples/memory.rs +++ b/examples/memory.rs @@ -1,7 +1,6 @@ #[cfg(feature = "async-std")] use async_std::main as async_main; use hypercore::{HypercoreBuilder, HypercoreError, Storage}; -use random_access_memory::RandomAccessMemory; #[cfg(feature = "tokio")] use tokio::main as async_main; @@ -15,7 +14,7 @@ async fn main() { // Build hypercore let mut hypercore = HypercoreBuilder::new(storage) - .build::() + .build() .await .expect("Could not create memory hypercore"); diff --git a/examples/replication.rs b/examples/replication.rs index 52c205a..0e658cd 100644 --- a/examples/replication.rs +++ b/examples/replication.rs @@ -4,8 +4,6 @@ use hypercore::{ Hypercore, HypercoreBuilder, HypercoreError, PartialKeypair, RequestBlock, RequestUpgrade, Storage, }; -use random_access_disk::RandomAccessDisk; -use random_access_memory::RandomAccessMemory; use tempfile::Builder; #[cfg(feature = "tokio")] use tokio::main as async_main; @@ -73,8 +71,8 @@ async fn main() { } async fn replicate_index( - origin_hypercore: &mut Hypercore, - replicated_hypercore: &mut Hypercore, + origin_hypercore: &mut Hypercore, + replicated_hypercore: &mut Hypercore, request_index: u64, ) { let missing_nodes = origin_hypercore diff --git a/src/builder.rs b/src/builder.rs index dfece90..37af78e 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -1,4 +1,3 @@ -use random_access_storage::RandomAccess; use std::fmt::Debug; #[cfg(feature = "cache")] use std::time::Duration; @@ -88,9 +87,7 @@ impl HypercoreBuilder { /// Build a new Hypercore. #[instrument(err, skip_all)] - pub async fn build( - self, - ) -> Result, HypercoreError> { + pub async fn build(self) -> Result { Hypercore::new(self.storage, self.options).await } } diff --git a/src/core.rs b/src/core.rs index 9de0bef..886ff98 100644 --- a/src/core.rs +++ b/src/core.rs @@ -1,7 +1,6 @@ //! Hypercore's main abstraction. Exposes an append-only, secure log structure. use ed25519_dalek::Signature; use futures::future::Either; -use random_access_storage::RandomAccess; use std::convert::TryFrom; use std::fmt::Debug; use tracing::instrument; @@ -40,10 +39,7 @@ impl HypercoreOptions { /// Hypercore is an append-only log structure. #[derive(Debug)] -pub struct Hypercore -where - T: RandomAccess + Debug, -{ +pub struct Hypercore { pub(crate) key_pair: PartialKeypair, pub(crate) storage: Storage, pub(crate) oplog: Oplog, @@ -52,7 +48,6 @@ where pub(crate) bitfield: Bitfield, skip_flush_count: u8, // autoFlush in Javascript header: Header, - _foo: Option, } /// Response from append, matches that of the Javascript result @@ -80,15 +75,12 @@ pub struct Info { pub writeable: bool, } -impl Hypercore -where - T: RandomAccess + Debug + Send, -{ +impl Hypercore { /// Creates/opens new hypercore using given storage and options pub(crate) async fn new( mut storage: Storage, mut options: HypercoreOptions, - ) -> Result, HypercoreError> { + ) -> Result { let key_pair: Option = if options.open { if options.key_pair.is_some() { return Err(HypercoreError::BadArgument { @@ -255,7 +247,6 @@ where bitfield, header, skip_flush_count: 0, - _foo: None, }) } @@ -736,7 +727,6 @@ fn update_contiguous_length( #[cfg(test)] mod tests { use super::*; - use random_access_memory::RandomAccessMemory; #[async_std::test] async fn core_create_proof_block_only() -> Result<(), HypercoreError> { @@ -1101,9 +1091,7 @@ mod tests { Ok(()) } - async fn create_hypercore_with_data( - length: u64, - ) -> Result, HypercoreError> { + async fn create_hypercore_with_data(length: u64) -> Result { let signing_key = generate_signing_key(); create_hypercore_with_data_and_key_pair( length, @@ -1118,7 +1106,7 @@ mod tests { async fn create_hypercore_with_data_and_key_pair( length: u64, key_pair: PartialKeypair, - ) -> Result, HypercoreError> { + ) -> Result { let storage = Storage::new_memory().await?; let mut hypercore = Hypercore::new( storage, diff --git a/tests/common/mod.rs b/tests/common/mod.rs index fbe8616..247b13c 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,6 +1,5 @@ use anyhow::Result; use ed25519_dalek::{SigningKey, VerifyingKey, PUBLIC_KEY_LENGTH, SECRET_KEY_LENGTH}; -use random_access_disk::RandomAccessDisk; use sha2::{Digest, Sha256}; use std::io::prelude::*; use std::path::Path; @@ -35,7 +34,7 @@ pub fn get_test_key_pair() -> PartialKeypair { PartialKeypair { public, secret } } -pub async fn create_hypercore(work_dir: &str) -> Result> { +pub async fn create_hypercore(work_dir: &str) -> Result { let path = Path::new(work_dir).to_owned(); let key_pair = get_test_key_pair(); let storage = Storage::new_disk(&path, true).await?; @@ -45,7 +44,7 @@ pub async fn create_hypercore(work_dir: &str) -> Result Result> { +pub async fn open_hypercore(work_dir: &str) -> Result { let path = Path::new(work_dir).to_owned(); let storage = Storage::new_disk(&path, false).await?; Ok(HypercoreBuilder::new(storage).open(true).build().await?) diff --git a/tests/core.rs b/tests/core.rs index c6b42b7..f3e8d2e 100644 --- a/tests/core.rs +++ b/tests/core.rs @@ -2,8 +2,7 @@ pub mod common; use anyhow::Result; use common::{create_hypercore, get_test_key_pair, open_hypercore, storage_contains_data}; -use hypercore::{Hypercore, HypercoreBuilder, Storage}; -use random_access_memory::RandomAccessMemory; +use hypercore::{HypercoreBuilder, Storage}; use tempfile::Builder; use test_log::test; @@ -15,7 +14,7 @@ use tokio::test as async_test; #[test(async_test)] async fn hypercore_new() -> Result<()> { let storage = Storage::new_memory().await?; - let _hypercore = HypercoreBuilder::new(storage).build::(); + let _hypercore = HypercoreBuilder::new(storage).build(); Ok(()) } @@ -23,7 +22,7 @@ async fn hypercore_new() -> Result<()> { async fn hypercore_new_with_key_pair() -> Result<()> { let storage = Storage::new_memory().await?; let key_pair = get_test_key_pair(); - let _hypercore: Hypercore = HypercoreBuilder::new(storage) + let _hypercore = HypercoreBuilder::new(storage) .key_pair(key_pair) .build() .await?; @@ -37,7 +36,7 @@ async fn hypercore_open_with_key_pair_error() -> Result<()> { assert!(HypercoreBuilder::new(storage) .key_pair(key_pair) .open(true) - .build::() + .build() .await .is_err()); Ok(()) diff --git a/tests/model.rs b/tests/model.rs index 3f81ead..e6a52fe 100644 --- a/tests/model.rs +++ b/tests/model.rs @@ -3,7 +3,6 @@ pub mod common; use proptest::prelude::*; use proptest::test_runner::FileFailurePersistence; use proptest_derive::Arbitrary; -use random_access_memory::RandomAccessMemory; const MAX_FILE_SIZE: u64 = 50000; @@ -67,7 +66,7 @@ async fn assert_implementation_matches_model(ops: Vec) -> bool { .await .expect("Memory storage creation should be successful"); let mut hypercore = HypercoreBuilder::new(storage) - .build::() + .build() .await .expect("Hypercore creation should be successful"); From 61423de6d66a73447b35b9144408d5fa612d1151 Mon Sep 17 00:00:00 2001 From: Blake Griffith Date: Fri, 28 Jun 2024 18:58:54 -0700 Subject: [PATCH 3/4] Document StorageTraits --- src/storage/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/mod.rs b/src/storage/mod.rs index 6ed4966..438a87f 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -15,7 +15,7 @@ use crate::{ HypercoreError, }; -/// rmme +/// Supertrait for Storage pub trait StorageTraits: RandomAccess + Debug {} impl StorageTraits for T {} From 44eb7673fea7cf1a08ad5219153056ec3898544a Mon Sep 17 00:00:00 2001 From: Blake Griffith Date: Sun, 30 Jun 2024 19:50:28 -0700 Subject: [PATCH 4/4] 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()