[][src]Trait lexpr::print::Formatter

pub trait Formatter {
    fn write_nil<W: ?Sized>(&mut self, writer: &mut W) -> Result<()>
    where
        W: Write
, { ... }
fn write_null<W: ?Sized>(&mut self, writer: &mut W) -> Result<()>
    where
        W: Write
, { ... }
fn write_bool<W: ?Sized>(
        &mut self,
        writer: &mut W,
        value: bool
    ) -> Result<()>
    where
        W: Write
, { ... }
fn write_number<W: ?Sized>(
        &mut self,
        writer: &mut W,
        value: &Number
    ) -> Result<()>
    where
        W: Write
, { ... }
fn write_char<W: ?Sized>(&mut self, writer: &mut W, c: char) -> Result<()>
    where
        W: Write
, { ... }
fn begin_string<W: ?Sized>(&mut self, writer: &mut W) -> Result<()>
    where
        W: Write
, { ... }
fn end_string<W: ?Sized>(&mut self, writer: &mut W) -> Result<()>
    where
        W: Write
, { ... }
fn write_string_fragment<W: ?Sized>(
        &mut self,
        writer: &mut W,
        fragment: &str
    ) -> Result<()>
    where
        W: Write
, { ... }
fn write_char_escape<W: ?Sized>(
        &mut self,
        writer: &mut W,
        char_escape: CharEscape
    ) -> Result<()>
    where
        W: Write
, { ... }
fn write_symbol<W: ?Sized>(
        &mut self,
        writer: &mut W,
        name: &str
    ) -> Result<()>
    where
        W: Write
, { ... }
fn write_keyword<W: ?Sized>(
        &mut self,
        writer: &mut W,
        name: &str
    ) -> Result<()>
    where
        W: Write
, { ... }
fn write_bytes<W: ?Sized>(
        &mut self,
        writer: &mut W,
        bytes: &[u8]
    ) -> Result<()>
    where
        W: Write
, { ... }
fn begin_list<W: ?Sized>(&mut self, writer: &mut W) -> Result<()>
    where
        W: Write
, { ... }
fn end_list<W: ?Sized>(&mut self, writer: &mut W) -> Result<()>
    where
        W: Write
, { ... }
fn begin_seq_element<W: ?Sized>(
        &mut self,
        writer: &mut W,
        first: bool
    ) -> Result<()>
    where
        W: Write
, { ... }
fn end_seq_element<W: ?Sized>(&mut self, _writer: &mut W) -> Result<()>
    where
        W: Write
, { ... }
fn begin_vector<W: ?Sized>(
        &mut self,
        kind: VectorType,
        writer: &mut W
    ) -> Result<()>
    where
        W: Write
, { ... }
fn end_vector<W: ?Sized>(&mut self, writer: &mut W) -> Result<()>
    where
        W: Write
, { ... }
fn write_dot<W: ?Sized>(&mut self, writer: &mut W) -> Result<()>
    where
        W: Write
, { ... } }

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

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

Writes a representation of the special nil value to the specified writer.

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

Writes a representation of the special nil value to the specified writer.

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

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

fn write_number<W: ?Sized>(
    &mut self,
    writer: &mut W,
    value: &Number
) -> Result<()> where
    W: Write

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

fn write_char<W: ?Sized>(&mut self, writer: &mut W, c: char) -> Result<()> where
    W: Write

Writes a charactor to the specified writer.

The implementation provided by the trait will use Scheme notation (#\C).

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

Called before each series of write_string_fragment and write_char_escape. Writes a " to the specified writer.

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

Called after each series of write_string_fragment and write_char_escape. Writes a " to the specified writer.

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

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

fn write_char_escape<W: ?Sized>(
    &mut self,
    writer: &mut W,
    char_escape: CharEscape
) -> Result<()> where
    W: Write

Writes a character escape code to the specified writer.

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

Writes a symbol to the specified writer.

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

Writes a keyword to the specified writer.

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

Writes a byte vector to the specified writer.

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

Called before any list elements. Writes a ( to the specified writer.

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

Called after all list elements have been written. Writes a ) to the specified writer.

fn begin_seq_element<W: ?Sized>(
    &mut self,
    writer: &mut W,
    first: bool
) -> Result<()> where
    W: Write

Called before starting to write a list or vector element. Writes a space to the specified writer, if needed.

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

Called after every list or vector element.

fn begin_vector<W: ?Sized>(
    &mut self,
    kind: VectorType,
    writer: &mut W
) -> Result<()> where
    W: Write

Called before any vector elements. Will write #( for generic vectors, or #u8( for byte vectors, to the specified writer.

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

Called after all vector elements have been written. Writes a ) to the specified writer.

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

Called before writing the tail of an improper list, or more generally, the cdr field of a cons cell. Writes a . to the specified writer.

Loading content...

Implementors

impl Formatter for CustomizedFormatter[src]

fn write_char_escape<W: ?Sized>(
    &mut self,
    writer: &mut W,
    char_escape: CharEscape
) -> Result<()> where
    W: Write
[src]

Writes a character escape code to the specified writer.

impl Formatter for DefaultFormatter[src]

Loading content...