Trait Props

Source
pub trait Props {
    type Builder;

    // Required method
    fn builder() -> Self::Builder;
}
Expand description

A trait that is implemented automatically by the Props derive macro.

This is used when constructing components in the view! macro.

§Example

Deriving an implementation and using the builder to construct an instance of the struct:

#[derive(Props)]
struct ButtonProps {
    color: String,
    disabled: bool,
}

let builder = <ButtonProps as Props>::builder();
let button_props = builder.color("red".to_string()).disabled(false).build();

Required Associated Types§

Source

type Builder

The type of the builder. This allows getting the builder type when the name is unknown (e.g. in a macro).

Required Methods§

Source

fn builder() -> Self::Builder

Returns the builder for the type. The builder should be automatically generated using the Props derive macro.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Props for ()

Make sure that the Props trait is implemented for () so that components without props can be thought as accepting props of type ().

Source§

type Builder = UnitBuilder

Source§

fn builder() -> Self::Builder

Implementors§

impl<R, F> Props for StaticRouterProps<R, F>
where R: Route + 'static, F: Fn(ReadSignal<R>) -> View + 'static,

impl<R, F, I> Props for RouterBaseProps<R, F, I>
where R: Route + 'static, F: FnOnce(ReadSignal<R>) -> View + 'static, I: Integration,

impl<R, F, I> Props for RouterProps<R, F, I>
where R: Route + 'static, F: FnOnce(ReadSignal<R>) -> View + 'static, I: Integration,

impl Props for ShowProps

impl<'a, T: Into<View> + Default> Props for Portal_Props<'a, T>

impl<T, K, U, List, F, Key> Props for KeyedProps<T, K, U, List, F, Key>
where List: Into<MaybeDyn<Vec<T>>> + 'static, F: Fn(T) -> U + 'static, Key: Fn(&T) -> K + 'static, T: 'static,

impl<T, U, List, F> Props for IndexedProps<T, U, List, F>
where List: Into<MaybeDyn<Vec<T>>> + 'static, F: Fn(T) -> U + 'static, T: 'static,