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: sv.rs
    path of file: ./repos/KuiBaDB/src/access
    
    the code of the file until where you have to start completion: // Copyright 2020 <盏一 w@hidva.com>
// 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 and
// limitations under the License.
use crate::access::ckpt::PendingFileOps;
use crate::access::wal::{self, Lsn, RmgrId};
use crate::access::xact::SessionExt as xactSessionExt;
use crate::utils::marc::{Destory, Marc};
use crate::utils::sb::{self, SharedBuffer};
use crate::utils::{persist, ser, SessionState};
use crate::{FileId, Oid};
use anyhow::ensure;
use byteorder::{NativeEndian, ReadBytesExt};
use std::fs::{self, OpenOptions};
use std::io::{Cursor, Seek, SeekFrom};
use std::mem::{self, size_of, size_of_val};
use std::sync::atomic::{AtomicBool, Ordering::Relaxed};

struct L0File {
    meta: FileMeta,
    inuse: AtomicBool,
}

impl std::clone::Clone for L0File {
    fn clone(&self) -> Self {
        Self {
            meta: self.meta,
            inuse: AtomicBool::new(self.inuse.load(Relaxed)),
        }
    }
}

impl L0File
    
fn read_manifest(path: &str, enable_cs_wal: bool) -> anyhow::Result<SupVer> {
    let mdata = fs::read(path)?;
    let mdata: &[u8] = &mdata;
    ensure!(
        mdata.len() >= size_of_val(&INIT_MANIFEST_DAT),
        "read_manifest: invalid manifest: path={} mdata={:?}",
        path,
        mdata
    );

    let crcidx = mdata.len() - size_of::<u32>();
    let expect_crc = crc32c::crc32c(&mdata[..crcidx]);

    let mut cursor = Cursor::new(mdata);
    cursor.seek(SeekFrom::Start(crcidx as u64))?;
    let actual_crc = cursor.read_u32::<NativeEndian>()?;
    ensure!(
        actual_crc == expect_crc,
        "read_manifest failed. path={} expect_crc={} actual_crc={}",
        path,
        expect_crc,
        actual_crc
    );

    cursor.seek(SeekFrom::Start(0))?;
    let ver = cursor.read_u32::<NativeEndian>()?;
    ensure!(
        ver == MANIFEST_VER,
        "read_manifest failed. path={} expect_ver={} actual_ver={}",
        path,
        MANIFEST_VER,
        ver
    );

    let lsn = Lsn::new(cursor.read_u64::<NativeEndian>()?);

    let mut newestid = 0u32;
    let l0files = read_level_files(&mut cursor, |fileid, filelen, rownum| {
        if fileid > newestid {
            newestid = fileid;
        }
        L0File {
            meta: FileMeta::new(FileId::new(fileid).unwrap(), rownum, filelen),
            inuse: AtomicBool::new(false),
        }
    })?;
    let l1files = read_level_files(&mut cursor, |fileid, filelen, rownum| {
        if fileid > newestid {
            newestid = fileid;
        }
        Marc::new(ImmFile {
            fileid: FileId::new(fileid).unwrap(),
            len: filelen,
            rownum,
        })
    })?;
    let l2files = read_level_files(&mut cursor, |fileid, filelen, rownum| {
        if fileid > newestid {
            newestid = fileid;
        }
        Marc::new(ImmFile {
            fileid: FileId::new(fileid).unwrap(),
            len: filelen,
            rownum,
        })
    })?;
    let nextid = newestid + 1;
    ensure!(nextid != 0, "read_manifest: nextid is 0. path={}", path);
    return Ok(SupVer {
        l0: l0files,
        l1: l1files,
        l2: l2files,
        nextid,
        lsn,
        enable_cs_wal,
    });
}