Skip to main content

SourceRendererFormat

Struct SourceRendererFormat 

Source
pub struct SourceRendererFormat { /* private fields */ }
Expand description

A plugin’s SourceRenderer as a document format: the renderer draws the source; the id, name, extensions and an optional sniffer come from the host that wraps it.

Implementations§

Source§

impl SourceRendererFormat

Source

pub fn new(id: impl Into<String>, renderer: Arc<dyn SourceRenderer>) -> Self

Wrap renderer as the format id.

Source

pub fn name(self, name: impl Into<String>) -> Self

The name people call the format.

Source

pub fn extensions(self, extensions: &[&str]) -> Self

The extensions it claims, without the dot.

Source

pub fn sniffer( self, sniffer: impl Fn(&str) -> f32 + Send + Sync + 'static, ) -> Self

A content sniffer (0 to 1).

Trait Implementations§

Source§

impl DocumentFormat for SourceRendererFormat

Source§

fn id(&self) -> &str

The format’s id: lowercase, stable, usable as a CLI value ("org").
Source§

fn name(&self) -> &str

The name people call it ("Org").
Source§

fn extensions(&self) -> Vec<String>

The file extensions it claims, lowercase, without the dot.
Source§

fn sniff(&self, text: &str) -> f32

How confident it is that text is in this format, from 0 to 1. See LIKELY and CERTAIN.
Source§

fn render(&self, source: &str, _options: &RenderOptions) -> Rendered

Render source. The default draws parse’s document with DocumentView, or the source as plain text when the format does not parse into the model.
Source§

fn aliases(&self) -> Vec<String>

Other ids accepted for it ("adoc" for AsciiDoc).
Source§

fn match_name(&self, file_name: &str) -> NameMatch

How file_name (a base name) relates to this format. By default a name whose extension is one of extensions is NameMatch::Yes.
Source§

fn features(&self) -> Vec<String>

What the format supports ("tables", "admonitions", …), for listings and for callers that want to know before rendering.
Source§

fn parse(&self, _source: &str) -> Option<Parsed>

Parse source into the shared model, for formats built on it.

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more