pub async fn read_then_subscribe<K, V, F>(
store: &TerminalStore<K, V>,
subscriber: &mut EventSubscriber,
authz: &impl TerminalAuthz<K>,
watcher: &str,
key: K,
classify: F,
) -> Result<Terminal<V>>Expand description
Latched-completion read: serve the retained terminal for key if already
latched (and authz permits the late read), else subscribe to the live
EventService edge via subscriber and block until an event that classify
identifies as terminal, then latch + return it.
Subsumes load --wait and P9 /task/<id>/exit under one pattern. The
caller must have already configured subscriber with the relevant
subscription pattern(s) before the first .await.
Await contract: this is a real Future (it .awaits
EventSubscriber::recv). Consumers MUST drive it with a real async
runtime — a noop-waker poll-spin driver busy-loops (see module docs).
No lock is held across .await: the fast-path store read drops its guard
before the subscriber.recv().await loop.