Generic request/response protocols.
RequestResponse is a
NetworkBehaviour that implements a generic
request/response protocol or protocol family, whereby each request is
sent over a new substream on a connection.
RequestResponse is generic
over the actual messages being sent, which are defined in terms of a
RequestResponseCodec. Creating a request/response protocol thus amounts
to providing an implementation of this trait which can then be
RequestResponse::new. Further configuration options are
available via the
RequestResponse instance can be used with an entire
protocol family that share the same request and response types.
For that purpose,
RequestResponseCodec::Protocol is typically
instantiated with a sum type.
The implementation supports one-way protocols that do not
have responses. In these cases the
be defined as
RequestResponseCodec::read_response as well as
RequestResponseCodec::write_response given the obvious implementations.
RequestResponseMessage::Response will still be emitted,
immediately after the request has been sent, since
will not actually read anything from the given I/O stream.
RequestResponse::send_response need not be called for one-way protocols,
ResponseChannel may just be dropped.
It is possible to only support inbound or outbound requests for
a particular protocol. This is achieved by instantiating
with protocols using
ProtocolSupport::Outbound. Any subset of protocols of a protocol
family can be configured in this way. Such protocols will not be
advertised during inbound respectively outbound protocol negotiation
on the substreams.
Limit the number of requests peers can send to each other.
The ID of an inbound or outbound request.
A request/response protocol for some message codec.
The configuration for a
A channel for sending a response to an inbound request.
A wrapper around
Possible failures occurring in the context of receiving an inbound request and sending a response.
Possible failures occurring in the context of sending an outbound request and receiving the response.
The level of support for a particular protocol.
The events emitted by a
An inbound request or response.
Types serving as protocol names.