pub trait Context<T, E>: Sealed {
    // Required methods
    fn show(
        self,
        display_error: impl FnOnce(&E) -> Result<VNode, RenderError>,
    ) -> Result<T, CapturedError>;
    fn context<C>(self, context: C) -> Result<T, CapturedError>
       where C: Display + 'static;
    fn with_context<C>(
        self,
        context: impl FnOnce() -> C,
    ) -> Result<T, CapturedError>
       where C: Display + 'static;
}Expand description
Provides context methods to [Result] and Option types that are compatible with [CapturedError]
This trait is sealed and cannot be implemented outside of dioxus-core
Required Methods§
fn show(
    self,
    display_error: impl FnOnce(&E) -> Result<VNode, RenderError>,
) -> Result<T, CapturedError>
fn show( self, display_error: impl FnOnce(&E) -> Result<VNode, RenderError>, ) -> Result<T, CapturedError>
Add a visual representation of the error that the ErrorBoundary may render
§Example
fn Component() -> Element {
    // You can bubble up errors with `?` inside components, and event handlers
    // Along with the error itself, you can provide a way to display the error by calling `show`
    let number = "1234".parse::<usize>().show(|error| rsx! {
        div {
            background_color: "red",
            color: "white",
            "Error parsing number: {error}"
        }
    })?;
    unimplemented!()
}fn context<C>(self, context: C) -> Result<T, CapturedError>where
    C: Display + 'static,
fn context<C>(self, context: C) -> Result<T, CapturedError>where
    C: Display + 'static,
Wrap the result additional context about the error that occurred.
§Example
fn NumberParser() -> Element {
    // You can bubble up errors with `?` inside components, and event handlers
    // Along with the error itself, you can provide a way to display the error by calling `context`
    let number = "-1234".parse::<usize>().context("Parsing number inside of the NumberParser")?;
    unimplemented!()
}fn with_context<C>(
    self,
    context: impl FnOnce() -> C,
) -> Result<T, CapturedError>where
    C: Display + 'static,
fn with_context<C>(
    self,
    context: impl FnOnce() -> C,
) -> Result<T, CapturedError>where
    C: Display + 'static,
Wrap the result with additional context about the error that occurred. The closure will only be run if the Result is an error.
§Example
fn NumberParser() -> Element {
    // You can bubble up errors with `?` inside components, and event handlers
    // Along with the error itself, you can provide a way to display the error by calling `context`
    let number = "-1234".parse::<usize>().with_context(|| format!("Timestamp: {:?}", std::time::Instant::now()))?;
    unimplemented!()
}Object Safety§
This trait is not object safe.