pub struct SimpleComplexityAnalyzer { /* private fields */ }Expand description
Lightweight complexity analyzer driven by SimpleCostRules.
Implementations§
Source§impl SimpleComplexityAnalyzer
impl SimpleComplexityAnalyzer
Sourcepub fn with_default_cost(self, cost: usize) -> Self
pub fn with_default_cost(self, cost: usize) -> Self
Override the default cost for fields without an explicit rule.
Sourcepub fn add_rule(&mut self, rule: SimpleCostRule)
pub fn add_rule(&mut self, rule: SimpleCostRule)
Register a field rule.
Sourcepub fn cost_for_field(&self, name: &str, args: &HashMap<String, usize>) -> usize
pub fn cost_for_field(&self, name: &str, args: &HashMap<String, usize>) -> usize
Cost for a single field + its args.
Sourcepub fn analyze_fields(
&self,
fields: &[QueryField],
) -> (usize, Vec<(String, usize)>)
pub fn analyze_fields( &self, fields: &[QueryField], ) -> (usize, Vec<(String, usize)>)
Analyse the given list of top-level fields and return total cost + per-field breakdown.
Sourcepub fn is_within_limit(&self, fields: &[QueryField]) -> bool
pub fn is_within_limit(&self, fields: &[QueryField]) -> bool
Returns true when query cost is within the limit.
Auto Trait Implementations§
impl Freeze for SimpleComplexityAnalyzer
impl RefUnwindSafe for SimpleComplexityAnalyzer
impl Send for SimpleComplexityAnalyzer
impl Sync for SimpleComplexityAnalyzer
impl Unpin for SimpleComplexityAnalyzer
impl UnsafeUnpin for SimpleComplexityAnalyzer
impl UnwindSafe for SimpleComplexityAnalyzer
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more