pub struct MemoryStore<const BODY_SIZE: usize = DEFAULT_BODY_SIZE> { /* private fields */ }Expand description
In-memory chunk storage using a RwLock<HashMap>.
Uses interior mutability so ChunkPut::put(&self) works without
external synchronization.
Implementations§
Source§impl<const BODY_SIZE: usize> MemoryStore<BODY_SIZE>
impl<const BODY_SIZE: usize> MemoryStore<BODY_SIZE>
Sourcepub fn from_chunks(
chunks: impl IntoIterator<Item = AnyChunk<BODY_SIZE>>,
) -> Self
pub fn from_chunks( chunks: impl IntoIterator<Item = AnyChunk<BODY_SIZE>>, ) -> Self
Build a store from a collection of chunks, keyed by address.
Sourcepub fn get(&self, address: &ChunkAddress) -> Option<AnyChunk<BODY_SIZE>>
pub fn get(&self, address: &ChunkAddress) -> Option<AnyChunk<BODY_SIZE>>
Get a cloned chunk by address.
Sourcepub fn into_chunks(self) -> HashMap<ChunkAddress, AnyChunk<BODY_SIZE>>
pub fn into_chunks(self) -> HashMap<ChunkAddress, AnyChunk<BODY_SIZE>>
Consume the store and return all chunks.
Trait Implementations§
Source§impl<const BODY_SIZE: usize> ChunkGet<BODY_SIZE> for MemoryStore<BODY_SIZE>
impl<const BODY_SIZE: usize> ChunkGet<BODY_SIZE> for MemoryStore<BODY_SIZE>
Source§impl<const BODY_SIZE: usize> ChunkHas<BODY_SIZE> for MemoryStore<BODY_SIZE>
impl<const BODY_SIZE: usize> ChunkHas<BODY_SIZE> for MemoryStore<BODY_SIZE>
Source§async fn has(&self, address: &ChunkAddress) -> bool
async fn has(&self, address: &ChunkAddress) -> bool
Check if a chunk exists.
Source§impl<const BODY_SIZE: usize> ChunkPut<BODY_SIZE> for MemoryStore<BODY_SIZE>
impl<const BODY_SIZE: usize> ChunkPut<BODY_SIZE> for MemoryStore<BODY_SIZE>
Source§impl<const BODY_SIZE: usize> Clone for MemoryStore<BODY_SIZE>
impl<const BODY_SIZE: usize> Clone for MemoryStore<BODY_SIZE>
Source§impl<const BODY_SIZE: usize> Debug for MemoryStore<BODY_SIZE>
impl<const BODY_SIZE: usize> Debug for MemoryStore<BODY_SIZE>
Auto Trait Implementations§
impl<const BODY_SIZE: usize = DEFAULT_BODY_SIZE> !Freeze for MemoryStore<BODY_SIZE>
impl<const BODY_SIZE: usize = DEFAULT_BODY_SIZE> !RefUnwindSafe for MemoryStore<BODY_SIZE>
impl<const BODY_SIZE: usize> Send for MemoryStore<BODY_SIZE>
impl<const BODY_SIZE: usize> Sync for MemoryStore<BODY_SIZE>
impl<const BODY_SIZE: usize> Unpin for MemoryStore<BODY_SIZE>
impl<const BODY_SIZE: usize> UnsafeUnpin for MemoryStore<BODY_SIZE>
impl<const BODY_SIZE: usize> UnwindSafe for MemoryStore<BODY_SIZE>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T, const BODY_SIZE: usize> ChunkGetExt<BODY_SIZE> for Twhere
T: ChunkGet<BODY_SIZE>,
impl<T, const BODY_SIZE: usize> ChunkGetExt<BODY_SIZE> for Twhere
T: ChunkGet<BODY_SIZE>,
Source§impl<T, const BODY_SIZE: usize> ChunkPutExt<BODY_SIZE> for Twhere
T: ChunkPut<BODY_SIZE>,
impl<T, const BODY_SIZE: usize> ChunkPutExt<BODY_SIZE> for Twhere
T: ChunkPut<BODY_SIZE>,
Source§fn write_file<D: ReadAt + Sync>(
&self,
data: D,
) -> impl Future<Output = Result<ChunkAddress>> + MaybeSend
fn write_file<D: ReadAt + Sync>( &self, data: D, ) -> impl Future<Output = Result<ChunkAddress>> + MaybeSend
Split
data and store every produced chunk, returning the root address. Read moreSource§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more