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: chain_store.rs
    path of file: ./repos/holochain-rust/crates/core/src/agent
    
    the code of the file until where you have to start completion: use crate::content_store::{AddContent, GetContent};
use globset::{GlobBuilder, GlobSetBuilder};
use holochain_core_types::{
    chain_header::ChainHeader,
    entry::entry_type::EntryType,
    error::{
        HcResult,
        RibosomeErrorCode::{self, *},
    },
};
use holochain_locksmith::RwLock;
use holochain_persistence_api::cas::{
    content::{Address, AddressableContent, Content},
    storage::ContentAddressableStorage,
};
use std::{str
    
    fn next(&mut self) -> Option<ChainHeader> {
        let previous = self.current.take();
        let storage = &self.content_storage.clone();
        self.current = previous
            .as_ref()
            .and_then(|chain_header| chain_header.link())
            .as_ref()
            // @TODO should this panic?
            // @see https://github.com/holochain/holochain-rust/issues/146
            .and_then(|linked_chain_header_address| {
                storage
                    .read()
                    .unwrap()
                    .fetch(linked_chain_header_address)
                    .expect("failed to fetch from CAS")
                    .map(|content| {
                        ChainHeader::try_from_content(&content)
                            .expect("failed to load ChainHeader from Content")
                    })
            });
        previous
    }