Trait freya::prelude::Properties

pub trait Properties: Sized {
    type Builder;

    const IS_STATIC: bool;

    // Required methods
    fn builder() -> Self::Builder;
    unsafe fn memoize(&self, other: &Self) -> bool;
}
Expand description

Every “Props” used for a component must implement the Properties trait. This trait gives some hints to Dioxus on how to memoize the props and some additional optimizations that can be made. We strongly encourage using the derive macro to implement the Properties trait automatically as guarantee that your memoization strategy is safe.

If your props are ’static, then Dioxus will require that they also be PartialEq for the derived memoize strategy. However, if your props borrow data, then the memoization strategy will simply default to “false” and the PartialEq will be ignored. This tends to be useful when props borrow something that simply cannot be compared (IE a reference to a closure);

By default, the memoization strategy is very conservative, but can be tuned to be more aggressive manually. However, this is only safe if the props are ’static - otherwise you might borrow references after-free.

We strongly suggest that any changes to memoization be done at the “PartialEq” level for ’static props. Additionally, we advise the use of smart pointers in cases where memoization is important.

Example

For props that are ’static:

#[derive(Props, PartialEq)]
struct MyProps {
    data: String
}

For props that borrow:

#[derive(Props)]
struct MyProps<'a >{
    data: &'a str
}

Required Associated Types§

type Builder

The type of the builder for this component. Used to create “in-progress” versions of the props.

Required Associated Constants§

const IS_STATIC: bool

An indication if these props are can be memoized automatically.

Required Methods§

fn builder() -> Self::Builder

Create a builder for this component.

unsafe fn memoize(&self, other: &Self) -> bool

Memoization can only happen if the props are valid for the ’static lifetime

Safety

The user must know if their props are static, but if they make a mistake, UB happens Therefore it’s unsafe to memoize.

Implementations on Foreign Types§

§

impl Properties for ()

§

type Builder = EmptyBuilder

§

const IS_STATIC: bool = true

§

fn builder() -> <() as Properties>::Builder

§

unsafe fn memoize(&self, _other: &()) -> bool

Implementors§

source§

impl Properties for CanvasProps

§

type Builder = CanvasPropsBuilder<((), (), (), ())>

source§

const IS_STATIC: bool = true

source§

impl Properties for GraphProps

§

type Builder = GraphPropsBuilder<((), (), (), ())>

source§

const IS_STATIC: bool = true

source§

impl Properties for LoaderProps

§

type Builder = LoaderPropsBuilder<()>

source§

const IS_STATIC: bool = true

source§

impl Properties for ProgressBarProps

§

type Builder = ProgressBarPropsBuilder<((), (), (), ())>

source§

const IS_STATIC: bool = true

source§

impl<'a> Properties for AccordionBodyProps<'a>

§

type Builder = AccordionBodyPropsBuilder<'a, ((),)>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for AccordionProps<'a>

§

type Builder = AccordionPropsBuilder<'a, ((), ())>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for AccordionSummaryProps<'a>

§

type Builder = AccordionSummaryPropsBuilder<'a, ((),)>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for ButtonProps<'a>

§

type Builder = ButtonPropsBuilder<'a, ((), (), (), (), (), (), ())>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for CursorAreaProps<'a>

§

type Builder = CursorAreaPropsBuilder<'a, ((), ())>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for DragProviderProps<'a>

§

type Builder = DragProviderPropsBuilder<'a, ((),)>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for ExternalLinkProps<'a>

§

type Builder = ExternalLinkPropsBuilder<'a, ((), (), (), ())>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for GestureAreaProps<'a>

§

type Builder = GestureAreaPropsBuilder<'a, ((), ())>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for InputProps<'a>

§

type Builder = InputPropsBuilder<'a, ((), (), (), (), ())>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for NetworkImageProps<'a>

§

type Builder = NetworkImagePropsBuilder<'a, ((), (), (), (), (), ())>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for ScrollBarProps<'a>

§

type Builder = ScrollBarPropsBuilder<'a, ((), (), (), (), (), ())>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for ScrollThumbProps<'a>

§

type Builder = ScrollThumbPropsBuilder<'a, ((), (), (), ())>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for ScrollViewProps<'a>

§

type Builder = ScrollViewPropsBuilder<'a, ((), (), (), (), (), (), ())>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for SliderProps<'a>

§

type Builder = SliderPropsBuilder<'a, ((), (), ())>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for SwitchProps<'a>

§

type Builder = SwitchPropsBuilder<'a, ((), ())>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for TableBodyProps<'a>

§

type Builder = TableBodyPropsBuilder<'a, ((),)>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for TableCellProps<'a>

§

type Builder = TableCellPropsBuilder<'a, ((), (), (), (), ())>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for TableHeadProps<'a>

§

type Builder = TableHeadPropsBuilder<'a, ((),)>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for TableProps<'a>

§

type Builder = TablePropsBuilder<'a, ((), (), (), (), ())>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for TableRowProps<'a>

§

type Builder = TableRowPropsBuilder<'a, ((), ())>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for ThemeProviderProps<'a>

§

type Builder = ThemeProviderPropsBuilder<'a, ((), ())>

source§

const IS_STATIC: bool = false

source§

impl<'a> Properties for TooltipProps<'a>

§

type Builder = TooltipPropsBuilder<'a, ((),)>

source§

const IS_STATIC: bool = false

source§

impl<'a, T> Properties for DragZoneProps<'a, T>

§

type Builder = DragZonePropsBuilder<'a, ((), (), ()), T>

source§

const IS_STATIC: bool = false

source§

impl<'a, T> Properties for DropZoneProps<'a, T>

§

type Builder = DropZonePropsBuilder<'a, ((), ()), T>

source§

const IS_STATIC: bool = false

source§

impl<'a, T> Properties for DropdownItemProps<'a, T>where T: 'static,

§

type Builder = DropdownItemPropsBuilder<'a, ((), (), ()), T>

source§

const IS_STATIC: bool = false

source§

impl<'a, T> Properties for DropdownProps<'a, T>where T: 'static,

§

type Builder = DropdownPropsBuilder<'a, ((), ()), T>

source§

const IS_STATIC: bool = false

source§

impl<'a, T> Properties for VirtualScrollViewProps<'a, T>where T: 'a,

§

type Builder = VirtualScrollViewPropsBuilder<'a, ((), (), (), (), (), (), (), (), (), (), ()), T>

source§

const IS_STATIC: bool = false