Stuck some more documentation on gemtext -> body conversion methods

This commit is contained in:
Emi Tatsuo 2020-12-08 19:19:23 -05:00
parent 367cc17e8f
commit ffc86af284
Signed by: Emi
GPG Key ID: 68FAB2E2E6DFC98B
1 changed files with 6 additions and 0 deletions

View File

@ -72,6 +72,9 @@ impl Body {
#[cfg(feature = "gemtext")]
#[allow(clippy::fallible_impl_from)] // It's really not fallible but thanks
impl From<Vec<gemtext::Node>> for Body {
/// Render a series of [`gemtext`] nodes to a `text/gemini` body without [normalizing]
///
/// [normalizing]: Gemtext::normalize
fn from(document: Vec<gemtext::Node>) -> Self {
let size: usize = document.iter().map(gemtext::Node::estimate_len).sum();
let mut bytes = Vec::with_capacity(size + document.len());
@ -82,6 +85,9 @@ impl From<Vec<gemtext::Node>> for Body {
#[cfg(feature = "gemtext")]
impl From<Gemtext> for Body {
/// [Normalize][1] & eender a series of [`gemtext`] nodes to a `text/gemini` body
///
/// [1]: Gemtext::normalize
fn from(document: Gemtext) -> Self {
document.normalize().build().into()
}