Skip to main content

FallbackResponse

Trait FallbackResponse 

Source
pub trait FallbackResponse {
    // Required method
    fn into_error(content: &str) -> Option<Report>;

    // Provided method
    fn to_string(content: &str) -> Option<String> { ... }
}
Expand description

Trait for types that can serve as a fallback error response parser

When handle_or fails to parse the primary response type, it calls into_error on the fallback type to attempt an alternative parse and surface a more descriptive error. Use NoFallback (the default) when no fallback is needed, or [FallbackFor<T>] to wrap a concrete error-response type.

Required Methods§

Source

fn into_error(content: &str) -> Option<Report>

Attempt to parse content as a fallback error type and return an error report, or None if parsing also fails.

Provided Methods§

Source

fn to_string(content: &str) -> Option<String>

Attempt to parse and pretty-print JSON content for readable fallback output.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§