sdk: readable clients (no Empty wrapper, no unused error module), documented examples with tests
This commit is contained in:
@@ -11,6 +11,23 @@ impl Consumer {
|
||||
.on_notify(|name, _| eprintln!("typed progress: {name}"))
|
||||
.await? as i32)
|
||||
}
|
||||
/// Connect to a world endpoint from the real core.
|
||||
async fn world_endpoint(&self) -> Result<u64> {
|
||||
let control = probe::control::connect("/state/control").await?;
|
||||
let received = std::rc::Rc::new(std::cell::Cell::new(false));
|
||||
let progress = received.clone();
|
||||
let result = control
|
||||
.stats()
|
||||
.on_notify(move |name, value| {
|
||||
progress.set(name == "endpoint-progress" && value["value"] == 7);
|
||||
})
|
||||
.await?;
|
||||
assert!(
|
||||
received.get(),
|
||||
"the endpoint must deliver progress before its result"
|
||||
);
|
||||
Ok(result)
|
||||
}
|
||||
/// Connect to the provider's endpoint and receive its notification.
|
||||
async fn endpoint(&self) -> Result<u64> {
|
||||
let control = probe::control::connect("/endpoint").await?;
|
||||
|
||||
Reference in New Issue
Block a user