Struct Node

Source
pub struct Node<'a> { /* private fields */ }
Expand description

An HTML element.

An open-tag is written to the buffer when a Node is created, and a close-tag is written when the Node is dropped. You can set attributes on a newly-created node using attr(), create child nodes with child(), and write text into the node using the Write impl.

§Escaping

Text written into a node using its Write impl is transformed to make it render correctly in an HTML-context. By default, the following characters are escaped: &, <, and >. The escaping can be strengthened or weakened using the safe() and raw() methods respectively.

Implementations§

Source§

impl<'a> Node<'a>

Source

pub fn child<'b>(&'b mut self, tag: Cow<'static, str>) -> Node<'b>

Source

pub fn void_child<'b>(&'b mut self, tag: Cow<'static, str>) -> Void<'b>

Source

pub fn comment<'b>(&'b mut self) -> Comment<'b>

Source

pub fn attr(self, attr: &str) -> Node<'a>

Source

pub fn raw(self) -> Node<'a>

Disable escaping

In this mode, written text is passed through unmodified.

Source

pub fn safe(self) -> Node<'a>

Escape more special characters

In this mode, the following characters are escaped: &, <, >, ", ', and /.

Trait Implementations§

Source§

impl<'a> Html5 for Node<'a>

Source§

fn doctype(&mut self)

Defines the document type

Source§

fn a(&mut self) -> Node<'_>

Defines a hyperlink

Source§

fn abbr(&mut self) -> Node<'_>

Defines an abbreviation or an acronym

Source§

fn address(&mut self) -> Node<'_>

Defines contact information for the author/owner of a document

Source§

fn area(&mut self) -> Void<'_>

Defines an area inside an image map

Source§

fn article(&mut self) -> Node<'_>

Defines an article

Source§

fn aside(&mut self) -> Node<'_>

Defines content aside from the page content

Source§

fn audio(&mut self) -> Node<'_>

Defines embedded sound content

Source§

fn b(&mut self) -> Node<'_>

Defines bold text

Source§

fn base(&mut self) -> Void<'_>

Specifies the base URL/target for all relative URLs in a document

Source§

fn bdi(&mut self) -> Node<'_>

Isolates a part of text that might be formatted in a different direction from other text outside it

Source§

fn bdo(&mut self) -> Node<'_>

Overrides the current text direction

Source§

fn blockquote(&mut self) -> Node<'_>

Defines a section that is quoted from another source

Source§

fn body(&mut self) -> Node<'_>

Defines the document’s body

Source§

fn br(&mut self) -> Void<'_>

Defines a single line break

Source§

fn button(&mut self) -> Node<'_>

Defines a clickable button

Source§

fn canvas(&mut self) -> Node<'_>

Used to draw graphics, on the fly, via scripting (usually JavaScript)

Source§

fn caption(&mut self) -> Node<'_>

Defines a table caption

Source§

fn cite(&mut self) -> Node<'_>

Defines the title of a work

Source§

fn code(&mut self) -> Node<'_>

Defines a piece of computer code

Source§

fn col(&mut self) -> Void<'_>

Specifies column properties for each column within a <colgroup> element

Source§

fn colgroup(&mut self) -> Node<'_>

Specifies a group of one or more columns in a table for formatting

Source§

fn data(&mut self) -> Node<'_>

Adds a machine-readable translation of a given content

Source§

fn datalist(&mut self) -> Node<'_>

Specifies a list of pre-defined options for input controls

Source§

fn dd(&mut self) -> Node<'_>

Defines a description/value of a term in a description list

Source§

fn del(&mut self) -> Node<'_>

Defines text that has been deleted from a document

Source§

fn details(&mut self) -> Node<'_>

Defines additional details that the user can view or hide

Source§

fn dfn(&mut self) -> Node<'_>

Specifies a term that is going to be defined within the content

Source§

fn dialog(&mut self) -> Node<'_>

Defines a dialog box or window

Source§

fn div(&mut self) -> Node<'_>

Defines a section in a document

Source§

fn dl(&mut self) -> Node<'_>

Defines a description list

Source§

fn dt(&mut self) -> Node<'_>

Defines a term/name in a description list

Source§

fn em(&mut self) -> Node<'_>

Defines emphasized text

Source§

fn embed(&mut self) -> Void<'_>

Defines a container for an external application

Source§

fn fieldset(&mut self) -> Node<'_>

Groups related elements in a form

Source§

fn figcaption(&mut self) -> Node<'_>

Defines a caption for a <figure> element

Source§

fn figure(&mut self) -> Node<'_>

Specifies self-contained content

Source§

fn footer(&mut self) -> Node<'_>

Defines a footer for a document or section

Source§

fn form(&mut self) -> Node<'_>

Defines an HTML form for user input

Source§

fn h1(&mut self) -> Node<'_>

Defines HTML headings

Source§

fn h2(&mut self) -> Node<'_>

Defines HTML headings

Source§

fn h3(&mut self) -> Node<'_>

Defines HTML headings

Source§

fn h4(&mut self) -> Node<'_>

Defines HTML headings

Source§

fn h5(&mut self) -> Node<'_>

Defines HTML headings

Source§

fn h6(&mut self) -> Node<'_>

Defines HTML headings

Source§

fn head(&mut self) -> Node<'_>

Contains metadata/information for the document

Source§

fn header(&mut self) -> Node<'_>

Defines a header for a document or section

Source§

fn hr(&mut self) -> Void<'_>

Defines a thematic change in the content

Source§

fn html(&mut self) -> Node<'_>

Defines the root of an HTML document

Source§

fn i(&mut self) -> Node<'_>

Defines a part of text in an alternate voice or mood

Source§

fn iframe(&mut self) -> Node<'_>

Defines an inline frame

Source§

fn img(&mut self) -> Void<'_>

Defines an image

Source§

fn input(&mut self) -> Void<'_>

Defines an input control

Source§

fn ins(&mut self) -> Node<'_>

Defines a text that has been inserted into a document

Source§

fn kbd(&mut self) -> Node<'_>

Defines keyboard input

Source§

fn label(&mut self) -> Node<'_>

Defines a label for an <input> element

Source§

fn legend(&mut self) -> Node<'_>

Defines a caption for a <fieldset> element

Source§

fn li(&mut self) -> Node<'_>

Defines a list item

Defines the relationship between a document and an external resource (most used to link to style sheets)

Source§

fn main(&mut self) -> Node<'_>

Specifies the main content of a document

Source§

fn map(&mut self) -> Node<'_>

Defines an image map

Source§

fn mark(&mut self) -> Node<'_>

Defines marked/highlighted text

Source§

fn meta(&mut self) -> Void<'_>

Defines metadata about an HTML document

Source§

fn meter(&mut self) -> Node<'_>

Defines a scalar measurement within a known range (a gauge)

Source§

fn nav(&mut self) -> Node<'_>

Defines navigation links

Source§

fn noscript(&mut self) -> Node<'_>

Defines an alternate content for users that do not support client-side scripts

Source§

fn object(&mut self) -> Node<'_>

Defines a container for an external application

Source§

fn ol(&mut self) -> Node<'_>

Defines an ordered list

Source§

fn optgroup(&mut self) -> Node<'_>

Defines a group of related options in a drop-down list

Source§

fn option(&mut self) -> Node<'_>

Defines an option in a drop-down list

Source§

fn output(&mut self) -> Node<'_>

Defines the result of a calculation

Source§

fn p(&mut self) -> Node<'_>

Defines a paragraph

Source§

fn param(&mut self) -> Void<'_>

Defines a parameter for an object

Source§

fn picture(&mut self) -> Node<'_>

Defines a container for multiple image resources

Source§

fn pre(&mut self) -> Node<'_>

Defines preformatted text

Source§

fn progress(&mut self) -> Node<'_>

Represents the progress of a task

Source§

fn q(&mut self) -> Node<'_>

Defines a short quotation

Source§

fn rp(&mut self) -> Node<'_>

Defines what to show in browsers that do not support ruby annotations

Source§

fn rt(&mut self) -> Node<'_>

Defines an explanation/pronunciation of characters (for East Asian typography)

Source§

fn ruby(&mut self) -> Node<'_>

Defines a ruby annotation (for East Asian typography)

Source§

fn s(&mut self) -> Node<'_>

Defines text that is no longer correct

Source§

fn samp(&mut self) -> Node<'_>

Defines sample output from a computer program

Source§

fn script(&mut self) -> Node<'_>

Defines a client-side script

Source§

fn section(&mut self) -> Node<'_>

Defines a section in a document

Source§

fn select(&mut self) -> Node<'_>

Defines a drop-down list

Source§

fn small(&mut self) -> Node<'_>

Defines smaller text

Source§

fn source(&mut self) -> Void<'_>

Defines multiple media resources for media elements (<video> and <audio>)

Source§

fn span(&mut self) -> Node<'_>

Defines a section in a document

Source§

fn strong(&mut self) -> Node<'_>

Defines important text

Source§

fn style(&mut self) -> Node<'_>

Defines style information for a document

Source§

fn sub(&mut self) -> Node<'_>

Defines subscripted text

Source§

fn summary(&mut self) -> Node<'_>

Defines a visible heading for a <details> element

Source§

fn sup(&mut self) -> Node<'_>

Defines superscripted text

Source§

fn svg(&mut self) -> Node<'_>

Defines a container for SVG graphics

Source§

fn table(&mut self) -> Node<'_>

Defines a table

Source§

fn tbody(&mut self) -> Node<'_>

Groups the body content in a table

Source§

fn td(&mut self) -> Node<'_>

Defines a cell in a table

Source§

fn template(&mut self) -> Node<'_>

Defines a container for content that should be hidden when the page loads

Source§

fn textarea(&mut self) -> Node<'_>

Defines a multiline input control (text area)

Source§

fn tfoot(&mut self) -> Node<'_>

Groups the footer content in a table

Source§

fn th(&mut self) -> Node<'_>

Defines a header cell in a table

Source§

fn thead(&mut self) -> Node<'_>

Groups the header content in a table

Source§

fn time(&mut self) -> Node<'_>

Defines a specific time (or datetime)

Source§

fn title(&mut self) -> Node<'_>

Defines a title for the document

Source§

fn tr(&mut self) -> Node<'_>

Defines a row in a table

Source§

fn track(&mut self) -> Void<'_>

Defines text tracks for media elements (<video> and <audio>)

Source§

fn u(&mut self) -> Node<'_>

Defines some text that is unarticulated and styled differently from normal text

Source§

fn ul(&mut self) -> Node<'_>

Defines an unordered list

Source§

fn var(&mut self) -> Node<'_>

Defines a variable

Source§

fn video(&mut self) -> Node<'_>

Defines embedded video content

Source§

fn wbr(&mut self) -> Void<'_>

Defines a possible line-break

Source§

impl<'a> Write for Node<'a>

Source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · Source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Node<'a>

§

impl<'a> RefUnwindSafe for Node<'a>

§

impl<'a> Send for Node<'a>

§

impl<'a> Sync for Node<'a>

§

impl<'a> Unpin for Node<'a>

§

impl<'a> UnwindSafe for Node<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.