pub struct Element<'t> { /* private fields */ }html only.Expand description
A matched element, for inspection and mutation by a handler.
Start-anchored edits (before, prepend, attribute changes) take
effect at the start tag; end-anchored edits (append, after,
set_inner_content, replace, remove,
remove_and_keep_content) are deferred to the matching end tag by the
rewriter.
Implementations§
Source§impl<'t> Element<'t>
impl<'t> Element<'t>
Sourcepub fn tag(&self) -> HtmlTag<'_>
pub fn tag(&self) -> HtmlTag<'_>
The element’s HtmlTag — a known element variant, or
HtmlTag::Other (the original-case name) for a custom tag.
Sourcepub fn attribute(&self, name: &str) -> Option<&[u8]>
pub fn attribute(&self, name: &str) -> Option<&[u8]>
The value of the attribute with the given (ASCII case-insensitive)
name, or None if absent. A valueless attribute reports Some(b"").
Sourcepub fn has_attribute(&self, name: &str) -> bool
pub fn has_attribute(&self, name: &str) -> bool
Whether the element has the given attribute.
Sourcepub fn set_attribute(&mut self, name: AttributeName, value: &str)
pub fn set_attribute(&mut self, name: AttributeName, value: &str)
Sets (or adds) an attribute. The AttributeName is pre-validated, so
it cannot inject markup; the value is escaped on render.
Sourcepub fn remove_attribute(&mut self, name: &str)
pub fn remove_attribute(&mut self, name: &str)
Removes the attribute with the given (ASCII case-insensitive) name.
Sourcepub fn before(&mut self, content: impl IntoHtml)
pub fn before(&mut self, content: impl IntoHtml)
Inserts content immediately before the element’s start tag.
Accepts any IntoHtml value: plain strings are escaped; wrap
trusted HTML in PreEscaped to emit it
verbatim.
Sourcepub fn prepend(&mut self, content: impl IntoHtml)
pub fn prepend(&mut self, content: impl IntoHtml)
Inserts content as the element’s first children (immediately after the
start tag). Escaping follows before.
Sourcepub fn append(&mut self, content: impl IntoHtml)
pub fn append(&mut self, content: impl IntoHtml)
Inserts content as the element’s last children (immediately before the
end tag). Escaping follows before.
Sourcepub fn after(&mut self, content: impl IntoHtml)
pub fn after(&mut self, content: impl IntoHtml)
Inserts content immediately after the element’s end tag. Escaping
follows before.
Sourcepub fn set_inner_content(&mut self, content: impl IntoHtml)
pub fn set_inner_content(&mut self, content: impl IntoHtml)
Replaces the element’s children, keeping the start and end tags (and
any attribute edits). Escaping follows before.
Sourcepub fn replace(&mut self, content: impl IntoHtml)
pub fn replace(&mut self, content: impl IntoHtml)
Replaces the whole element (start tag through end tag). Escaping
follows before.
Sourcepub fn remove_and_keep_content(&mut self)
pub fn remove_and_keep_content(&mut self)
Removes only the element’s start and end tags, leaving its children in place.
Sourcepub fn is_removed(&self) -> bool
pub fn is_removed(&self) -> bool
Whether a remove /
remove_and_keep_content /
replace disposition is in effect.
Auto Trait Implementations§
impl<'t> Freeze for Element<'t>
impl<'t> RefUnwindSafe for Element<'t>
impl<'t> Send for Element<'t>
impl<'t> Sync for Element<'t>
impl<'t> Unpin for Element<'t>
impl<'t> UnsafeUnpin for Element<'t>
impl<'t> UnwindSafe for Element<'t>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more