Skip to main content

Viewer

Trait Viewer 

Source
pub trait Viewer<'a, Message, Theme = Theme, Renderer = Renderer<Renderer, Renderer>>: Sized + 'a
where Message: 'a, Theme: Catalog + 'a, Renderer: Renderer + 'a,
{ // Required methods fn theme(&self) -> &Theme; fn highlighter(&self) -> &dyn Highlighter<Code, Theme>; fn on_link_click(url: String) -> Message; // Provided methods fn image( &self, settings: Settings, url: &'a String, title: &'a str, alt: &Text, ) -> impl Widget<Message, Theme, Renderer> + 'a { ... } fn heading( &self, settings: Settings, level: &'a HeadingLevel, text: &'a Text, ) -> impl Widget<Message, Theme, Renderer> + 'a { ... } fn paragraph( &self, settings: Settings, text: &Text, ) -> impl Widget<Message, Theme, Renderer> + 'a { ... } fn code_block( &self, settings: Settings, language: Option<&'a str>, code: &'a str, lines: &'a [Text], ) -> impl Widget<Message, Theme, Renderer> + 'a { ... } fn unordered_list( &self, settings: Settings, bullets: &'a [Bullet], ) -> impl Widget<Message, Theme, Renderer> + 'a { ... } fn ordered_list( &self, settings: Settings, start: u64, bullets: &'a [Bullet], ) -> impl Widget<Message, Theme, Renderer> + 'a { ... } fn quote( &self, settings: Settings, contents: &'a [Item], ) -> impl Widget<Message, Theme, Renderer> + 'a { ... } fn rule(&self) -> impl Widget<Message, Theme, Renderer> + 'a { ... } fn table( &self, settings: Settings, columns: &'a [Column], rows: &'a [Row], ) -> impl Widget<Message, Theme, Renderer> + 'a { ... } }
Available on crate feature markdown only.
Expand description

A view strategy to display a Markdown Item.

A Viewer is in charge of turning each Item into a widget. It also provides the Theme and text::Highlighter used for rendering.

Required Methods§

Source

fn theme(&self) -> &Theme

The Theme used for styling the Markdown elements.

Source

fn highlighter(&self) -> &dyn Highlighter<Code, Theme>

The text::Highlighter used for highligthing Code regions.

Produces a message when a link is clicked with the given Uri.

Provided Methods§

Source

fn image( &self, settings: Settings, url: &'a String, title: &'a str, alt: &Text, ) -> impl Widget<Message, Theme, Renderer> + 'a

Displays an image.

By default, it will show a container with the image title.

Source

fn heading( &self, settings: Settings, level: &'a HeadingLevel, text: &'a Text, ) -> impl Widget<Message, Theme, Renderer> + 'a

Displays a heading.

By default, it calls heading.

Source

fn paragraph( &self, settings: Settings, text: &Text, ) -> impl Widget<Message, Theme, Renderer> + 'a

Displays a paragraph.

By default, it calls paragraph.

Source

fn code_block( &self, settings: Settings, language: Option<&'a str>, code: &'a str, lines: &'a [Text], ) -> impl Widget<Message, Theme, Renderer> + 'a

Displays a code block.

By default, it calls code_block.

Source

fn unordered_list( &self, settings: Settings, bullets: &'a [Bullet], ) -> impl Widget<Message, Theme, Renderer> + 'a

Displays an unordered list.

By default, it calls unordered_list.

Source

fn ordered_list( &self, settings: Settings, start: u64, bullets: &'a [Bullet], ) -> impl Widget<Message, Theme, Renderer> + 'a

Displays an ordered list.

By default, it calls ordered_list.

Source

fn quote( &self, settings: Settings, contents: &'a [Item], ) -> impl Widget<Message, Theme, Renderer> + 'a

Displays a quote.

By default, it calls quote.

Source

fn rule(&self) -> impl Widget<Message, Theme, Renderer> + 'a

Displays a rule.

By default, it calls rule.

Source

fn table( &self, settings: Settings, columns: &'a [Column], rows: &'a [Row], ) -> impl Widget<Message, Theme, Renderer> + 'a

Displays a table.

By default, it calls table.

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.

Implementors§

Source§

impl<'a, Theme, Renderer> Viewer<'a, String, Theme, Renderer> for DefaultViewer<'a, Theme>
where Theme: Catalog + 'a, Renderer: Renderer + 'a,