Struct Element
pub struct Element<'t> { /* private fields */ }html and http 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§
§impl<'t> Element<'t>
impl<'t> Element<'t>
pub 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.
pub 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"").
pub fn has_attribute(&self, name: &str) -> bool
pub fn has_attribute(&self, name: &str) -> bool
Whether the element has the given attribute.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub fn remove(&mut self)
pub fn remove(&mut self)
Removes the whole element, children included.
pub 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.
pub 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§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more§impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>
§impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
type Error = <U as RamaTryFrom<T, CrateMarker>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<V, F> ValueFormatter<&V> for F
impl<V, F> ValueFormatter<&V> for F
§fn format_value(writer: impl ValueWriter, value: &&V)
fn format_value(writer: impl ValueWriter, value: &&V)
value to writer§impl<V, F> ValueFormatter<Arc<V>> for F
impl<V, F> ValueFormatter<Arc<V>> for F
§fn format_value(writer: impl ValueWriter, value: &Arc<V>)
fn format_value(writer: impl ValueWriter, value: &Arc<V>)
value to writer§impl<V, F> ValueFormatter<Box<V>> for F
impl<V, F> ValueFormatter<Box<V>> for F
§fn format_value(writer: impl ValueWriter, value: &Box<V>)
fn format_value(writer: impl ValueWriter, value: &Box<V>)
value to writer§impl<V, F> ValueFormatter<Cow<'_, V>> for F
impl<V, F> ValueFormatter<Cow<'_, V>> for F
§fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
value to writer§impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
§fn format_value(writer: impl ValueWriter, value: &Option<V>)
fn format_value(writer: impl ValueWriter, value: &Option<V>)
value to writer