1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#[macro_use]
extern crate nom;

use std::io::{Read};
use std::fs::File;
use std::path::Path;

mod error;
pub use error::Error;

pub type Result<T> = ::std::result::Result<T, Error>;

pub mod reader;
pub use reader::Reader;

mod entry;
pub use entry::{Table, Entry, Statement, Value};

pub mod parser;

/// Create a reader from the given path.
pub fn open<P: AsRef<Path>>(path: P) -> Result<Reader<File>> {
	Ok(Reader::from(try!(File::open(path))))
}

/// Create a reader from the given stream.
pub fn read<R: Read>(stream: R) -> Result<Reader<R>> {
	Ok(Reader::from(stream))
}

/// Load a table from the given path.
pub fn load<P: AsRef<Path>>(path: P) -> Result<Entry> {
	Ok(try!(Table::load(&mut try!(open(path)))).into())
}