[][src]Trait ramhorns::Content

pub trait Content {
    fn is_truthy(&self) -> bool { ... }
fn capacity_hint(&self, _tpl: &Template<'_>) -> usize { ... }
fn render_escaped<E: Encoder>(
        &self,
        _encoder: &mut E
    ) -> Result<(), E::Error> { ... }
fn render_unescaped<E: Encoder>(
        &self,
        encoder: &mut E
    ) -> Result<(), E::Error> { ... }
fn render_cmark<E: Encoder>(&self, encoder: &mut E) -> Result<(), E::Error> { ... }
fn render_section<C, E>(
        &self,
        section: Section<'_, C>,
        encoder: &mut E
    ) -> Result<(), E::Error>
    where
        C: ContentSequence,
        E: Encoder
, { ... }
fn render_inverse<C, E>(
        &self,
        section: Section<'_, C>,
        encoder: &mut E
    ) -> Result<(), E::Error>
    where
        C: ContentSequence,
        E: Encoder
, { ... }
fn render_field_escaped<E: Encoder>(
        &self,
        _hash: u64,
        _name: &str,
        _encoder: &mut E
    ) -> Result<bool, E::Error> { ... }
fn render_field_unescaped<E: Encoder>(
        &self,
        _hash: u64,
        _name: &str,
        _encoder: &mut E
    ) -> Result<bool, E::Error> { ... }
fn render_field_section<C, E>(
        &self,
        _hash: u64,
        _name: &str,
        _section: Section<'_, C>,
        _encoder: &mut E
    ) -> Result<bool, E::Error>
    where
        C: ContentSequence,
        E: Encoder
, { ... }
fn render_field_inverse<C, E>(
        &self,
        _hash: u64,
        _name: &str,
        _section: Section<'_, C>,
        _encoder: &mut E
    ) -> Result<bool, E::Error>
    where
        C: ContentSequence,
        E: Encoder
, { ... } }

Trait allowing the rendering to quickly access data stored in the type that implements it. You needn't worry about implementing it, in virtually all cases the #[derive(Content)] attribute above your types should be sufficient.

Provided methods

fn is_truthy(&self) -> bool

Marks whether this content is truthy. Used when attempting to render a section.

fn capacity_hint(&self, _tpl: &Template<'_>) -> usize

How much capacity is likely required for all the data in this Content for a given Template.

fn render_escaped<E: Encoder>(&self, _encoder: &mut E) -> Result<(), E::Error>

Renders self as a variable to the encoder.

This will escape HTML characters, eg: < will become &lt;.

fn render_unescaped<E: Encoder>(&self, encoder: &mut E) -> Result<(), E::Error>

Renders self as a variable to the encoder.

This doesn't perform any escaping at all.

fn render_cmark<E: Encoder>(&self, encoder: &mut E) -> Result<(), E::Error>

Renders self as a variable to the encoder with CommonMark processing.

The generated HTML is never escaped.

fn render_section<C, E>(
    &self,
    section: Section<'_, C>,
    encoder: &mut E
) -> Result<(), E::Error> where
    C: ContentSequence,
    E: Encoder

Render a section with self.

fn render_inverse<C, E>(
    &self,
    section: Section<'_, C>,
    encoder: &mut E
) -> Result<(), E::Error> where
    C: ContentSequence,
    E: Encoder

Render a section with self.

fn render_field_escaped<E: Encoder>(
    &self,
    _hash: u64,
    _name: &str,
    _encoder: &mut E
) -> Result<bool, E::Error>

Render a field by the hash or string of its name.

This will escape HTML characters, eg: < will become &lt;. If successful, returns true if the field exists in this content, otherwise false.

fn render_field_unescaped<E: Encoder>(
    &self,
    _hash: u64,
    _name: &str,
    _encoder: &mut E
) -> Result<bool, E::Error>

Render a field by the hash or string of its name.

This doesn't perform any escaping at all. If successful, returns true if the field exists in this content, otherwise false.

fn render_field_section<C, E>(
    &self,
    _hash: u64,
    _name: &str,
    _section: Section<'_, C>,
    _encoder: &mut E
) -> Result<bool, E::Error> where
    C: ContentSequence,
    E: Encoder

Render a field by the hash or string of its name, as a section. If successful, returns true if the field exists in this content, otherwise false.

fn render_field_inverse<C, E>(
    &self,
    _hash: u64,
    _name: &str,
    _section: Section<'_, C>,
    _encoder: &mut E
) -> Result<bool, E::Error> where
    C: ContentSequence,
    E: Encoder

Render a field, by the hash of or string its name, as an inverse section. If successful, returns true if the field exists in this content, otherwise false.

Loading content...

Implementations on Foreign Types

impl Content for ()[src]

impl Content for str[src]

impl Content for String[src]

impl Content for bool[src]

impl Content for u8[src]

impl Content for u16[src]

impl Content for u32[src]

impl Content for u64[src]

impl Content for u128[src]

impl Content for usize[src]

impl Content for i8[src]

impl Content for i16[src]

impl Content for i32[src]

impl Content for i64[src]

impl Content for i128[src]

impl Content for isize[src]

impl Content for f32[src]

impl Content for f64[src]

impl<T: Content> Content for Option<T>[src]

impl<T: Content, U> Content for Result<T, U>[src]

impl<T: Content> Content for Vec<T>[src]

impl<T: Content> Content for [T][src]

impl<K, V, S> Content for HashMap<K, V, S> where
    K: Borrow<str> + Hash + Eq,
    V: Content,
    S: BuildHasher
[src]

fn render_section<C, E>(
    &self,
    section: Section<'_, C>,
    encoder: &mut E
) -> Result<(), E::Error> where
    C: ContentSequence,
    E: Encoder
[src]

Render a section with self.

impl<K, V> Content for BTreeMap<K, V> where
    K: Borrow<str> + Ord,
    V: Content
[src]

fn render_section<C, E>(
    &self,
    section: Section<'_, C>,
    encoder: &mut E
) -> Result<(), E::Error> where
    C: ContentSequence,
    E: Encoder
[src]

Render a section with self.

impl<T: Content + ?Sized, '_> Content for &'_ T[src]

impl<T: Content + ?Sized> Content for Box<T>[src]

impl<T: Content + ?Sized> Content for Rc<T>[src]

impl<T: Content + ?Sized> Content for Arc<T>[src]

impl<T: Content + ToOwned + ?Sized, '_> Content for Cow<'_, T>[src]

impl<T: Content + Clone + ?Sized, '_> Content for Cow<'_, [T]>[src]

impl<T: Content + Clone + ?Sized, '_> Content for Cow<'_, [T]>[src]

impl<'_> Content for Cow<'_, str>[src]

impl<'_> Content for Cow<'_, str>[src]

Loading content...

Implementors

Loading content...