pub fn load_fixture<T: DeserializeOwned>(path: PathBuf) -> Result<T, Error> {
    let file = File::open(&path)?;
    let buffered_reader = BufReader::new(file);

    let fixture = match path.extension().and_then(OsStr::to_str) {
        Some(extension) if extension.to_ascii_lowercase() == JSON_FILE_EXT => {
            serde_json::from_reader(buffered_reader)?
        }
        Some(_) => return Err(Error::UnsupportedFormat(path)),
        None => return Err(Error::NoExtension(path)),
    };
    Ok(fixture)
}
/// Loads a generic test fixture from a file with a reader based on a file extension.
///
/// Currently only JSON files are supported.
Loads a generic test fixture from a file with a reader based on a file extension.
Currently only JSON files are supported.
Loads a generic test fixture from a file with a reader based on a file extension . Currently only JSON files are supported .
pub fn load_fixture<T: DeserializeOwned>(path: PathBuf) -> Result<T, Error> {
    let file = File::open(&path)?;
    let buffered_reader = BufReader::new(file);
    let fixture = match path.extension().and_then(OsStr::to_str) {
        Some(extension) if extension.to_ascii_lowercase() == JSON_FILE_EXT => {
            serde_json::from_reader(buffered_reader)?
        }
        Some(_) => return Err(Error::UnsupportedFormat(path)),
        None => return Err(Error::NoExtension(path)),
    };
    Ok(fixture)
}
pub fn load_fixture < T : DeserializeOwned > ( path : PathBuf ) -> Result < T , Error > { let file = File :: open ( & path ) ? ; let buffered_reader = BufReader :: new ( file ) ; let fixture = match path . extension ( ) . and_then ( OsStr :: to_str ) { Some ( extension ) if extension . to_ascii_lowercase ( ) == JSON_FILE_EXT => { serde_json :: from_reader ( buffered_reader ) ? } Some ( _ ) => return Err ( Error :: UnsupportedFormat ( path ) ) , None => return Err ( Error :: NoExtension ( path ) ) , } ; Ok ( fixture ) }
Loads a generic test fixture from a file with a reader based on a file extension.
Loads a generic test fixture from a file with a reader based on a file extension .
path
PathBuf
path
PathBuf