Enum Node

Source
pub enum Node {
    Comment(Comment),
    Doctype(Doctype),
    Fragment(Fragment),
    Element(Element),
    Text(Text),
    UnsafeText(UnsafeText),
}
Expand description

An HTML node.

Variants§

§

Comment(Comment)

A comment.

<!-- I'm a comment! -->
§

Doctype(Doctype)

A doctype.

<!DOCTYPE html>
§

Fragment(Fragment)

A fragment.

<>
    I'm in a fragment!
</>
§

Element(Element)

An element.

<div class="container">
    I'm in an element!
</div>
§

Text(Text)

A text node.

<div>
    I'm a text node!
</div>
§

UnsafeText(UnsafeText)

An unsafe text node.

§Warning

Node::UnsafeText is not escaped when rendered, and as such, can allow for XSS attacks. Use with caution!

Implementations§

Source§

impl Node

Source

pub const EMPTY: Node

A Node::Fragment with no children.

Source

pub fn from_typed<E>(element: E, children: Option<Vec<Node>>) -> Node
where E: TypedElement,

Create a new Node from a TypedElement.

Source

pub fn pretty(self) -> Pretty

Wrap the node in a pretty-printing wrapper.

Source

pub fn as_children(&self) -> Option<&[Node]>

Borrow the children of the node, if it is an element (with children) or a fragment.

Source

pub fn children_iter(&self) -> impl Iterator<Item = &Node>

Iterate over the children of the node.

Source

pub fn children(self) -> Option<Vec<Node>>

The children of the node, if it is an element (with children) or a fragment.

Source

pub fn into_children(self) -> impl Iterator<Item = Node>

Iterate over the children of the node, consuming it.

Source

pub const fn as_comment(&self) -> Option<&Comment>

Try to get this node as a Comment, if it is one.

Source

pub const fn as_doctype(&self) -> Option<&Doctype>

Try to get this node as a Doctype, if it is one.

Source

pub const fn as_fragment(&self) -> Option<&Fragment>

Try to get this node as a Fragment, if it is one.

Source

pub const fn as_element(&self) -> Option<&Element>

Try to get this node as an Element, if it is one.

Source

pub const fn as_text(&self) -> Option<&Text>

Try to get this node as a Text, if it is one.

Source

pub const fn as_unsafe_text(&self) -> Option<&UnsafeText>

Try to get this node as an UnsafeText, if it is one.

Trait Implementations§

Source§

impl Clone for Node

Source§

fn clone(&self) -> Node

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Node

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Node

Source§

fn default() -> Node

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Node

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Node, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Node

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<Comment> for Node

Source§

fn from(comment: Comment) -> Node

Converts to this type from the input type.
Source§

impl From<Doctype> for Node

Source§

fn from(doctype: Doctype) -> Node

Converts to this type from the input type.
Source§

impl From<Element> for Node

Source§

fn from(element: Element) -> Node

Converts to this type from the input type.
Source§

impl From<Fragment> for Node

Source§

fn from(fragment: Fragment) -> Node

Converts to this type from the input type.
Source§

impl<I, N> From<I> for Node
where I: IntoIterator<Item = N>, N: Into<Node>,

Source§

fn from(iter: I) -> Node

Converts to this type from the input type.
Source§

impl From<Text> for Node

Source§

fn from(text: Text) -> Node

Converts to this type from the input type.
Source§

impl From<UnsafeText> for Node

Source§

fn from(text: UnsafeText) -> Node

Converts to this type from the input type.
Source§

impl IntoResponse for Node

Source§

fn into_response(self) -> Response<UnsyncBoxBody<Bytes, Error>>

Create a response.
Source§

impl PartialEq for Node

Source§

fn eq(&self, other: &Node) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Node

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Node

Source§

impl StructuralPartialEq for Node

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnwindSafe for Node

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T, S, B> Handler<IntoResponseHandler, S, B> for T
where T: IntoResponse + Clone + Send + 'static, B: Send + 'static,

Source§

type Future = Ready<Response<UnsyncBoxBody<Bytes, Error>>>

The type of future calling this handler returns.
Source§

fn call( self, _req: Request<B>, _state: S, ) -> <T as Handler<IntoResponseHandler, S, B>>::Future

Call the handler with the given request.
Source§

fn layer<L, NewReqBody>(self, layer: L) -> Layered<L, Self, T, S, B, NewReqBody>
where L: Layer<HandlerService<Self, T, S, B>> + Clone, <L as Layer<HandlerService<Self, T, S, B>>>::Service: Service<Request<NewReqBody>>,

Apply a tower::Layer to the handler. Read more
Source§

fn with_state(self, state: S) -> HandlerService<Self, T, S, B>

Convert the handler into a Service by providing the state
Source§

impl<H, T, B> HandlerWithoutStateExt<T, B> for H
where H: Handler<T, (), B>,

Source§

fn into_service(self) -> HandlerService<H, T, (), B>

Convert the handler into a Service and no state.
Source§

fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, (), B>>

Convert the handler into a MakeService and no state. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,