pub async fn send_and_wait<N, F, R>(
node: &Node<N>,
peer_id: &str,
namespace: &str,
msg_type: &str,
payload: &Value,
timeout: Duration,
filter: F,
) -> Result<R, RequestError>Expand description
Send a namespaced message and wait for a reply that matches a predicate.
- Subscribes to
namespace(before sending, to avoid missing the reply). - Sends the message via
Node::send_typed. - Loops on incoming messages, calling
filteron each. - Returns the first
Some(R)from the filter, or times out.
The filter receives every message on the namespace, not just from the target peer — the caller decides what constitutes a valid reply.