ChunkWriteStorage

Trait ChunkWriteStorage 

Source
pub trait ChunkWriteStorage<N, Ch> {
    // Required methods
    fn get_mut(&mut self, key: ChunkKey<N>) -> Option<&mut Ch>;
    fn get_mut_or_insert_with(
        &mut self,
        key: ChunkKey<N>,
        create_chunk: impl FnOnce() -> Ch,
    ) -> &mut Ch;
    fn replace(&mut self, key: ChunkKey<N>, chunk: Ch) -> Option<Ch>;
    fn write(&mut self, key: ChunkKey<N>, chunk: Ch);
    fn delete(&mut self, key: ChunkKey<N>);
    fn pop(&mut self, key: ChunkKey<N>) -> Option<Ch>;
}
Expand description

Methods for writing chunks from storage.

Required Methods§

Source

fn get_mut(&mut self, key: ChunkKey<N>) -> Option<&mut Ch>

Mutably borrow the chunk at key.

Source

fn get_mut_or_insert_with( &mut self, key: ChunkKey<N>, create_chunk: impl FnOnce() -> Ch, ) -> &mut Ch

Mutably borrow the chunk at key. If it doesn’t exist, insert the return value of create_chunk.

Source

fn replace(&mut self, key: ChunkKey<N>, chunk: Ch) -> Option<Ch>

Replace the chunk at key with chunk, returning the old value.

Source

fn write(&mut self, key: ChunkKey<N>, chunk: Ch)

Overwrite the chunk at key with chunk. Drops the previous value.

Source

fn delete(&mut self, key: ChunkKey<N>)

Removes and drops the chunk at key.

Source

fn pop(&mut self, key: ChunkKey<N>) -> Option<Ch>

Removes and returns the chunk at key.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a, N, Ch, T> ChunkWriteStorage<N, Ch> for &'a mut T
where T: 'a + ChunkWriteStorage<N, Ch> + ?Sized,

Source§

fn get_mut(&mut self, key: ChunkKey<N>) -> Option<&mut Ch>

Source§

fn get_mut_or_insert_with( &mut self, key: ChunkKey<N>, create_chunk: impl FnOnce() -> Ch, ) -> &mut Ch

Source§

fn replace(&mut self, key: ChunkKey<N>, chunk: Ch) -> Option<Ch>

Source§

fn write(&mut self, key: ChunkKey<N>, chunk: Ch)

Source§

fn delete(&mut self, key: ChunkKey<N>)

Source§

fn pop(&mut self, key: ChunkKey<N>) -> Option<Ch>

Source§

impl<N, Ch> ChunkWriteStorage<N, Ch> for AHashMap<ChunkKey<N>, Ch>
where ChunkKey<N>: Hash + Eq,

Source§

fn get_mut(&mut self, key: ChunkKey<N>) -> Option<&mut Ch>

Source§

fn get_mut_or_insert_with( &mut self, key: ChunkKey<N>, create_chunk: impl FnOnce() -> Ch, ) -> &mut Ch

Source§

fn replace(&mut self, key: ChunkKey<N>, chunk: Ch) -> Option<Ch>

Source§

fn write(&mut self, key: ChunkKey<N>, chunk: Ch)

Source§

fn delete(&mut self, key: ChunkKey<N>)

Source§

fn pop(&mut self, key: ChunkKey<N>) -> Option<Ch>

Implementors§

Source§

impl<N, Compr> ChunkWriteStorage<N, <Compr as Compression>::Data> for CompressibleChunkStorage<N, Compr>
where ChunkKey<N>: Clone + Eq + Hash, Compr: Compression,