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 SyncChunkPut::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 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> 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>
Source§impl<const BODY_SIZE: usize> Default for MemoryStore<BODY_SIZE>
impl<const BODY_SIZE: usize> Default for MemoryStore<BODY_SIZE>
Source§impl<const BODY_SIZE: usize> SyncChunkGet<BODY_SIZE> for MemoryStore<BODY_SIZE>
impl<const BODY_SIZE: usize> SyncChunkGet<BODY_SIZE> for MemoryStore<BODY_SIZE>
Source§impl<const BODY_SIZE: usize> SyncChunkHas<BODY_SIZE> for MemoryStore<BODY_SIZE>
impl<const BODY_SIZE: usize> SyncChunkHas<BODY_SIZE> for MemoryStore<BODY_SIZE>
Source§fn has(&self, address: &ChunkAddress) -> bool
fn has(&self, address: &ChunkAddress) -> bool
Check if a chunk exists.
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 BS: usize> ChunkHas<BS> for T
impl<T, const BS: usize> ChunkHas<BS> for T
Source§async fn has(&self, address: &SwarmAddress) -> bool
async fn has(&self, address: &SwarmAddress) -> bool
Check if a chunk exists.
Source§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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T, const BODY_SIZE: usize> SyncChunkGetExt<BODY_SIZE> for Twhere
T: SyncChunkGet<BODY_SIZE>,
impl<T, const BODY_SIZE: usize> SyncChunkGetExt<BODY_SIZE> for Twhere
T: SyncChunkGet<BODY_SIZE>,
Source§impl<T, const BODY_SIZE: usize> SyncChunkPutExt<BODY_SIZE> for Twhere
T: SyncChunkPut<BODY_SIZE>,
impl<T, const BODY_SIZE: usize> SyncChunkPutExt<BODY_SIZE> for Twhere
T: SyncChunkPut<BODY_SIZE>,
Source§fn writer(&self, size: u64) -> SyncSplitter<&Self, BODY_SIZE>where
Self: Sized,
fn writer(&self, size: u64) -> SyncSplitter<&Self, BODY_SIZE>where
Self: Sized,
Create a writer for streaming data. Returns a
SyncSplitter implementing Write.
Call .finish() on the returned writer to get the root address.Source§fn encrypted_writer(&self, size: u64) -> EncryptedSyncSplitter<&Self, BODY_SIZE>where
Self: Sized,
fn encrypted_writer(&self, size: u64) -> EncryptedSyncSplitter<&Self, BODY_SIZE>where
Self: Sized,
Create an encrypted writer. Returns an
EncryptedSyncSplitter implementing Write.Source§fn write_file(&self, data: &[u8]) -> Result<ChunkAddress>
fn write_file(&self, data: &[u8]) -> Result<ChunkAddress>
Write file data into the store (like
fs::write).Source§fn write_encrypted_file(&self, data: &[u8]) -> Result<EncryptedChunkRef>
fn write_encrypted_file(&self, data: &[u8]) -> Result<EncryptedChunkRef>
Write encrypted file data into the store.