feat(request-response): add modules for json and cbor messages

This patch adds two modules to `libp2p::request_response`:

- `cbor`
- `json`

Both define a `Behaviour` type-alias that comes with a `Codec` implementation which uses the respective `serde` crate to serialize and deserialize the messages.

Fixes #3905.

Pull-Request: #3952.
This commit is contained in:
Denis Garus
2023-05-24 14:13:12 +03:00
committed by GitHub
parent 5e8f2e82e4
commit a5cd0d0e03
9 changed files with 489 additions and 16 deletions

View File

@ -60,7 +60,7 @@ pub(crate) async fn new(
transport,
ComposedBehaviour {
kademlia: Kademlia::new(peer_id, MemoryStore::new(peer_id)),
request_response: request_response::Behaviour::new(
request_response: request_response::Behaviour::with_codec(
FileExchangeCodec(),
iter::once((
StreamProtocol::new("/file-exchange/1"),