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: file.rs
    path of file: ./repos/CYFS/src/component/cyfs-bdt/src/ndn/chunk/cache/raw_cache
    
    the code of the file until where you have to start completion: use std::{
    sync::{Arc, RwLock}, usize, 
    io::SeekFrom, 
    ops::Range, 
    path::{Path, PathBuf}
};
use async_std::{
    pin::Pin, 
    task::{self, Context, Poll},
    fs
};
use cyfs_base::*;
use cyfs_util::{
    AsyncWriteWithSeek, 
    AsyncReadWithSeek, 
    SyncWriteWithSeek, 
    SyncReadWithSeek
};
use crate::{
    types::*
};
use super::{
    common::*, 
};

enum CacheState
    
    async fn wait_created(&self) -> BuckyResult<async_std::fs::File> {
        let (ret, waiter) = {
            match &mut *self.0.state.write().unwrap() {
                CacheState::Creating(waiters) => (None, Some(waiters.new_waiter())),
                CacheState::Created(file) => (Some(Ok(file.clone())), None), 
                CacheState::Error(err) => (Some(Err(err.clone())), None)
            }
        };
        if let Some(ret) = ret {
            ret 
        } else if let Some(waiter) = waiter {
            StateWaiter::wait(waiter, || {
                match &*self.0.state.read().unwrap() {
                    CacheState::Creating(_) => unreachable!(),
                    CacheState::Created(file) => Ok(file.clone()), 
                    CacheState::Error(err) => Err(err.clone())
                }
            }).await
        } else {
            unreachable!()
        }
    }