Trait PrintNode

Source
pub trait PrintNode {
    // Required method
    fn write_to_buffer(&self, level: usize, buffer: &mut dyn Write) -> Result;

    // Provided method
    fn print(&self) -> String { ... }
}
Expand description

Trait for printing AST Nodes to a new String allocated on the heap. This is implemented by all AST Nodes and can hence be used to granularly print GraphQL language. However, mostly this will be used via Document::print.

This typically is the last operation that’s done in a given AST context and is hence outside of its lifetime and arena.

For convience when debugging, AST Nodes that implement PrintNode also automatically implement the fmt::Display trait.

Required Methods§

Source

fn write_to_buffer(&self, level: usize, buffer: &mut dyn Write) -> Result

Write an AST node to a buffer implementing the Write trait.

The level indicates the level of nesting, which increases with each SelectionSet and is typically initialized as zero (0).

Provided Methods§

Source

fn print(&self) -> String

Print an AST Node to source text as a String allocated on the heap.

For convience when debugging, AST Nodes that implement PrintNode also automatically implement the fmt::Display trait.

Trait Implementations§

Source§

impl Display for dyn PrintNode

Source§

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

Formats the value using the given formatter. Read more

Implementors§