You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: lib.rs
    path of file: ./repos/Theseus/kernel/block_cache/src
    
    the code of the file until where you have to start completion: //! A caching layer for block based storage devices.
//! 
//! For many storage devices, calls to the backing medium are quite expensive. This layer intends to reduce those calls,
//! improving efficiency in exchange for additional memory usage. Note that this crate is intended to be used as a part of
//! `b
    
    fn flush_block(locked_device: &mut dyn StorageDevice, block_num: usize, cached_block: &mut CachedBlock) -> Result<(), &'static str> {
        // we only need to actually write blocks in the `Modified` state.
        match cached_block.state {
            CacheState::Shared | CacheState::Invalid => { },
            CacheState::Modified => {
                locked_device.write_blocks(&cached_block.block, block_num)?;
                cached_block.state = CacheState::Shared;
            }
        }
        Ok(())
    }