pub trait Minify
{
#[inline(always)]
fn debug_fmt<W: fmt::Write>(&self, f: &mut W) -> fmt::Result;
#[inline(always)]
fn debug_string(&self) -> String
{
let mut debug = String::new();
self.debug_fmt(&mut debug).unwrap();
debug
}
#[inline(always)]
fn minify_to_file_path<P: AsRef<Path>>(&self, html_head_and_body_tags_are_optional: bool, collapse_whitespace: bool, html_file_path: P) -> Result<(), HtmlError>;
#[inline(always)]
fn minify_to_string(&self, html_head_and_body_tags_are_optional: bool, collapse_whitespace: bool) -> String
{
let bytes = self.minify_to_bytes(html_head_and_body_tags_are_optional, collapse_whitespace);
String::from_utf8(bytes).unwrap()
}
#[inline(always)]
fn minify_to_bytes(&self, html_head_and_body_tags_are_optional: bool, collapse_whitespace: bool) -> Vec<u8>;
#[inline(always)]
fn minify_to_writer<W: Write>(&self, html_head_and_body_tags_are_optional: bool, collapse_whitespace: bool, writer: W) -> io::Result<()>;
}
impl Minify for RcDom
{
#[inline(always)]
fn debug_fmt<W: fmt::Write>(&self, f: &mut W) -> fmt::Result
{
self.document.debug_fmt(f)
}
#[inline(always)]
fn minify_to_file_path<P: AsRef<Path>>(&self, html_head_and_body_tags_are_optional: bool, collapse_whitespace: bool, html_file_path: P) -> Result<(), HtmlError>
{
self.document.minify_to_file_path(html_head_and_body_tags_are_optional, collapse_whitespace, html_file_path)
}
#[inline(always)]
fn minify_to_bytes(&self, html_head_and_body_tags_are_optional: bool, collapse_whitespace: bool) -> Vec<u8>
{
self.document.minify_to_bytes(html_head_and_body_tags_are_optional, collapse_whitespace)
}
#[inline(always)]
fn minify_to_writer<W: Write>(&self, html_head_and_body_tags_are_optional: bool, collapse_whitespace: bool, writer: W) -> io::Result<()>
{
UltraMinifyingHtmlSerializer::new(html_head_and_body_tags_are_optional, false, false, writer).serialize_rc_dom(self, collapse_whitespace)
}
}
impl Minify for Rc<Node>
{
#[inline(always)]
fn debug_fmt<W: fmt::Write>(&self, f: &mut W) -> fmt::Result
{
write!(f, "{}", self.minify_to_string(true, true))
}
#[inline(always)]
fn minify_to_file_path<P: AsRef<Path>>(&self, html_head_and_body_tags_are_optional: bool, collapse_whitespace: bool, html_file_path: P) -> Result<(), HtmlError>
{
use ::std::fs::File;
let path = html_file_path.as_ref();
let file = File::create(path).context(path)?;
self.minify_to_writer(html_head_and_body_tags_are_optional, collapse_whitespace, file).context(path)?;
Ok(())
}
#[inline(always)]
fn minify_to_bytes(&self, html_head_and_body_tags_are_optional: bool, collapse_whitespace: bool) -> Vec<u8>
{
let mut bytes = Vec::new();
self.minify_to_writer(html_head_and_body_tags_are_optional, collapse_whitespace, &mut bytes).unwrap();
bytes
}
#[inline(always)]
fn minify_to_writer<W: Write>(&self, html_head_and_body_tags_are_optional: bool, collapse_whitespace: bool, writer: W) -> io::Result<()>
{
UltraMinifyingHtmlSerializer::new(html_head_and_body_tags_are_optional, false, false, writer).serialize_node(self, collapse_whitespace, true)
}
}