Skip to main content

AttrValueAdapter

Struct AttrValueAdapter 

Source
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>

Source

pub fn get_mut_inner(&mut self) -> &mut T

Source§

impl<T> AttrValueAdapter<T>

Source

pub fn new(inner: T) -> Self

Source§

impl<F> AttrValueAdapter<F>
where F: FnMut(Event) + 'static,

Adapts a FnMut(Event) 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().

Source

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

pub fn into_callback_attribute_value_with_name( self, name: &'static str, ) -> AttributeValue

Converts the wrapped closure into a callback AttributeValue with a custom event name for component props.

§Arguments
  • &'static str - The custom attribute name (e.g., “on-increment”, “on-change”).
§Returns
  • AttributeValue - An event attribute value with the custom name.
Source§

impl AttrValueAdapter<NativeEventHandler>

Adapts an owned NativeEventHandler into an AttributeValue::Event directly.

Source

pub fn into_callback_attribute_value(self) -> AttributeValue

Converts the wrapped handler into an event AttributeValue.

§Returns
  • AttributeValue - An AttributeValue::Event containing the re-wrapped handler.
Source

pub fn into_callback_attribute_value_with_name( self, name: &'static str, ) -> AttributeValue

Converts the wrapped handler into a callback AttributeValue with a custom event name for component props.

§Arguments
  • &'static str - The custom attribute name.
§Returns
  • AttributeValue - An event attribute value with the custom name.
Source§

impl AttrValueAdapter<Option<NativeEventHandler>>

Adapts an Option<NativeEventHandler> into an AttributeValue.

Source

pub fn into_callback_attribute_value(self) -> AttributeValue

Converts the wrapped optional handler into an attribute value.

§Returns
  • AttributeValue - An event attribute if Some, otherwise an empty text attribute.
Source

pub fn into_callback_attribute_value_with_name( self, name: &'static str, ) -> AttributeValue

Converts this optional handler into a callback AttributeValue with a custom event name for component props.

§Arguments
  • &'static str - The custom attribute name.
§Returns
  • AttributeValue - An event attribute with the custom name if Some, otherwise an empty text attribute.
Source§

impl<T> AttrValueAdapter<T>

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().

Source

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.

Trait Implementations§

Source§

impl<T: Debug> Debug for AttrValueAdapter<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for AttrValueAdapter<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for AttrValueAdapter<T>
where T: RefUnwindSafe,

§

impl<T> Send for AttrValueAdapter<T>
where T: Send,

§

impl<T> Sync for AttrValueAdapter<T>
where T: Sync,

§

impl<T> Unpin for AttrValueAdapter<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for AttrValueAdapter<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for AttrValueAdapter<T>
where T: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more