Trait skyline_web::Content
source · pub trait Content {
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 render_cmark<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>
where
E: Encoder,
{ ... }
fn render_section<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>
where
C: ContentSequence,
E: Encoder,
{ ... }
fn render_inverse<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>
where
C: ContentSequence,
E: Encoder,
{ ... }
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 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_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,
{ ... }
}
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 render_cmark<E>(&self, encoder: &mut E) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
fn render_cmark<E>(&self, encoder: &mut E) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
Renders self as a variable to the encoder with CommonMark processing.
The generated HTML is never escaped.
sourcefn render_section<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
fn render_section<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::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 as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
fn render_inverse<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
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 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 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
.
Implementations on Foreign Types
sourceimpl<T> Content for Arc<T>where
T: Content + ?Sized,
impl<T> Content for Arc<T>where
T: Content + ?Sized,
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 render_section<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
fn render_inverse<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
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 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_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,
sourceimpl<T> Content for Option<T>where
T: Content,
impl<T> Content for Option<T>where
T: Content,
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 render_section<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
sourceimpl<T> Content for Box<T, Global>where
T: Content + ?Sized,
impl<T> Content for Box<T, Global>where
T: Content + ?Sized,
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 render_section<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
fn render_inverse<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
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 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_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,
sourceimpl 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,
fn render_cmark<E>(&self, encoder: &mut E) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
sourceimpl<T> Content for Cow<'_, [T], Wide>where
T: Content + Clone + ?Sized,
impl<T> Content for Cow<'_, [T], Wide>where
T: Content + Clone + ?Sized,
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 render_section<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
fn render_inverse<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
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 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_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,
sourceimpl<T> Content for &Twhere
T: Content + ?Sized,
impl<T> Content for &Twhere
T: Content + ?Sized,
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 render_section<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
fn render_inverse<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
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 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_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,
sourceimpl<K, V> Content for BTreeMap<K, V, Global>where
K: Borrow<str> + Ord,
V: Content,
impl<K, V> Content for BTreeMap<K, V, Global>where
K: Borrow<str> + Ord,
V: Content,
sourcefn render_section<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
fn render_section<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> 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_inverse<C, E>(
&self,
_: u64,
name: &str,
section: Section<'_, C>,
encoder: &mut E
) -> Result<bool, <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
sourceimpl 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 render_cmark<E>(&self, encoder: &mut E) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
sourceimpl<T, U> Content for Result<T, U>where
T: Content,
impl<T, U> Content for Result<T, U>where
T: Content,
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 render_section<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
sourceimpl<K, V, S> Content for HashMap<K, V, S>where
K: Borrow<str> + Hash + Eq,
V: Content,
S: BuildHasher,
impl<K, V, S> Content for HashMap<K, V, S>where
K: Borrow<str> + Hash + Eq,
V: Content,
S: BuildHasher,
sourcefn render_section<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
fn render_section<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
Render a section with self.