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

View file

@ -72,6 +72,9 @@ impl Body {
#[cfg(feature = "gemtext")] #[cfg(feature = "gemtext")]
#[allow(clippy::fallible_impl_from)] // It's really not fallible but thanks #[allow(clippy::fallible_impl_from)] // It's really not fallible but thanks
impl From<Vec<gemtext::Node>> for Body { 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 { fn from(document: Vec<gemtext::Node>) -> Self {
let size: usize = document.iter().map(gemtext::Node::estimate_len).sum(); let size: usize = document.iter().map(gemtext::Node::estimate_len).sum();
let mut bytes = Vec::with_capacity(size + document.len()); let mut bytes = Vec::with_capacity(size + document.len());
@ -82,6 +85,9 @@ impl From<Vec<gemtext::Node>> for Body {
#[cfg(feature = "gemtext")] #[cfg(feature = "gemtext")]
impl From<Gemtext> for Body { 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 { fn from(document: Gemtext) -> Self {
document.normalize().build().into() document.normalize().build().into()
} }