pub async fn subscribe_replacements<F, Fut>(
rpc_endpoint: &str,
on_notification: F,
) -> Result<SubscriptionHandle, SubscriptionError>Expand description
Subscribe to replacement results streamed over replacementSubscribe.
Each requote simulation or direct-fill probe is delivered to on_notification as a
ReplacementNotification; branch on its variant, or hand the stream to
crate::reroute_report::from_stream / crate::reroute_report::probes_from_stream. Single
and keyless — every result shares one stream, distinguished by slot / batch_index /
original_signature.
A websocket disconnect is treated as a fatal error — the handle’s join_handle resolves with
a SubscriptionRuntimeError.
§Example
use simulator_client::{ReplacementNotification, subscribe_replacements};
let handle = subscribe_replacements(
"http://localhost:8900/session/abc",
|result| async move {
match result {
ReplacementNotification::Requote(requote) => {
println!("slot={} sig={}", requote.core.slot, requote.core.original_signature);
}
ReplacementNotification::DirectFill(probe) => {
println!("template={} sig={}", probe.template, probe.core.original_signature);
}
}
},
)
.await?;
handle.stop.send(true).ok();
handle.join_handle.await.ok();