Trait HtmlStr

Source
pub trait HtmlStr {
    const TAG_DOCTYPE_PAT: &'static str = "<!doctype";
    const TAG_DOCTYPE_HTML_PAT: &'static str = "<!doctype html";
    const TAG_DOCTYPE_HTML: &'static str = "<!DOCTYPE html>";
    const START_TAG_HTML_PAT: &'static str = "<html";
    const END_TAG_HTML: &'static str = "</html>";

    // Required methods
    fn is_empty_html(&self) -> bool;
    fn has_html_start_tag(&self) -> bool;
    fn is_html_unchecked(&self) -> bool;

    // Provided methods
    fn is_empty_html2(html: &str) -> bool { ... }
    fn has_html_start_tag2(html: &str) -> bool { ... }
}
Expand description

This trait deals with tagged HTML &str data.

Provided Associated Constants§

Source

const TAG_DOCTYPE_PAT: &'static str = "<!doctype"

Lowercase pattern to check if this is a Doctype tag.

Source

const TAG_DOCTYPE_HTML_PAT: &'static str = "<!doctype html"

Lowercase pattern to check if this Doctype is HTML.

Source

const TAG_DOCTYPE_HTML: &'static str = "<!DOCTYPE html>"

Doctype HTML tag. This is inserted by <HtmlString>.prepend_html_start_tag()

Source

const START_TAG_HTML_PAT: &'static str = "<html"

Pattern to check if f this is an HTML start tag.

Source

const END_TAG_HTML: &'static str = "</html>"

HTML end tag.

Required Methods§

Source

fn is_empty_html(&self) -> bool

We consider self empty, when it equals to <!DOCTYPE html...> or when it is empty.

Source

fn has_html_start_tag(&self) -> bool

True if stream starts with <!DOCTYPE html...>.

Source

fn is_html_unchecked(&self) -> bool

Some heuristics to guess if the input stream contains HTML. Current implementation: True if:

  • The stream starts with <!DOCTYPE html ...>, or
  • the stream starts with <html ...>

This function does not check if the recognized HTML is valid.

Provided Methods§

Source

fn is_empty_html2(html: &str) -> bool

We consider html empty, when it equals to <!DOCTYPE html...> or when it is empty. This is identical to is_empty_html(), but does not pull in additional trait bounds.

Source

fn has_html_start_tag2(html: &str) -> bool

True if html starts with <!DOCTYPE html...>. This is identical to has_html_start_tag(), but does not pull in additional trait bounds.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl HtmlStr for str

Implementors§