MapStateStorage

Trait MapStateStorage 

Source
trait MapStateStorage {
    // Required methods
    fn log_mappable_bytes(&self) -> u8;
    fn get_state(&self, chunk: Address) -> MapState;
    fn bulk_set_state(&self, range: ChunkRange, state: MapState);
    fn bulk_transition_state<F>(
        &self,
        range: ChunkRange,
        update_fn: F,
    ) -> Result<()>
       where F: FnMut(ChunkRange, MapState) -> Result<Option<MapState>>;
}
Expand description

The back-end storage of ChunkStateMmapper. It is responsible for holding the states of each chunk (eagerly or lazily) and transitioning the states in bulk.

Required Methods§

Source

fn log_mappable_bytes(&self) -> u8

The logarithm of the address space size this MapStateStorage can handle.

Source

fn get_state(&self, chunk: Address) -> MapState

Return the state of a given chunk (must be aligned).

Note that all chunks are logically MapState::Unmapped before the states are stored. They include chunks outside the mappable address range.

Source

fn bulk_set_state(&self, range: ChunkRange, state: MapState)

Set all chunks within range to state.

Source

fn bulk_transition_state<F>( &self, range: ChunkRange, update_fn: F, ) -> Result<()>

Visit the chunk states within range and allow the update_fn callback to inspect and change the states.

It visits chunks from low to high addresses, and calls update_fn(group_range, group_state) for each contiguous chunk range group_range that have the same state group_state. update_fn can take actions accordingly and return one of the three values:

  • Err(err): Stop visiting and return Err(err) from bulk_transition_state immediately.
  • Ok(None): Continue visiting the next chunk range without changing chunk states.
  • Ok(Some(new_state)): Set the state of all chunks within group_range to new_state.

Return Ok(()) if finished visiting all chunks normally.

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.

Implementors§