Type Alias libp2p_request_response::json::Behaviour
source · pub type Behaviour<Req, Resp> = Behaviour<Codec<Req, Resp>>;
Available on crate feature
json
only.Expand description
A request-response behaviour using serde_json
for serializing and deserializing the messages.
§Example
#[derive(Debug, serde::Serialize, serde::Deserialize)]
struct GreetRequest {
name: String,
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
struct GreetResponse {
message: String,
}
let behaviour = json::Behaviour::<GreetRequest, GreetResponse>::new(
[(StreamProtocol::new("/my-json-protocol"), ProtocolSupport::Full)],
request_response::Config::default()
);
Aliased Type§
struct Behaviour<Req, Resp> { /* private fields */ }