Struct ComposedVisitor

Source
pub struct ComposedVisitor<'a, Context, A: Visitor<'a, Context>, B: Visitor<'a, Context>> {
    pub a: A,
    pub b: B,
    /* private fields */
}
Expand description

This structure implements the Visitor trait and runs two child Visitors in parallel, executing and calling callbacks on them both.

During traversal the Composed Visitor will keep track of the visitor’s VisitFlow signals and will avoid calling callbacks on them appropriately, while letting the other visitor continue as usual. In short, this visitor aims to minimize the work it does while preserving expected behavior.

Visitors may be composed indefinitely since a Composed Visitor can be passed into another Composed Visitor, as long as all visitors accept the same Context type.

Fields§

§a: A§b: B

Implementations§

Source§

impl<'a, C, A: Visitor<'a, C>, B: Visitor<'a, C>> ComposedVisitor<'a, C, A, B>

Source

pub fn new(a: A, b: B) -> ComposedVisitor<'a, C, A, B>

Composes two input visitors into one Composed Visitor.

Trait Implementations§

Source§

impl<'a, A, B> Default for ComposedVisitor<'a, ValidationContext<'a>, A, B>
where A: ValidationRule<'a>, B: ValidationRule<'a>,

Source§

fn default() -> Self

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

impl<'a, A, B> ValidationRule<'a> for ComposedVisitor<'a, ValidationContext<'a>, A, B>
where A: ValidationRule<'a>, B: ValidationRule<'a>,

Source§

fn validate(ctx: &'a ASTContext, document: &'a Document<'a>) -> Result<()>

Run this ValidationRule against the given document and return a result which errors if the rule fails on the document.
Source§

impl<'a, C, A: Visitor<'a, C>, B: Visitor<'a, C>> Visitor<'a, C> for ComposedVisitor<'a, C, A, B>

Source§

fn enter_document( &mut self, ctx: &mut C, document: &'a Document<'a>, info: &VisitInfo, ) -> VisitFlow

Called when a Document is visited and before its child nodes are visited.
Source§

fn leave_document( &mut self, ctx: &mut C, document: &'a Document<'a>, info: &VisitInfo, ) -> VisitFlow

Called after a Document and its child nodes were visited.
Source§

fn enter_operation( &mut self, ctx: &mut C, operation: &'a OperationDefinition<'a>, info: &VisitInfo, ) -> VisitFlow

Called when an OperationDefinition node is visited and before its child nodes are visited.
Source§

fn leave_operation( &mut self, ctx: &mut C, operation: &'a OperationDefinition<'a>, info: &VisitInfo, ) -> VisitFlow

Called after an OperationDefinition and its child node were visited.
Source§

fn enter_fragment( &mut self, ctx: &mut C, fragment: &'a FragmentDefinition<'a>, info: &VisitInfo, ) -> VisitFlow

Called when a FragmentDefinition node is visited and before its child nodes are visited.
Source§

fn leave_fragment( &mut self, ctx: &mut C, fragment: &'a FragmentDefinition<'a>, info: &VisitInfo, ) -> VisitFlow

Called after a FragmentDefinition node and its child nodes were visited.
Source§

fn enter_variable_definition( &mut self, ctx: &mut C, var_def: &'a VariableDefinition<'a>, info: &VisitInfo, ) -> VisitFlow

Called when a VariableDefinition node is visited and before its child nodes are visited.
Source§

fn leave_variable_definition( &mut self, ctx: &mut C, var_def: &'a VariableDefinition<'a>, info: &VisitInfo, ) -> VisitFlow

Called after a VariableDefinition node and its child nodes were visited.
Source§

fn enter_selection_set( &mut self, ctx: &mut C, selection_set: &'a SelectionSet<'a>, info: &VisitInfo, ) -> VisitFlow

Called when a SelectionSet node is visited and before its child nodes are visited.
Source§

fn leave_selection_set( &mut self, ctx: &mut C, selection_set: &'a SelectionSet<'a>, info: &VisitInfo, ) -> VisitFlow

Called after a SelectionSet node and its child nodes were visited.
Source§

fn enter_fragment_spread( &mut self, ctx: &mut C, fragment_spread: &'a FragmentSpread<'a>, info: &VisitInfo, ) -> VisitFlow

Called when a FragmentSpread node is visited and before its child nodes are visited.
Source§

fn leave_fragment_spread( &mut self, ctx: &mut C, fragment_spread: &'a FragmentSpread<'a>, info: &VisitInfo, ) -> VisitFlow

Called after a FragmentSpread node and its child nodes were visited.
Source§

fn enter_inline_fragment( &mut self, ctx: &mut C, inline_fragment: &'a InlineFragment<'a>, info: &VisitInfo, ) -> VisitFlow

Called when an InlineFragment node is visited and before its child nodes are visited.
Source§

fn leave_inline_fragment( &mut self, ctx: &mut C, inline_fragment: &'a InlineFragment<'a>, info: &VisitInfo, ) -> VisitFlow

Called after an InlineFragment node and its child nodes were visited.
Source§

fn enter_field( &mut self, ctx: &mut C, field: &'a Field<'a>, info: &VisitInfo, ) -> VisitFlow

Called when a Field node is visited and before its child nodes are visited.
Source§

fn leave_field( &mut self, ctx: &mut C, field: &'a Field<'a>, info: &VisitInfo, ) -> VisitFlow

Called after a Field node and its child nodes were visited.
Source§

fn enter_directive( &mut self, ctx: &mut C, directive: &'a Directive<'a>, info: &VisitInfo, ) -> VisitFlow

Called when a Directive node is visited and before its child nodes are visited.
Source§

fn leave_directive( &mut self, ctx: &mut C, directive: &'a Directive<'a>, info: &VisitInfo, ) -> VisitFlow

Called after a Directive node and its child nodes were visited.
Source§

fn enter_argument( &mut self, ctx: &mut C, argument: &'a Argument<'a>, info: &VisitInfo, ) -> VisitFlow

Called when an Argument node is visited and before its child nodes are visited.
Source§

fn leave_argument( &mut self, ctx: &mut C, argument: &'a Argument<'a>, info: &VisitInfo, ) -> VisitFlow

Called after an Argument node and its child nodes were visited.
Source§

fn compose<V: Visitor<'a, Context>>( self, other: V, ) -> ComposedVisitor<'a, Context, Self, V>

Combines two visitors into one that will run both the original and passed visitor concurrently. Read more

Auto Trait Implementations§

§

impl<'a, Context, A, B> Freeze for ComposedVisitor<'a, Context, A, B>
where A: Freeze, B: Freeze,

§

impl<'a, Context, A, B> RefUnwindSafe for ComposedVisitor<'a, Context, A, B>
where A: RefUnwindSafe, B: RefUnwindSafe, Context: RefUnwindSafe,

§

impl<'a, Context, A, B> Send for ComposedVisitor<'a, Context, A, B>
where A: Send, B: Send, Context: Sync,

§

impl<'a, Context, A, B> Sync for ComposedVisitor<'a, Context, A, B>
where A: Sync, B: Sync, Context: Sync,

§

impl<'a, Context, A, B> Unpin for ComposedVisitor<'a, Context, A, B>
where A: Unpin, B: Unpin,

§

impl<'a, Context, A, B> UnwindSafe for ComposedVisitor<'a, Context, A, B>
where A: UnwindSafe, B: UnwindSafe, Context: RefUnwindSafe,

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 = 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 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.