Trait building_blocks_storage::chunk::storage::ChunkWriteStorage [−][src]
pub trait ChunkWriteStorage<N, Ch> {
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
fn get_mut_or_insert_with(
&mut self,
key: ChunkKey<N>,
create_chunk: impl FnOnce() -> Ch
) -> &mut Ch
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
.
Replace the chunk at key
with chunk
, returning the old value.
Overwrite the chunk at key
with chunk
. Drops the previous value.