Skip to main content

Parser

Struct Parser 

Source
pub struct Parser { /* private fields */ }
Expand description

Holds the budget for one parse and hands out readers that share it.

Implementations§

Source§

impl Parser

Source

pub fn new(encoding: Encoding, limits: Limits, memory: Memory) -> Self

A parser for one document, in one encoding, with one budget.

Source

pub fn der(memory: Memory) -> Self

A parser for DER, with the default budget.

Source

pub fn ber(memory: Memory) -> Self

A parser that also accepts the BER forms CMS permits.

Source

pub fn limits(&self) -> Limits

The limits this parser was given.

Source

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.

Source

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.

Source

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().

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Parser

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Parser

§

impl !RefUnwindSafe for Parser

§

impl !Sync for Parser

§

impl Send for Parser

§

impl Unpin for Parser

§

impl UnsafeUnpin for Parser

§

impl UnwindSafe for Parser

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.