pub trait Content {
Show 16 methods
// Provided methods
fn is_truthy(&self) -> bool { ... }
fn capacity_hint(&self, _tpl: &Template) -> usize { ... }
fn render_escaped<E>(
&self,
_encoder: &mut E
) -> Result<(), <E as Encoder>::Error>
where E: Encoder { ... }
fn render_unescaped<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>
where E: Encoder { ... }
fn apply_unescaped(
&self
) -> Result<SimpleValue, Box<dyn Error + Sync + Send>> { ... }
fn render_section<C, E, IC>(
&self,
section: Section<'_, C>,
encoder: &mut E,
content: Option<&IC>
) -> Result<(), <E as Encoder>::Error>
where C: ContentSequence,
E: Encoder,
IC: Content { ... }
fn apply_section<C>(
&self,
section: SimpleSection<'_, C>
) -> Result<SimpleValue, Box<dyn Error + Sync + Send>>
where C: ContentSequence { ... }
fn render_inverse<C, E, IC>(
&self,
section: Section<'_, C>,
encoder: &mut E,
content: Option<&IC>
) -> Result<(), <E as Encoder>::Error>
where C: ContentSequence,
E: Encoder,
IC: Content { ... }
fn render_notnone_section<C, E, IC>(
&self,
section: Section<'_, C>,
encoder: &mut E,
content: Option<&IC>
) -> Result<(), <E as Encoder>::Error>
where C: ContentSequence,
E: Encoder,
IC: Content { ... }
fn render_field_escaped<E>(
&self,
_hash: u64,
_name: &str,
_encoder: &mut E
) -> Result<bool, <E as Encoder>::Error>
where E: Encoder { ... }
fn render_field_unescaped<E>(
&self,
_hash: u64,
_name: &str,
_encoder: &mut E
) -> Result<bool, <E as Encoder>::Error>
where E: Encoder { ... }
fn apply_field_unescaped(
&self,
_hash: u64,
_name: &str
) -> Result<SimpleValue, Box<dyn Error + Sync + Send>> { ... }
fn render_field_section<C, E>(
&self,
_hash: u64,
_name: &str,
_section: Section<'_, C>,
_encoder: &mut E
) -> Result<bool, <E as Encoder>::Error>
where C: ContentSequence,
E: Encoder { ... }
fn apply_field_section<C>(
&self,
_hash: u64,
_name: &str,
_section: SimpleSection<'_, C>
) -> Result<SimpleValue, Box<dyn Error + Sync + Send>>
where C: ContentSequence { ... }
fn render_field_inverse<C, E>(
&self,
_hash: u64,
_name: &str,
_section: Section<'_, C>,
_encoder: &mut E
) -> Result<bool, <E as Encoder>::Error>
where C: ContentSequence,
E: Encoder { ... }
fn render_field_notnone_section<C, E>(
&self,
_hash: u64,
_name: &str,
_section: Section<'_, C>,
_encoder: &mut E
) -> Result<bool, <E as Encoder>::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>(
&self,
_encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
fn render_escaped<E>(
&self,
_encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
Renders self as a variable to the encoder.
This will escape HTML characters, eg: < will become <.
sourcefn render_unescaped<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
fn render_unescaped<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
Renders self as a variable to the encoder.
This doesn’t perform any escaping at all.
sourcefn apply_unescaped(&self) -> Result<SimpleValue, Box<dyn Error + Sync + Send>>
fn apply_unescaped(&self) -> Result<SimpleValue, Box<dyn Error + Sync + Send>>
Apply self as a variable.
This doesn’t perform any escaping at all.
sourcefn render_section<C, E, IC>(
&self,
section: Section<'_, C>,
encoder: &mut E,
content: Option<&IC>
) -> Result<(), <E as Encoder>::Error>
fn render_section<C, E, IC>( &self, section: Section<'_, C>, encoder: &mut E, content: Option<&IC> ) -> Result<(), <E as Encoder>::Error>
Render a section with self.
sourcefn apply_section<C>(
&self,
section: SimpleSection<'_, C>
) -> Result<SimpleValue, Box<dyn Error + Sync + Send>>where
C: ContentSequence,
fn apply_section<C>(
&self,
section: SimpleSection<'_, C>
) -> Result<SimpleValue, Box<dyn Error + Sync + Send>>where
C: ContentSequence,
Apply a section with self.
sourcefn render_inverse<C, E, IC>(
&self,
section: Section<'_, C>,
encoder: &mut E,
content: Option<&IC>
) -> Result<(), <E as Encoder>::Error>
fn render_inverse<C, E, IC>( &self, section: Section<'_, C>, encoder: &mut E, content: Option<&IC> ) -> Result<(), <E as Encoder>::Error>
Render a section with self.
sourcefn render_notnone_section<C, E, IC>(
&self,
section: Section<'_, C>,
encoder: &mut E,
content: Option<&IC>
) -> Result<(), <E as Encoder>::Error>
fn render_notnone_section<C, E, IC>( &self, section: Section<'_, C>, encoder: &mut E, content: Option<&IC> ) -> Result<(), <E as Encoder>::Error>
Render a section with self.
sourcefn render_field_escaped<E>(
&self,
_hash: u64,
_name: &str,
_encoder: &mut E
) -> Result<bool, <E as Encoder>::Error>where
E: Encoder,
fn render_field_escaped<E>(
&self,
_hash: u64,
_name: &str,
_encoder: &mut E
) -> Result<bool, <E as Encoder>::Error>where
E: Encoder,
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>(
&self,
_hash: u64,
_name: &str,
_encoder: &mut E
) -> Result<bool, <E as Encoder>::Error>where
E: Encoder,
fn render_field_unescaped<E>(
&self,
_hash: u64,
_name: &str,
_encoder: &mut E
) -> Result<bool, <E as Encoder>::Error>where
E: Encoder,
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 apply_field_unescaped(
&self,
_hash: u64,
_name: &str
) -> Result<SimpleValue, Box<dyn Error + Sync + Send>>
fn apply_field_unescaped( &self, _hash: u64, _name: &str ) -> Result<SimpleValue, Box<dyn Error + Sync + Send>>
sourcefn render_field_section<C, E>(
&self,
_hash: u64,
_name: &str,
_section: Section<'_, C>,
_encoder: &mut E
) -> Result<bool, <E as Encoder>::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 as Encoder>::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 apply_field_section<C>(
&self,
_hash: u64,
_name: &str,
_section: SimpleSection<'_, C>
) -> Result<SimpleValue, Box<dyn Error + Sync + Send>>where
C: ContentSequence,
fn apply_field_section<C>(
&self,
_hash: u64,
_name: &str,
_section: SimpleSection<'_, C>
) -> Result<SimpleValue, Box<dyn Error + Sync + Send>>where
C: ContentSequence,
sourcefn render_field_inverse<C, E>(
&self,
_hash: u64,
_name: &str,
_section: Section<'_, C>,
_encoder: &mut E
) -> Result<bool, <E as Encoder>::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 as Encoder>::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.
sourcefn render_field_notnone_section<C, E>(
&self,
_hash: u64,
_name: &str,
_section: Section<'_, C>,
_encoder: &mut E
) -> Result<bool, <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
fn render_field_notnone_section<C, E>(
&self,
_hash: u64,
_name: &str,
_section: Section<'_, C>,
_encoder: &mut E
) -> Result<bool, <E as Encoder>::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.
Object Safety§
Implementations on Foreign Types§
source§impl Content for str
impl Content for str
fn is_truthy(&self) -> bool
fn capacity_hint(&self, _tpl: &Template) -> usize
fn render_escaped<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
fn render_unescaped<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
fn apply_unescaped(&self) -> Result<SimpleValue, Box<dyn Error + Sync + Send>>
source§impl Content for String
impl Content for String
fn is_truthy(&self) -> bool
fn capacity_hint(&self, _tpl: &Template) -> usize
fn render_escaped<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
fn render_unescaped<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
fn apply_unescaped(&self) -> Result<SimpleValue, Box<dyn Error + Sync + Send>>
source§impl Content for Cow<'_, str, Wide>
impl Content for Cow<'_, str, Wide>
fn is_truthy(&self) -> bool
fn capacity_hint(&self, _tpl: &Template) -> usize
fn render_escaped<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
fn render_unescaped<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
source§impl Content for DateTime<FixedOffset>
impl Content for DateTime<FixedOffset>
fn is_truthy(&self) -> bool
fn capacity_hint(&self, _tpl: &Template) -> usize
fn render_unescaped<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
fn render_escaped<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
fn apply_unescaped(&self) -> Result<SimpleValue, Box<dyn Error + Sync + Send>>
source§impl Content for DateTime<Local>
impl Content for DateTime<Local>
fn is_truthy(&self) -> bool
fn capacity_hint(&self, _tpl: &Template) -> usize
fn render_unescaped<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
fn render_escaped<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
fn apply_unescaped(&self) -> Result<SimpleValue, Box<dyn Error + Sync + Send>>
source§impl Content for DateTime<Utc>
impl Content for DateTime<Utc>
fn is_truthy(&self) -> bool
fn capacity_hint(&self, _tpl: &Template) -> usize
fn render_unescaped<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
fn render_escaped<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
fn apply_unescaped(&self) -> Result<SimpleValue, Box<dyn Error + Sync + Send>>
source§impl Content for NaiveDateTime
impl Content for NaiveDateTime
fn is_truthy(&self) -> bool
fn capacity_hint(&self, _tpl: &Template) -> usize
fn render_unescaped<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
fn render_escaped<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
fn apply_unescaped(&self) -> Result<SimpleValue, Box<dyn Error + Sync + Send>>
source§impl<K, V> Content for BTreeMap<K, V>
impl<K, V> Content for BTreeMap<K, V>
source§fn render_section<C, E, IC>(
&self,
section: Section<'_, C>,
encoder: &mut E,
_content: Option<&IC>
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
fn render_section<C, E, IC>(
&self,
section: Section<'_, C>,
encoder: &mut E,
_content: Option<&IC>
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
Render a section with self.
source§fn render_notnone_section<C, E, IC>(
&self,
section: Section<'_, C>,
encoder: &mut E,
_content: Option<&IC>
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
fn render_notnone_section<C, E, IC>(
&self,
section: Section<'_, C>,
encoder: &mut E,
_content: Option<&IC>
) -> Result<(), <E as Encoder>::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 as Encoder>::Error>where
E: Encoder,
fn render_field_unescaped<E>(
&self,
_: u64,
name: &str,
encoder: &mut E
) -> Result<bool, <E as Encoder>::Error>where
E: Encoder,
fn render_field_section<C, E>(
&self,
_: u64,
name: &str,
section: Section<'_, C>,
encoder: &mut E
) -> Result<bool, <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
fn render_field_notnone_section<C, E>(
&self,
_: u64,
name: &str,
section: Section<'_, C>,
encoder: &mut E
) -> Result<bool, <E as Encoder>::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 as Encoder>::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, IC>(
&self,
section: Section<'_, C>,
encoder: &mut E,
_content: Option<&IC>
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
fn render_section<C, E, IC>(
&self,
section: Section<'_, C>,
encoder: &mut E,
_content: Option<&IC>
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
Render a section with self.
source§fn render_notnone_section<C, E, IC>(
&self,
section: Section<'_, C>,
encoder: &mut E,
_content: Option<&IC>
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
fn render_notnone_section<C, E, IC>(
&self,
section: Section<'_, C>,
encoder: &mut E,
_content: Option<&IC>
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
Render a section with self.