pub trait Content {
// Provided methods
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_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 { ... }
}Expand description
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§
Sourcefn is_truthy(&self) -> bool
fn is_truthy(&self) -> bool
Marks whether this content is truthy. Used when attempting to render a section.
Sourcefn capacity_hint(&self, _tpl: &Template<'_>) -> usize
fn capacity_hint(&self, _tpl: &Template<'_>) -> usize
How much capacity is likely required for all the data in this Content
for a given Template.
Sourcefn render_escaped<E: Encoder>(&self, _encoder: &mut E) -> Result<(), E::Error>
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 <.
Sourcefn render_unescaped<E: Encoder>(&self, encoder: &mut E) -> Result<(), E::Error>
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.
Sourcefn render_section<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E,
) -> Result<(), E::Error>where
C: ContentSequence,
E: Encoder,
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.
Sourcefn render_inverse<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,
Render a section with self.
Sourcefn render_field_escaped<E: Encoder>(
&self,
_hash: u64,
_name: &str,
_encoder: &mut E,
) -> Result<bool, E::Error>
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 <.
If successful, returns true if the field exists in this content, otherwise false.
Sourcefn render_field_unescaped<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>
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.
Sourcefn 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_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.
Sourcefn 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,
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.
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<K, V> Content for BTreeMap<K, V>
impl<K, V> Content for BTreeMap<K, V>
Source§fn render_section<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E,
) -> Result<(), E::Error>where
C: ContentSequence,
E: Encoder,
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 is_truthy(&self) -> bool
fn render_field_escaped<E>(
&self,
_: u64,
name: &str,
encoder: &mut E,
) -> Result<bool, E::Error>where
E: Encoder,
fn render_field_unescaped<E>(
&self,
_: u64,
name: &str,
encoder: &mut E,
) -> Result<bool, E::Error>where
E: Encoder,
fn render_field_section<C, E>(
&self,
_: 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,
_: u64,
name: &str,
section: Section<'_, C>,
encoder: &mut E,
) -> Result<bool, E::Error>where
C: ContentSequence,
E: Encoder,
Source§impl<K, V, S> Content for HashMap<K, V, S>
impl<K, V, S> Content for HashMap<K, V, S>
Source§fn render_section<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E,
) -> Result<(), E::Error>where
C: ContentSequence,
E: Encoder,
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.