euv_ui/hook/use_async/trait.rs
1/// Optional payload for the `Loading` state.
2///
3/// Most users will leave this at the default `()` — the variant
4/// then carries no information beyond "we're fetching". Implement
5/// this trait for your loading-hint type to attach stale-while-
6/// revalidate metadata (last-known data, fetched-at timestamp, …)
7/// to the `Loading` arm.
8///
9/// The trait has a single associated constant — a zero-sized marker
10/// so the type can be used as a default type parameter — and one
11/// method that produces the "no prior data, no hint" sentinel.
12pub trait HasLoadingHint: Clone + 'static {
13 /// The sentinel value representing "no prior data is available".
14 /// `use_async` slots this in for the first render so that
15 /// `.loading_hint()` always returns a usable value, even before
16 /// the future has a chance to produce one.
17 fn empty() -> Self;
18}