Manifest

Trait Manifest 

Source
pub trait Manifest<A> {
    type Error;

    // Required method
    fn manifest(&self, ast: &A) -> Result<impl Display, Self::Error>;

    // Provided methods
    fn write_fmt<W: Write>(
        &self,
        ast: &A,
        writer: W,
    ) -> Result<(), FmtRenderError<Self::Error>> { ... }
    fn write_io<W: Write>(
        &self,
        ast: &A,
        writer: W,
    ) -> Result<(), IORenderError<Self::Error>> { ... }
}
Expand description

A manifest knows how to display an Ast.

Often, you can use a provided implementation.

Manifest implementations typically contain state which determine how the string is displayed.

§Mutable state

A Manifest implementation is not provided a mutable self-reference. In order to maintain mutable state which lasts for a single render of a template, implement ManifestMut instead.

Required Associated Types§

Source

type Error

An error produced while manifesting.

Required Methods§

Source

fn manifest(&self, ast: &A) -> Result<impl Display, Self::Error>

Convert the Ast to a type which can be displayed.

Note that the returned Display implementation is ephemeral and can borrow from &self or the ast.

Provided Methods§

Source

fn write_fmt<W: Write>( &self, ast: &A, writer: W, ) -> Result<(), FmtRenderError<Self::Error>>

Write the Ast into a fmt::Write implementation.

The default implementation calls write!(writer, "{}", self.manifest(ast)).

Source

fn write_io<W: Write>( &self, ast: &A, writer: W, ) -> Result<(), IORenderError<Self::Error>>

Write the Ast into a io::Write implementation.

The default implementation calls write!(writer, "{}", self.manifest(ast)).

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.

Implementations on Foreign Types§

Source§

impl<Q, K, V> Manifest<Q> for BTreeMap<K, V>
where K: Borrow<Q> + Ord, Q: Ord, V: Display,

Source§

type Error = KeyMissing

Source§

fn manifest(&self, ast: &Q) -> Result<impl Display, Self::Error>

Source§

impl<Q, K, V> Manifest<Q> for HashMap<K, V>
where K: Borrow<Q> + Eq + Hash, Q: Eq + Hash, V: Display,

Source§

type Error = KeyMissing

Source§

fn manifest(&self, ast: &Q) -> Result<impl Display, Self::Error>

Source§

impl<T: Display> Manifest<usize> for &[T]

Source§

type Error = IndexOutOfRange

Source§

fn manifest(&self, ast: &usize) -> Result<impl Display, Self::Error>

Source§

impl<T: Display> Manifest<usize> for &mut [T]

Source§

type Error = IndexOutOfRange

Source§

fn manifest(&self, ast: &usize) -> Result<impl Display, Self::Error>

Source§

impl<T: Display> Manifest<usize> for [T]

Source§

type Error = IndexOutOfRange

Source§

fn manifest(&self, ast: &usize) -> Result<impl Display, Self::Error>

Source§

impl<T: Display> Manifest<usize> for VecDeque<T>

Source§

type Error = IndexOutOfRange

Source§

fn manifest(&self, ast: &usize) -> Result<impl Display, Self::Error>

Source§

impl<T: Display> Manifest<usize> for Vec<T>

Source§

type Error = IndexOutOfRange

Source§

fn manifest(&self, ast: &usize) -> Result<impl Display, Self::Error>

Source§

impl<const N: usize, T: Display> Manifest<usize> for [T; N]

Source§

type Error = IndexOutOfRange

Source§

fn manifest(&self, ast: &usize) -> Result<impl Display, Self::Error>

Source§

impl<const N: usize, T: Display> Manifest<BoundedInt<N>> for [T; N]

Source§

type Error = Infallible

Source§

fn manifest(&self, ast: &BoundedInt<N>) -> Result<impl Display, Self::Error>

Implementors§

Source§

impl<A, F, T: Display, E> Manifest<A> for F
where F: Fn(&A) -> Result<T, E>,

Source§

type Error = E