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
impl Node
Sourcepub const EMPTY: Node
pub const EMPTY: Node
A Node::Fragment
with no children.
Sourcepub fn from_typed<E>(element: E, children: Option<Vec<Node>>) -> Nodewhere
E: TypedElement,
pub fn from_typed<E>(element: E, children: Option<Vec<Node>>) -> Nodewhere
E: TypedElement,
Create a new Node
from a TypedElement
.
Sourcepub fn as_children(&self) -> Option<&[Node]>
pub fn as_children(&self) -> Option<&[Node]>
Borrow the children of the node, if it is an element (with children) or a fragment.
Sourcepub fn children_iter(&self) -> impl Iterator<Item = &Node>
pub fn children_iter(&self) -> impl Iterator<Item = &Node>
Iterate over the children of the node.
Sourcepub fn children(self) -> Option<Vec<Node>>
pub fn children(self) -> Option<Vec<Node>>
The children of the node, if it is an element (with children) or a fragment.
Sourcepub fn into_children(self) -> impl Iterator<Item = Node>
pub fn into_children(self) -> impl Iterator<Item = Node>
Iterate over the children of the node, consuming it.
Sourcepub const fn as_comment(&self) -> Option<&Comment>
pub const fn as_comment(&self) -> Option<&Comment>
Try to get this node as a Comment
, if it is one.
Sourcepub const fn as_doctype(&self) -> Option<&Doctype>
pub const fn as_doctype(&self) -> Option<&Doctype>
Try to get this node as a Doctype
, if it is one.
Sourcepub const fn as_fragment(&self) -> Option<&Fragment>
pub const fn as_fragment(&self) -> Option<&Fragment>
Try to get this node as a Fragment
, if it is one.
Sourcepub const fn as_element(&self) -> Option<&Element>
pub const fn as_element(&self) -> Option<&Element>
Try to get this node as an Element
, if it is one.
Sourcepub const fn as_unsafe_text(&self) -> Option<&UnsafeText>
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<'de> Deserialize<'de> for Node
impl<'de> Deserialize<'de> for Node
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Node, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Node, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<UnsafeText> for Node
impl From<UnsafeText> for Node
Source§fn from(text: UnsafeText) -> Node
fn from(text: UnsafeText) -> Node
Source§impl IntoResponse for Node
impl IntoResponse for Node
Source§fn into_response(self) -> Response<UnsyncBoxBody<Bytes, Error>>
fn into_response(self) -> Response<UnsyncBoxBody<Bytes, Error>>
Source§impl Serialize for Node
impl Serialize for Node
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for Node
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, S, B> Handler<IntoResponseHandler, S, B> for T
impl<T, S, B> Handler<IntoResponseHandler, S, B> for T
Source§type Future = Ready<Response<UnsyncBoxBody<Bytes, Error>>>
type Future = Ready<Response<UnsyncBoxBody<Bytes, Error>>>
Source§fn call(
self,
_req: Request<B>,
_state: S,
) -> <T as Handler<IntoResponseHandler, S, B>>::Future
fn call( self, _req: Request<B>, _state: S, ) -> <T as Handler<IntoResponseHandler, S, B>>::Future
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>>,
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>>,
tower::Layer
to the handler. Read moreSource§fn with_state(self, state: S) -> HandlerService<Self, T, S, B>
fn with_state(self, state: S) -> HandlerService<Self, T, S, B>
Service
by providing the stateSource§impl<H, T, B> HandlerWithoutStateExt<T, B> for H
impl<H, T, B> HandlerWithoutStateExt<T, B> for H
Source§fn into_service(self) -> HandlerService<H, T, (), B>
fn into_service(self) -> HandlerService<H, T, (), B>
Service
and no state.Source§fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, (), B>>
fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, (), B>>
MakeService
and no state. Read more