Expand description
Request/reply utility for correlated message exchange.
Provides send_and_wait, a function that sends a namespaced message to a
peer and waits for a reply matching a caller-provided filter. This
eliminates the subscribe → send → loop → timeout boilerplate that
subsystems like file transfer repeat at every call site.
§Example
ⓘ
use truffle_core::request_reply::{send_and_wait, RequestError};
let port = send_and_wait(
&node, "peer-id", "my-ns", "request", &payload,
Duration::from_secs(10),
|msg| {
if msg.msg_type == "response" && msg.from == "peer-id" {
Some(msg.payload.clone())
} else {
None
}
},
).await?;Enums§
- Request
Error - Errors returned by
send_and_wait.
Functions§
- send_
and_ wait - Send a namespaced message and wait for a reply that matches a predicate.