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: storage.rs
    path of file: ./repos/engula/src/server/src/raftgroup
    
    the code of the file until where you have to start completion: // Copyright 2022 The Engula Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions a
    
    async fn open_empty_raft_storage_after_applying_snapshot() {
        let dir = TempDir::new("open-empty-raft-storage-after-applying-snapshot").unwrap();

        let cfg = Config {
            dir: dir.path().join("db").to_str().unwrap().to_owned(),
            ..Default::default()
        };
        let engine = Arc::new(Engine::open(cfg).unwrap());

        write_initial_state(&RaftConfig::default(), engine.as_ref(), 1, vec![], vec![])
            .await
            .unwrap();

        let snap_mgr = SnapManager::new(dir.path().join("snap"));
        let mut storage = Storage::open(
            &RaftConfig::default(),
            1,
            0,
            ConfState::default(),
            engine.clone(),
            snap_mgr.clone(),
        )
        .await
        .unwrap();

        let snap_index = 123;
        let snap_term = 123;
        let mut task = WriteTask::with_entries(vec![]);
        task.snapshot = Some(Snapshot {
            data: vec![],
            metadata: Some(SnapshotMetadata {
                conf_state: None,
                index: snap_index,
                term: snap_term,
            }),
        });

        let mut lb = LogBatch::default();
        storage.write(&mut lb, &task).unwrap();
        assert_eq!(storage.hard_state.commit, snap_index);
        assert_eq!(storage.truncated_index(), snap_index);
        assert_eq!(storage.truncated_term(), snap_term);
        assert_eq!(storage.first_index, snap_index + 1);
        assert_eq!(storage.last_index, snap_index);
        engine.write(&mut lb, false).unwrap();

        info!("open storage again after applying snapshot");

        // Open storage again.
        drop(storage);
        let storage = Storage::open(
            &RaftConfig::default(),
            1,
            snap_index,
            ConfState::default(),
            engine.clone(),
            snap_mgr,
        )
        .await
        .unwrap();
        assert_eq!(storage.hard_state.commit, snap_index);
        assert_eq!(storage.truncated_index(), snap_index);
        assert_eq!(storage.truncated_term(), snap_term);
        assert_eq!(storage.first_index, snap_index + 1);
        assert_eq!(storage.last_index, snap_index);
    }