pub fn maelstrom_bidi_clients<'a, C, In: DeserializeOwned, Out: Serialize>(
cluster: &Cluster<'a, C>,
) -> (KeyedStream<String, In, Cluster<'a, C>>, ForwardHandle<'a, KeyedStream<String, Out, Cluster<'a, C>>>)Available on crate feature
deploy and (crate features maelstrom or maelstrom_runtime) only.Expand description
Sets up bidirectional communication with Maelstrom clients on a cluster.
This function provides a similar API to bidi_external_many_bytes but for Maelstrom
client communication. It returns a keyed input stream of client messages and accepts
a keyed output stream of responses.
The key type is String (the client ID like “c1”, “c2”).
The value type is serde_json::Value (the message body).
§Example
ⓘ
let (input, output_handle) = maelstrom_bidi_clients(&cluster);
output_handle.complete(input.map(q!(|(client_id, body)| {
// Process and return response
(client_id, response_body)
})));