Skip to main content

parse

Function parse 

Source
pub fn parse(
    reader: &mut impl BufRead,
    format: InputFormat,
    items_path: Option<&str>,
) -> Result<ParsedInput, FaceError>
Expand description

Parse the input as the chosen format and locate the items array.

The caller has already run crate::input::sniff::sniff_format and consumed the BOM. items_path overrides automatic items detection per §4.2 — when Some(path), the parser resolves it via path::resolve before returning items.

§Errors

§Examples

use std::io::BufReader;
use face_core::input::parse;
use face_core::InputFormat;

let mut r = BufReader::new(b"[1, 2, 3]" as &[u8]);
let parsed = parse(&mut r, InputFormat::Json, None).unwrap();
assert_eq!(parsed.items.len(), 3);
assert!(parsed.skips.is_empty());