Skip to main content

from_reader

Function from_reader 

Source
pub fn from_reader<R: Read + Seek>(reader: R) -> Result<VersionReader<R>>
Expand description

Reads a BDAT file from a std::io::Read implementation. That type must also implement std::io::Seek.

Version and endianness will be automatically detected. To force a different endianness and/or version, use the specialized functions from bdat::legacy and bdat::modern.

This function will only read the file header. To parse tables, call BdatFile::get_tables.

The BDAT file format is not recommended for streams, so it is best to read from a file or a byte buffer.

use std::fs::File;
use bdat::{BdatFile, BdatResult, SwitchEndian};

fn read_file(name: &str) -> BdatResult<()> {
    let file = File::open(name)?;
    let tables = bdat::from_reader(file)?.get_tables()?;
    Ok(())
}