1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
use std::fs::read_to_string; use std::path::Path; use crate::parse_vojaq; use crate::VojaqSet; /// Extract the content of a Vojaq file into a VojaqSet. /// /// The Vojaq file must represent a valid Vojaq set and /// be encoded in UTF-8. pub fn read_file<P>(path: P) -> Result<VojaqSet, Box<dyn std::error::Error>> where P: AsRef<Path> { let content = read_to_string(path)?; // Remove the UTF-8 BOM if any. let content = if content.starts_with("\u{FEFF}") { &content[3..] } else { &content[..] }; Ok(parse_vojaq(content)?) }