libp2p::request_response::cbor

Type Alias Behaviour

pub type Behaviour<Req, Resp> = Behaviour<Codec<Req, Resp>>;
Available on crate features request-response and cbor only.
Expand description

A request-response behaviour using [cbor4ii::serde] 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 = cbor::Behaviour::<GreetRequest, GreetResponse>::new(
    [(StreamProtocol::new("/my-cbor-protocol"), ProtocolSupport::Full)],
    request_response::Config::default()
);

Aliased Type§

struct Behaviour<Req, Resp> { /* private fields */ }