pub trait HasLoadingHint: Clone + 'static {
// Required method
fn empty() -> Self;
}Expand description
Optional payload for the Loading state.
Most users will leave this at the default () — the variant
then carries no information beyond “we’re fetching”. Implement
this trait for your loading-hint type to attach stale-while-
revalidate metadata (last-known data, fetched-at timestamp, …)
to the Loading arm.
The trait has a single associated constant — a zero-sized marker so the type can be used as a default type parameter — and one method that produces the “no prior data, no hint” sentinel.
§Examples
ⓘ
#[derive(Clone)]
struct Hint { previous: Option<MyData>, last_fetched_ms: u64 }
impl HasLoadingHint for Hint {
fn empty() -> Self { Hint { previous: None, last_fetched_ms: 0 } }
}Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".