pub struct LimitTracker {
    pub high: usize,
    pub limit: usize,
    /* private fields */
}
Expand description

A LimitTracker enforces a particular limit within the parser. It keeps track of utilization so that we can report how close to a limit we approached over the lifetime of the tracker.

use apollo_parser::Parser;

let query = "
{
    animal
    ...snackSelection
    ... on Pet {
      playmates {
        count
      }
    }
}
";
// Create a new instance of a parser given a query and a
// recursion limit
let parser = Parser::new(query).recursion_limit(4);
// Parse the query, and return a SyntaxTree.
let ast = parser.parse();
// Retrieve the limits
let usage = ast.recursion_limit();
// Print out some of the usage details to see what happened during
// our parse. `limit` just reports the limit we set, `high` is the
// high-water mark of recursion usage.
println!("{:?}", usage);
println!("{:?}", usage.limit);
println!("{:?}", usage.high);
// Check that are no errors. These are not part of the AST.
assert_eq!(0, ast.errors().len());

// Get the document root node
let doc = ast.document();
// ... continue

Fields§

§high: usize

High Water mark for this limit

§limit: usize

Limit.

Implementations§

source§

impl LimitTracker

source

pub fn new(limit: usize) -> Self

source

pub fn limited(&self) -> bool

source

pub fn consume(&mut self)

source

pub fn reset(&mut self)

Trait Implementations§

source§

impl Clone for LimitTracker

source§

fn clone(&self) -> LimitTracker

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for LimitTracker

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for LimitTracker

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl PartialEq<LimitTracker> for LimitTracker

source§

fn eq(&self, other: &LimitTracker) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for LimitTracker

source§

impl Eq for LimitTracker

source§

impl StructuralEq for LimitTracker

source§

impl StructuralPartialEq for LimitTracker

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.