ProviderOutputBounds

Trait ProviderOutputBounds 

Source
pub trait ProviderOutputBounds:
    Clone
    + PartialEq
    + Send
    + Sync
    + 'static { }
Expand description

Common trait bounds for provider output types

Provider outputs must satisfy these bounds to enable:

  • Clone: Results are cloned when cached and served to multiple components
  • PartialEq: Allows change detection to avoid unnecessary re-renders
  • Send + Sync: Enables safe sharing of results across async contexts
  • ’static: Required for storing results in global caches and signals

§Example

use dioxus_provider::prelude::*;

// Simple types work out of the box:
#[provider]
async fn fetch_count() -> Result<i32, String> {
    Ok(42)
}

// Custom types need to derive Clone and PartialEq:
#[derive(Clone, PartialEq)]
struct User {
    id: u32,
    name: String,
}

#[provider]
async fn fetch_user(id: u32) -> Result<User, String> {
    Ok(User { id, name: "Alice".to_string() })
}

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.

Implementors§

Source§

impl<T> ProviderOutputBounds for T
where T: Clone + PartialEq + Send + Sync + 'static,