macro_rules! provider_param {
($type:ty) => { ... };
}Expand description
Macro to enable a custom type to be used directly as a provider parameter
This macro implements the sealed DirectParam trait for your type, allowing it
to be used with the blanket IntoProviderParam implementation.
§Requirements
Your type must implement:
Clone + PartialEq + Hash + Debug + Send + Sync + 'static
§Example
use dioxus_provider::{prelude::*, provider_param};
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
struct UserId(u32);
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
struct ProductId(String);
// Enable direct usage as provider parameters
provider_param!(UserId);
provider_param!(ProductId);
#[provider]
async fn fetch_user(user_id: UserId) -> Result<User, String> { ... }
#[provider]
async fn fetch_product(product_id: ProductId) -> Result<Product, String> { ... }
// Now you can use them directly:
let user = use_provider(fetch_user(), UserId(42));
let product = use_provider(fetch_product(), ProductId("abc".to_string()));