Trait Formatter

Source
pub trait Formatter {
Show 35 methods // Provided methods fn write_raw<W>(&mut self, writer: &mut W, fragment: &str) -> Result<()> where W: ?Sized + Write { ... } fn write_keyword<W>(&mut self, writer: &mut W, name: &str) -> Result<()> where W: ?Sized + Write { ... } fn write_separator<W>(&mut self, writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn before_operation_or_fragment_definition<W>( &mut self, _writer: &mut W, ) -> Result<()> where W: ?Sized + Write { ... } fn before_operation_variable_definitions<W>( &mut self, _writer: &mut W, ) -> Result<()> where W: ?Sized + Write { ... } fn after_operation_or_fragment_signature<W>( &mut self, _writer: &mut W, ) -> Result<()> where W: ?Sized + Write { ... } fn after_selection_signature<W>(&mut self, _writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn before_type_condition<W>(&mut self, _writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn before_directive<W>(&mut self, _writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn write_string_fragment<W>( &mut self, writer: &mut W, fragment: &str, ) -> Result<()> where W: ?Sized + Write { ... } fn begin_variable<W>(&mut self, writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn write_non_null_type_indicator<W>(&mut self, writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn begin_directive<W>(&mut self, writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn write_name_value_separator<W>(&mut self, writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn write_variable_default_value_separator<W>( &mut self, writer: &mut W, ) -> Result<()> where W: ?Sized + Write { ... } fn write_item_separator<W>(&mut self, writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn begin_parentheses<W>(&mut self, writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn end_parentheses<W>(&mut self, writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn begin_block<W>(&mut self, writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn end_block<W>(&mut self, writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn before_block_item<W>(&mut self, _writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn after_block_item<W>(&mut self, writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn begin_string<W>(&mut self, writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn end_string<W>(&mut self, writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn begin_array<W>(&mut self, writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn end_array<W>(&mut self, writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn write_byte_array<W>( &mut self, writer: &mut W, value: &[u8], ) -> Result<()> where W: ?Sized + Write { ... } fn begin_object<W>(&mut self, writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn end_object<W>(&mut self, writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn write_null<W>(&mut self, writer: &mut W) -> Result<()> where W: ?Sized + Write { ... } fn write_bool<W>(&mut self, writer: &mut W, value: bool) -> Result<()> where W: ?Sized + Write { ... } fn write_u8<W>(&mut self, writer: &mut W, value: u8) -> Result<()> where W: ?Sized + Write { ... } fn write_u64<W>(&mut self, writer: &mut W, value: u64) -> Result<()> where W: ?Sized + Write { ... } fn write_i64<W>(&mut self, writer: &mut W, value: i64) -> Result<()> where W: ?Sized + Write { ... } fn write_f64<W>(&mut self, writer: &mut W, value: f64) -> Result<()> where W: ?Sized + Write { ... }
}
Expand description

A trait for writing GraphQL documents.

Provided Methods§

Source

fn write_raw<W>(&mut self, writer: &mut W, fragment: &str) -> Result<()>
where W: ?Sized + Write,

Writes a raw GraphQL fragment that doesn’t need escaping to the writer.

Source

fn write_keyword<W>(&mut self, writer: &mut W, name: &str) -> Result<()>
where W: ?Sized + Write,

Source

fn write_separator<W>(&mut self, writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Writes a whitespace separator to the specified writer.

This is used to separate different parts of the GraphQL query, For example:

  • To separate the operation type keyword from the name:

    query MyQuery { ... }
         ^
         |
         This is a separator
  • Or to separate the fragment name from the fragment definition, or the fragment type condition keyword from the type name.

    fragment MyFragment on MyType { ... }
            ^             ^
            |             |
            |             This is a separator
            This is a separator
Source

fn before_operation_or_fragment_definition<W>( &mut self, _writer: &mut W, ) -> Result<()>
where W: ?Sized + Write,

Source

fn before_operation_variable_definitions<W>( &mut self, _writer: &mut W, ) -> Result<()>
where W: ?Sized + Write,

Source

fn after_operation_or_fragment_signature<W>( &mut self, _writer: &mut W, ) -> Result<()>
where W: ?Sized + Write,

Called after writing the operation name and/or arguments.

Source

fn after_selection_signature<W>(&mut self, _writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Source

fn before_type_condition<W>(&mut self, _writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Source

fn before_directive<W>(&mut self, _writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Source

fn write_string_fragment<W>( &mut self, writer: &mut W, fragment: &str, ) -> Result<()>
where W: ?Sized + Write,

Writes a string fragment that doesn’t need any escaping to the specified writer.

Source

fn begin_variable<W>(&mut self, writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Writes a $ to the specified writer.

This must be called before writing a variable name.

Source

fn write_non_null_type_indicator<W>(&mut self, writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Writes a ! to the specified writer.

This must be called after writing a variable type name.

Source

fn begin_directive<W>(&mut self, writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Writes a @ to the specified writer.

This must be called before writing a directive name.

Source

fn write_name_value_separator<W>(&mut self, writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Writes a : to the specified writer.

Source

fn write_variable_default_value_separator<W>( &mut self, writer: &mut W, ) -> Result<()>
where W: ?Sized + Write,

Writes a = to the specified writer.

This is used to separate the name of a variable from its default value.

Source

fn write_item_separator<W>(&mut self, writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Writes a , to the specified writer.

For example, this is used to separate items in a list (arguments, variable definitions, etc.), or to separate key-value pairs in an object value.

query MyQuery($var1: String, $var2: Int) { ... }
                           ^
                           |
                         This is an item separator
query MyQuery { field1(arg1: [1, 2, 3]) { ... } }
                               ^  ^
                               |  |
                               |  This is an item separator
                              This is an item separator
Source

fn begin_parentheses<W>(&mut self, writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Writes a ( to the specified writer.

Source

fn end_parentheses<W>(&mut self, writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Writes a ) to the specified writer.

Source

fn begin_block<W>(&mut self, writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Writes a { to the specified writer.

Source

fn end_block<W>(&mut self, writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Writes a } to the specified writer.

Source

fn before_block_item<W>(&mut self, _writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Source

fn after_block_item<W>(&mut self, writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Source

fn begin_string<W>(&mut self, writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Source

fn end_string<W>(&mut self, writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Source

fn begin_array<W>(&mut self, writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Writes a [ to the specified writer.

Source

fn end_array<W>(&mut self, writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Writes a ] to the specified writer.

Source

fn write_byte_array<W>(&mut self, writer: &mut W, value: &[u8]) -> Result<()>
where W: ?Sized + Write,

Writes the representation of a byte array. Formatters can choose whether to represent bytes as a JSON array of integers (the default), or some JSON string encoding like hex or base64.

Source

fn begin_object<W>(&mut self, writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Writes a { to the specified writer.

Source

fn end_object<W>(&mut self, writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Writes a } to the specified writer.

Source

fn write_null<W>(&mut self, writer: &mut W) -> Result<()>
where W: ?Sized + Write,

Writes a null value to the specified writer.

Source

fn write_bool<W>(&mut self, writer: &mut W, value: bool) -> Result<()>
where W: ?Sized + Write,

Writes a true or false value to the specified writer.

Source

fn write_u8<W>(&mut self, writer: &mut W, value: u8) -> Result<()>
where W: ?Sized + Write,

Writes an unsigned byte value like “255” to the specified writer.

Source

fn write_u64<W>(&mut self, writer: &mut W, value: u64) -> Result<()>
where W: ?Sized + Write,

Writes an integer value like 123 to the specified writer.

Source

fn write_i64<W>(&mut self, writer: &mut W, value: i64) -> Result<()>
where W: ?Sized + Write,

Writes an integer value like -123 to the specified writer.

Source

fn write_f64<W>(&mut self, writer: &mut W, value: f64) -> Result<()>
where W: ?Sized + Write,

Writes a floating point value like -31.26e+12 to the specified writer.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§