Renderer

Struct Renderer 

Source
pub struct Renderer<'writer, 'config> { /* 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, 'config> Renderer<'writer, 'config>

Source

pub fn new( writer: &'writer mut dyn WriteStyle, config: &'config Config, ) -> Renderer<'writer, 'config>

Construct a renderer from the given writer and config.

Source

pub fn render_header( &mut self, locus: Option<&Locus>, severity: Severity, code: Option<&str>, message: &str, ) -> Result<(), Error>

Diagnostic header, with severity, code, and message.

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

pub fn render_empty(&mut self) -> Result<(), Error>

Empty line.

Source

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

Top left border and locus.

┌─ test:2:9
Source

pub fn render_snippet_source( &mut self, outer_padding: usize, line_number: usize, source: &str, severity: Severity, single_labels: &[(LabelStyle, Range<usize>, &'_ str)], num_multi_labels: usize, multi_labels: &[(usize, LabelStyle, MultiLabel<'_>)], ) -> Result<(), Error>

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, severity: Severity, num_multi_labels: usize, multi_labels: &[(usize, LabelStyle, MultiLabel<'_>)], ) -> Result<(), Error>

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

│ │ │
Source

pub fn render_snippet_break( &mut self, outer_padding: usize, severity: Severity, num_multi_labels: usize, multi_labels: &[(usize, LabelStyle, MultiLabel<'_>)], ) -> Result<(), Error>

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

· │ │
Source

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

Additional notes.

= expected type `Int`
     found type `String`

Trait Implementations§

Source§

impl Write for Renderer<'_, '_>

Available on crate feature std only.
Source§

fn write(&mut self, buf: &[u8]) -> Result<usize>

Writes a buffer into this writer, returning how many bytes were written. Read more
Source§

fn flush(&mut self) -> Result<()>

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
1.36.0 · Source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

Like write, except that it writes from a slice of buffers. Read more
Source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
1.0.0 · Source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>

Attempts to write an entire buffer into this writer. Read more
Source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · Source§

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

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more
Source§

impl WriteStyle for Renderer<'_, '_>

Auto Trait Implementations§

§

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

§

impl<'writer, 'config> !RefUnwindSafe for Renderer<'writer, 'config>

§

impl<'writer, 'config> !Send for Renderer<'writer, 'config>

§

impl<'writer, 'config> !Sync for Renderer<'writer, 'config>

§

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

§

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

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.