pub trait Formatter {
Show 19 methods
// Provided methods
fn write_nil<W>(&mut self, writer: &mut W) -> Result<()>
where W: Write + ?Sized { ... }
fn write_null<W>(&mut self, writer: &mut W) -> Result<()>
where W: Write + ?Sized { ... }
fn write_bool<W>(&mut self, writer: &mut W, value: bool) -> Result<()>
where W: Write + ?Sized { ... }
fn write_number<W>(&mut self, writer: &mut W, value: &Number) -> Result<()>
where W: Write + ?Sized { ... }
fn write_char<W>(&mut self, writer: &mut W, c: char) -> Result<()>
where W: Write + ?Sized { ... }
fn begin_string<W>(&mut self, writer: &mut W) -> Result<()>
where W: Write + ?Sized { ... }
fn end_string<W>(&mut self, writer: &mut W) -> Result<()>
where W: Write + ?Sized { ... }
fn write_string_fragment<W>(
&mut self,
writer: &mut W,
fragment: &str
) -> Result<()>
where W: Write + ?Sized { ... }
fn write_char_escape<W>(
&mut self,
writer: &mut W,
char_escape: CharEscape
) -> Result<()>
where W: Write + ?Sized { ... }
fn write_symbol<W>(&mut self, writer: &mut W, name: &str) -> Result<()>
where W: Write + ?Sized { ... }
fn write_keyword<W>(&mut self, writer: &mut W, name: &str) -> Result<()>
where W: Write + ?Sized { ... }
fn write_bytes<W>(&mut self, writer: &mut W, bytes: &[u8]) -> Result<()>
where W: Write + ?Sized { ... }
fn begin_list<W>(&mut self, writer: &mut W) -> Result<()>
where W: Write + ?Sized { ... }
fn end_list<W>(&mut self, writer: &mut W) -> Result<()>
where W: Write + ?Sized { ... }
fn begin_seq_element<W>(
&mut self,
writer: &mut W,
first: bool
) -> Result<()>
where W: Write + ?Sized { ... }
fn end_seq_element<W>(&mut self, _writer: &mut W) -> Result<()>
where W: Write + ?Sized { ... }
fn begin_vector<W>(
&mut self,
kind: VectorType,
writer: &mut W
) -> Result<()>
where W: Write + ?Sized { ... }
fn end_vector<W>(&mut self, writer: &mut W) -> Result<()>
where W: Write + ?Sized { ... }
fn write_dot<W>(&mut self, writer: &mut W) -> Result<()>
where W: Write + ?Sized { ... }
}
Expand description
This trait abstracts away serializing the S-expression pieces, which allows the implementer to optionally pretty print the S-expression output, as well as to allow customizing the printing for various S-expression “dialects”.
The default implementation produces Scheme-syntax S-expression text.
Provided Methods§
sourcefn write_nil<W>(&mut self, writer: &mut W) -> Result<()>where
W: Write + ?Sized,
fn write_nil<W>(&mut self, writer: &mut W) -> Result<()>where W: Write + ?Sized,
Writes a representation of the special nil value to the specified writer.
sourcefn write_null<W>(&mut self, writer: &mut W) -> Result<()>where
W: Write + ?Sized,
fn write_null<W>(&mut self, writer: &mut W) -> Result<()>where W: Write + ?Sized,
Writes a representation of the special nil value to the specified writer.
sourcefn write_bool<W>(&mut self, writer: &mut W, value: bool) -> Result<()>where
W: Write + ?Sized,
fn write_bool<W>(&mut self, writer: &mut W, value: bool) -> Result<()>where W: Write + ?Sized,
Writes a representation of a boolean value to the specified writer.
The implementation provided by the trait will use the Scheme notation
(#t
and #f
).
sourcefn write_number<W>(&mut self, writer: &mut W, value: &Number) -> Result<()>where
W: Write + ?Sized,
fn write_number<W>(&mut self, writer: &mut W, value: &Number) -> Result<()>where W: Write + ?Sized,
Writes an integer value like -123
to the specified writer.
sourcefn write_char<W>(&mut self, writer: &mut W, c: char) -> Result<()>where
W: Write + ?Sized,
fn write_char<W>(&mut self, writer: &mut W, c: char) -> Result<()>where W: Write + ?Sized,
Writes a charactor to the specified writer.
The implementation provided by the trait will use Scheme notation
(#\C
).
sourcefn begin_string<W>(&mut self, writer: &mut W) -> Result<()>where
W: Write + ?Sized,
fn begin_string<W>(&mut self, writer: &mut W) -> Result<()>where W: Write + ?Sized,
Called before each series of write_string_fragment
and
write_char_escape
. Writes a "
to the specified writer.
sourcefn end_string<W>(&mut self, writer: &mut W) -> Result<()>where
W: Write + ?Sized,
fn end_string<W>(&mut self, writer: &mut W) -> Result<()>where W: Write + ?Sized,
Called after each series of write_string_fragment
and
write_char_escape
. Writes a "
to the specified writer.
sourcefn write_string_fragment<W>(
&mut self,
writer: &mut W,
fragment: &str
) -> Result<()>where
W: Write + ?Sized,
fn write_string_fragment<W>( &mut self, writer: &mut W, fragment: &str ) -> Result<()>where W: Write + ?Sized,
Writes a string fragment that doesn’t need any escaping to the specified writer.
sourcefn write_char_escape<W>(
&mut self,
writer: &mut W,
char_escape: CharEscape
) -> Result<()>where
W: Write + ?Sized,
fn write_char_escape<W>( &mut self, writer: &mut W, char_escape: CharEscape ) -> Result<()>where W: Write + ?Sized,
Writes a character escape code to the specified writer.
sourcefn write_symbol<W>(&mut self, writer: &mut W, name: &str) -> Result<()>where
W: Write + ?Sized,
fn write_symbol<W>(&mut self, writer: &mut W, name: &str) -> Result<()>where W: Write + ?Sized,
Writes a symbol to the specified writer.
sourcefn write_keyword<W>(&mut self, writer: &mut W, name: &str) -> Result<()>where
W: Write + ?Sized,
fn write_keyword<W>(&mut self, writer: &mut W, name: &str) -> Result<()>where W: Write + ?Sized,
Writes a keyword to the specified writer.
sourcefn write_bytes<W>(&mut self, writer: &mut W, bytes: &[u8]) -> Result<()>where
W: Write + ?Sized,
fn write_bytes<W>(&mut self, writer: &mut W, bytes: &[u8]) -> Result<()>where W: Write + ?Sized,
Writes a byte vector to the specified writer.
sourcefn begin_list<W>(&mut self, writer: &mut W) -> Result<()>where
W: Write + ?Sized,
fn begin_list<W>(&mut self, writer: &mut W) -> Result<()>where W: Write + ?Sized,
Called before any list elements. Writes a (
to the specified
writer.
sourcefn end_list<W>(&mut self, writer: &mut W) -> Result<()>where
W: Write + ?Sized,
fn end_list<W>(&mut self, writer: &mut W) -> Result<()>where W: Write + ?Sized,
Called after all list elements have been written. Writes a )
to the
specified writer.
sourcefn begin_seq_element<W>(&mut self, writer: &mut W, first: bool) -> Result<()>where
W: Write + ?Sized,
fn begin_seq_element<W>(&mut self, writer: &mut W, first: bool) -> Result<()>where W: Write + ?Sized,
Called before starting to write a list or vector element. Writes a space to the specified writer, if needed.
sourcefn end_seq_element<W>(&mut self, _writer: &mut W) -> Result<()>where
W: Write + ?Sized,
fn end_seq_element<W>(&mut self, _writer: &mut W) -> Result<()>where W: Write + ?Sized,
Called after every list or vector element.
sourcefn begin_vector<W>(&mut self, kind: VectorType, writer: &mut W) -> Result<()>where
W: Write + ?Sized,
fn begin_vector<W>(&mut self, kind: VectorType, writer: &mut W) -> Result<()>where W: Write + ?Sized,
Called before any vector elements. Will write #(
for generic vectors,
or #u8(
for byte vectors, to the specified writer.