Struct Renderer

Source
pub struct Renderer<'writer, W>
where W: Write,
{ /* private fields */ }
Expand description

A renderer of display list entries.

The following diagram gives an overview of each of the parts of the renderer’s output:

                    ┌ outer gutter
                    │ ┌ left border
                    │ │ ┌ inner gutter
                    │ │ │   ┌─────────────────────────── source ─────────────────────────────┐
                    │ │ │   │                                                                │
                 ┌────────────────────────────────────────────────────────────────────────────
       header ── │ error[0001]: oh noes, a cupcake has occurred!
snippet start ── │    ┌─ test:9:0
snippet empty ── │    │
 snippet line ── │  9 │   ╭ Cupcake ipsum dolor. Sit amet marshmallow topping cheesecake
 snippet line ── │ 10 │   │ muffin. Halvah croissant candy canes bonbon candy. Apple pie jelly
                 │    │ ╭─│─────────^
snippet break ── │    · │ │
 snippet line ── │ 33 │ │ │ Muffin danish chocolate soufflé pastry icing bonbon oat cake.
 snippet line ── │ 34 │ │ │ Powder cake jujubes oat cake. Lemon drops tootsie roll marshmallow
                 │    │ │ ╰─────────────────────────────^ blah blah
snippet break ── │    · │
 snippet line ── │ 38 │ │   Brownie lemon drops chocolate jelly-o candy canes. Danish marzipan
 snippet line ── │ 39 │ │   jujubes soufflé carrot cake marshmallow tiramisu caramels candy canes.
                 │    │ │           ^^^^^^^^^^^^^^^^^^^ -------------------- blah blah
                 │    │ │           │
                 │    │ │           blah blah
                 │    │ │           note: this is a note
 snippet line ── │ 40 │ │   Fruitcake jelly-o danish toffee. Tootsie roll pastry cheesecake
 snippet line ── │ 41 │ │   soufflé marzipan. Chocolate bar oat cake jujubes lollipop pastry
 snippet line ── │ 42 │ │   cupcake. Candy canes cupcake toffee gingerbread candy canes muffin
                 │    │ │                                ^^^^^^^^^^^^^^^^^^ blah blah
                 │    │ ╰──────────^ blah blah
snippet break ── │    ·
 snippet line ── │ 82 │     gingerbread toffee chupa chups chupa chups jelly-o cotton candy.
                 │    │                 ^^^^^^                         ------- blah blah
snippet empty ── │    │
 snippet note ── │    = blah blah
 snippet note ── │    = blah blah blah
                 │      blah blah
 snippet note ── │    = blah blah blah
                 │      blah blah
        empty ── │

Filler text from http://www.cupcakeipsum.com

Implementations§

Source§

impl<'writer, W: Write> Renderer<'writer, W>

Source

pub fn new(writer: &'writer mut W) -> Self

Construct a renderer from the given writer and config.

Source

pub fn render_header( &mut self, locus: Option<&Locus>, message: &str, ) -> FmtResult

Diagnostic header, with code, and message.

error[E0001]: unexpected type in `+` application
Source

pub fn render_empty(&mut self) -> FmtResult

Empty line.

Source

pub fn render_snippet_start( &mut self, outer_padding: usize, locus: &Locus, ) -> FmtResult

Top left border and locus.

┌─ test:2:9
Source

pub fn render_snippet_source( &mut self, outer_padding: usize, line_number: usize, source: &str, single_labels: &[SingleLabel<'_>], num_multi_labels: usize, multi_labels: &[(usize, MultiLabel<'_>)], ) -> FmtResult

A line of source code.

10 │   │ muffin. Halvah croissant candy canes bonbon candy. Apple pie jelly
   │ ╭─│─────────^
Source

pub fn render_snippet_empty( &mut self, outer_padding: usize, num_multi_labels: usize, multi_labels: &[(usize, MultiLabel<'_>)], ) -> FmtResult

An empty source line, for providing additional whitespace to source snippets.

│ │ │
Source

pub fn render_snippet_break( &mut self, outer_padding: usize, num_multi_labels: usize, multi_labels: &[(usize, MultiLabel<'_>)], ) -> FmtResult

A broken source line, for labeling skipped sections of source.

· │ │
Source

pub fn render_snippet_note( &mut self, outer_padding: usize, message: &str, ) -> FmtResult

Additional notes.

= expected type `Int`
     found type `String`

Trait Implementations§

Source§

impl<'writer, W: Write> Write for Renderer<'writer, W>

Source§

fn write_str(&mut self, buf: &str) -> FmtResult

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · Source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more

Auto Trait Implementations§

§

impl<'writer, W> Freeze for Renderer<'writer, W>

§

impl<'writer, W> RefUnwindSafe for Renderer<'writer, W>
where W: RefUnwindSafe,

§

impl<'writer, W> Send for Renderer<'writer, W>
where W: Send,

§

impl<'writer, W> Sync for Renderer<'writer, W>
where W: Sync,

§

impl<'writer, W> Unpin for Renderer<'writer, W>

§

impl<'writer, W> !UnwindSafe for Renderer<'writer, W>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.