pub fn parse_object<R: Resolve + ?Sized>(
lx: &mut Lexer<'_>,
limits: &Limits,
diags: &mut Diagnostics,
strictness: Strictness,
store: &R,
) -> Result<Object, Error>Expand description
Parse one object body at the lexer’s position.
This is the entry point every other layer uses; depth is the nesting
already spent, which the caller threads so that an object stream’s members
share the file parse’s budget rather than getting a fresh one.
§Errors
Error::NoObject when the bytes are not an object at all — which is
also how composite parses learn they have reached their closing bracket —
and Error::TooDeep when this object is itself nested past
limits.max_object_nesting. A composite containing something too deep
does not fail: it drops what it could not read.
use pdfrum_common::{Diagnostics, Limits};
use pdfrum_object::{NoResolve, Object};
use pdfrum_parser::{Lexer, Strictness, parse_object};
let limits = Limits::default();
let mut diags = Diagnostics::default();
let mut lx = Lexer::new(b"<< /Type /Page /Count 3 >>");
let obj = parse_object(&mut lx, &limits, &mut diags, Strictness::Loose, &NoResolve)?;
let dict = obj.as_dict().expect("a dictionary");
assert_eq!(dict.int(pdfrum_object::names::COUNT, &NoResolve), Some(3));