pub struct Parser { /* private fields */ }Expand description
Holds the budget for one parse and hands out readers that share it.
Implementations§
Source§impl Parser
impl Parser
Sourcepub fn new(encoding: Encoding, limits: Limits, memory: Memory) -> Self
pub fn new(encoding: Encoding, limits: Limits, memory: Memory) -> Self
A parser for one document, in one encoding, with one budget.
Sourcepub fn memory(&self) -> &Memory
pub fn memory(&self) -> &Memory
The aggregate account shared with other parsers and retained results.
Limits.max_work additionally bounds this parser’s scanning, not later
owned-result processing. Memory’s cumulative work bounds the whole domain.
Sourcepub fn read<'a>(&'a self, data: &'a [u8], base: u64) -> Result<Reader<'a>>
pub fn read<'a>(&'a self, data: &'a [u8], base: u64) -> Result<Reader<'a>>
A reader over data, whose first byte sits at base in the document.
base is what makes an error’s offset and an element’s span mean
something to a caller holding a whole document while handing this parser
a window into it.
Refused when the end of data would not fit an offset. Checking that
here is what lets every offset computed while reading be ordinary
arithmetic: each is at most base + data.len().
Sourcepub fn read_as<'a>(
&'a self,
data: &'a [u8],
base: u64,
encoding: Encoding,
) -> Result<Reader<'a>>
pub fn read_as<'a>( &'a self, data: &'a [u8], base: u64, encoding: Encoding, ) -> Result<Reader<'a>>
A reader over data under a chosen encoding, sharing this parser’s
budget.
For a window whose schema fixes its encoding regardless of what this parser was built for: the value of a certificate extension is DER even when the parser was made lenient for the envelope the certificate arrived in.
Sourcepub fn read_nested<'a>(
&'a self,
data: &'a [u8],
base: u64,
encoding: Encoding,
outer: u32,
) -> Result<Reader<'a>>
pub fn read_nested<'a>( &'a self, data: &'a [u8], base: u64, encoding: Encoding, outer: u32, ) -> Result<Reader<'a>>
A reader over bytes another element carries as its value, one level below the reader that element was found in.
For an encoding wrapped in a primitive, an octet string above all: a
certificate extension’s value, a signed message’s content. outer is
Reader::depth of the reader the carrying element came from. A
reader made with Parser::read_as would count the wrapped structure
from the top again, and a caller’s depth ceiling would bound each
wrapping rather than the document.
§Errors
ErrorCode::LimitExceeded where the level is past the depth
ceiling, and what Parser::read_as refuses.
Sourcepub fn read_nested_in<'a>(
&'a self,
data: &'a [u8],
base: u64,
encoding: Encoding,
outer: u32,
execution: &Memory,
) -> Result<Reader<'a>>
pub fn read_nested_in<'a>( &'a self, data: &'a [u8], base: u64, encoding: Encoding, outer: u32, execution: &Memory, ) -> Result<Reader<'a>>
Nested lazy reader using the current execution domain from creation.
Original offsets, depth and this parser session’s cumulative ceilings
remain in force. New storage and deferred work use execution.