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 execution_in<'work>(
&'work self,
memory: &'work Memory,
) -> Execution<'work>
pub fn execution_in<'work>( &'work self, memory: &'work Memory, ) -> Execution<'work>
Borrows this session’s cumulative work ceiling and a current account.
This creates no reader, allocation or owning account clone. It allows schema scratch to keep the same local ceiling while a reader cursor advances. Selecting an aggregate account does not reset earlier work; existing retained capacity stays with its original storage owner.
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.
Sourcepub fn read_nested_query_in<'a>(
&'a self,
query: &Reader<'a>,
data: &'a [u8],
base: u64,
encoding: Encoding,
outer: u32,
) -> Result<Reader<'a>>
pub fn read_nested_query_in<'a>( &'a self, query: &Reader<'a>, data: &'a [u8], base: u64, encoding: Encoding, outer: u32, ) -> Result<Reader<'a>>
Reads an original source window under the current query’s ceilings.
The original parser, encoding, offsets and inherited depth remain the source’s. Its cumulative limits and the query operation’s limits both apply before work; the current aggregate account is charged once. Further foreign-source transitions retain the same operation owner, rather than accumulating a chain of unrelated source budgets.