ProviderErrorBounds

Trait ProviderErrorBounds 

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

Common trait bounds for provider error types

Provider errors must satisfy these bounds to enable:

  • Clone: Errors are cloned when cached and displayed to users
  • PartialEq: Enables error comparison and change detection
  • Send + Sync: Allows safe propagation of errors across async boundaries
  • ’static: Required for storing errors in caches and error states

§Example

use dioxus_provider::prelude::*;
use thiserror::Error;

// String works as a simple error type:
#[provider]
async fn simple_provider() -> Result<String, String> {
    Err("Something went wrong".to_string())
}

// Custom error types provide better structure:
#[derive(Error, Debug, Clone, PartialEq)]
pub enum MyError {
    #[error("Network error: {0}")]
    Network(String),
    #[error("Not found")]
    NotFound,
}

#[provider]
async fn typed_provider() -> Result<String, MyError> {
    Err(MyError::NotFound)
}

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> ProviderErrorBounds for T
where T: Clone + PartialEq + Send + Sync + 'static,