pub struct AttrValueAdapter<T> { /* private fields */ }Expand description
Adapts an arbitrary attribute value expression into an AttributeValue.
Handles the dispatch between event closures and reactive values without
requiring the macro to generate inline trait hierarchies. The macro emits
AttrValueAdapter::new(expr).into_attribute_value() instead of the
__IsClosure / __ClosurePicker / __ValuePicker / __FallbackHelper
/ __dispatch boilerplate.
For event attributes (key starts with “on”), event closures are wrapped
into AttributeValue::Event. For non-event attributes, values are
converted via IntoReactiveValue.
Implementations§
Source§impl<T> AttrValueAdapter<T>
Constructs an AttrValueAdapter that wraps any attribute-compatible value.
impl<T> AttrValueAdapter<T>
Constructs an AttrValueAdapter that wraps any attribute-compatible value.
Source§impl<F> AttrValueAdapter<F>where
F: FnMut(NativeEvent) + 'static,
Adapts a FnMut(NativeEvent) closure into a callback AttributeValue.
impl<F> AttrValueAdapter<F>where
F: FnMut(NativeEvent) + 'static,
Adapts a FnMut(NativeEvent) closure into a callback AttributeValue.
This handles the case where a closure is used as a component callback prop.
The closure is converted via IntoCallbackAttribute::into_callback_attribute().
This replaces the __IsClosure for F impl that was previously generated inline.
Sourcepub fn into_callback_attribute_value(self) -> AttributeValue
pub fn into_callback_attribute_value(self) -> AttributeValue
Converts the wrapped closure into a callback AttributeValue.
§Returns
AttributeValue- An event attribute value wrapping the adapted closure.
Source§impl AttrValueAdapter<NativeEventHandler>
Adapts an owned NativeEventHandler into an AttributeValue::Event directly.
impl AttrValueAdapter<NativeEventHandler>
Adapts an owned NativeEventHandler into an AttributeValue::Event directly.
When the user already provides a NativeEventHandler, it is returned as-is.
This replaces the __IsClosure for NativeEventHandler impl that was previously
generated inline by the html! macro.
Sourcepub fn into_callback_attribute_value(self) -> AttributeValue
pub fn into_callback_attribute_value(self) -> AttributeValue
Converts the wrapped handler into an event AttributeValue.
§Returns
AttributeValue- AnAttributeValue::Eventcontaining the handler.
Source§impl AttrValueAdapter<Option<NativeEventHandler>>
Adapts an Option<NativeEventHandler> into an AttributeValue.
impl AttrValueAdapter<Option<NativeEventHandler>>
Adapts an Option<NativeEventHandler> into an AttributeValue.
Some(handler) becomes AttributeValue::Event(handler), and None becomes
AttributeValue::Text(String::new()). This replaces the
__IsClosure for Option<NativeEventHandler> impl that was previously
generated inline by the html! macro.
Sourcepub fn into_callback_attribute_value(self) -> AttributeValue
pub fn into_callback_attribute_value(self) -> AttributeValue
Converts the wrapped optional handler into an attribute value.
§Returns
AttributeValue- An event attribute ifSome, otherwise an empty text attribute.
Source§impl<T> AttrValueAdapter<T>where
T: IntoReactiveValue,
Adapts any IntoReactiveValue type into an AttributeValue.
impl<T> AttrValueAdapter<T>where
T: IntoReactiveValue,
Adapts any IntoReactiveValue type into an AttributeValue.
This is the fallback path for non-closure attribute values (strings, signals,
CSS classes, etc.). The value is converted via IntoReactiveValue::into_reactive_value().
This replaces the __ValuePicker / __FallbackHelper hierarchy that was previously
generated inline by the html! macro.
Sourcepub fn into_reactive_attribute_value(self) -> AttributeValue
pub fn into_reactive_attribute_value(self) -> AttributeValue
Converts the wrapped value into an AttributeValue via reactive value adaptation.
§Returns
AttributeValue- The reactive attribute value.