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§
Sourcefn write_raw<W>(&mut self, writer: &mut W, fragment: &str) -> Result<()>
fn write_raw<W>(&mut self, writer: &mut W, fragment: &str) -> Result<()>
Writes a raw GraphQL fragment that doesn’t need escaping to the writer.
fn write_keyword<W>(&mut self, writer: &mut W, name: &str) -> Result<()>
Sourcefn write_separator<W>(&mut self, writer: &mut W) -> Result<()>
fn write_separator<W>(&mut self, writer: &mut W) -> Result<()>
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
fn before_operation_or_fragment_definition<W>( &mut self, _writer: &mut W, ) -> Result<()>
fn before_operation_variable_definitions<W>( &mut self, _writer: &mut W, ) -> Result<()>
Sourcefn after_operation_or_fragment_signature<W>(
&mut self,
_writer: &mut W,
) -> Result<()>
fn after_operation_or_fragment_signature<W>( &mut self, _writer: &mut W, ) -> Result<()>
Called after writing the operation name and/or arguments.
fn after_selection_signature<W>(&mut self, _writer: &mut W) -> Result<()>
fn before_type_condition<W>(&mut self, _writer: &mut W) -> Result<()>
fn before_directive<W>(&mut self, _writer: &mut W) -> Result<()>
Sourcefn write_string_fragment<W>(
&mut self,
writer: &mut W,
fragment: &str,
) -> Result<()>
fn write_string_fragment<W>( &mut self, writer: &mut W, fragment: &str, ) -> Result<()>
Writes a string fragment that doesn’t need any escaping to the specified writer.
Sourcefn begin_variable<W>(&mut self, writer: &mut W) -> Result<()>
fn begin_variable<W>(&mut self, writer: &mut W) -> Result<()>
Writes a $
to the specified writer.
This must be called before writing a variable name.
Sourcefn write_non_null_type_indicator<W>(&mut self, writer: &mut W) -> Result<()>
fn write_non_null_type_indicator<W>(&mut self, writer: &mut W) -> Result<()>
Writes a !
to the specified writer.
This must be called after writing a variable type name.
Sourcefn begin_directive<W>(&mut self, writer: &mut W) -> Result<()>
fn begin_directive<W>(&mut self, writer: &mut W) -> Result<()>
Writes a @
to the specified writer.
This must be called before writing a directive name.
Sourcefn write_name_value_separator<W>(&mut self, writer: &mut W) -> Result<()>
fn write_name_value_separator<W>(&mut self, writer: &mut W) -> Result<()>
Writes a :
to the specified writer.
Sourcefn write_variable_default_value_separator<W>(
&mut self,
writer: &mut W,
) -> Result<()>
fn write_variable_default_value_separator<W>( &mut self, writer: &mut W, ) -> Result<()>
Writes a =
to the specified writer.
This is used to separate the name of a variable from its default value.
Sourcefn write_item_separator<W>(&mut self, writer: &mut W) -> Result<()>
fn write_item_separator<W>(&mut self, writer: &mut W) -> Result<()>
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
Sourcefn begin_parentheses<W>(&mut self, writer: &mut W) -> Result<()>
fn begin_parentheses<W>(&mut self, writer: &mut W) -> Result<()>
Writes a (
to the specified writer.
Sourcefn end_parentheses<W>(&mut self, writer: &mut W) -> Result<()>
fn end_parentheses<W>(&mut self, writer: &mut W) -> Result<()>
Writes a )
to the specified writer.
Sourcefn begin_block<W>(&mut self, writer: &mut W) -> Result<()>
fn begin_block<W>(&mut self, writer: &mut W) -> Result<()>
Writes a {
to the specified writer.
fn before_block_item<W>(&mut self, _writer: &mut W) -> Result<()>
fn after_block_item<W>(&mut self, writer: &mut W) -> Result<()>
fn begin_string<W>(&mut self, writer: &mut W) -> Result<()>
fn end_string<W>(&mut self, writer: &mut W) -> Result<()>
Sourcefn begin_array<W>(&mut self, writer: &mut W) -> Result<()>
fn begin_array<W>(&mut self, writer: &mut W) -> Result<()>
Writes a [
to the specified writer.
Sourcefn write_byte_array<W>(&mut self, writer: &mut W, value: &[u8]) -> Result<()>
fn write_byte_array<W>(&mut self, writer: &mut W, value: &[u8]) -> Result<()>
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.
Sourcefn begin_object<W>(&mut self, writer: &mut W) -> Result<()>
fn begin_object<W>(&mut self, writer: &mut W) -> Result<()>
Writes a {
to the specified writer.
Sourcefn end_object<W>(&mut self, writer: &mut W) -> Result<()>
fn end_object<W>(&mut self, writer: &mut W) -> Result<()>
Writes a }
to the specified writer.
Sourcefn write_null<W>(&mut self, writer: &mut W) -> Result<()>
fn write_null<W>(&mut self, writer: &mut W) -> Result<()>
Writes a null
value to the specified writer.
Sourcefn write_bool<W>(&mut self, writer: &mut W, value: bool) -> Result<()>
fn write_bool<W>(&mut self, writer: &mut W, value: bool) -> Result<()>
Writes a true
or false
value to the specified writer.
Sourcefn write_u8<W>(&mut self, writer: &mut W, value: u8) -> Result<()>
fn write_u8<W>(&mut self, writer: &mut W, value: u8) -> Result<()>
Writes an unsigned byte value like “255” to the specified writer.
Sourcefn write_u64<W>(&mut self, writer: &mut W, value: u64) -> Result<()>
fn write_u64<W>(&mut self, writer: &mut W, value: u64) -> Result<()>
Writes an integer value like 123
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.