pub struct CmdRenderer { /* private fields */ }
Expand description

A generic renderer which will shell out to an arbitrary executable.

Rendering Protocol

When the renderer’s render() method is invoked, CmdRenderer will spawn the cmd as a subprocess. The RenderContext is passed to the subprocess as a JSON string (using serde_json).

Note: The command used doesn’t necessarily need to be a single executable (i.e. /path/to/renderer). The cmd string lets you pass in command line arguments, so there’s no reason why it couldn’t be python /path/to/renderer --from mdbook --to epub.

Anything the subprocess writes to stdin or stdout will be passed through to the user. While this gives the renderer maximum flexibility to output whatever it wants, to avoid spamming users it is recommended to avoid unnecessary output.

To help choose the appropriate output level, the RUST_LOG environment variable will be passed through to the subprocess, if set.

If the subprocess wishes to indicate that rendering failed, it should exit with a non-zero return code.

Implementations§

source§

impl CmdRenderer

source

pub fn new(name: String, cmd: String) -> CmdRenderer

Create a new CmdRenderer which will invoke the provided cmd string.

Trait Implementations§

source§

impl Clone for CmdRenderer

source§

fn clone(&self) -> CmdRenderer

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CmdRenderer

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq<CmdRenderer> for CmdRenderer

source§

fn eq(&self, other: &CmdRenderer) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Renderer for CmdRenderer

source§

fn name(&self) -> &str

The Renderer’s name.
source§

fn render(&self, ctx: &RenderContext) -> Result<()>

Invoke the Renderer, passing in all the necessary information for describing a book.
source§

impl StructuralPartialEq for CmdRenderer

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.