pub trait RequestResponseCodec {
type Protocol: ProtocolName + Send + Clone;
type Request: Send;
type Response: Send;
// Required methods
fn read_request<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
protocol: &'life1 Self::Protocol,
io: &'life2 mut T
) -> Pin<Box<dyn Future<Output = Result<Self::Request>> + Send + 'async_trait>>
where T: AsyncRead + Unpin + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn read_response<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
protocol: &'life1 Self::Protocol,
io: &'life2 mut T
) -> Pin<Box<dyn Future<Output = Result<Self::Response>> + Send + 'async_trait>>
where T: AsyncRead + Unpin + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn write_request<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
protocol: &'life1 Self::Protocol,
io: &'life2 mut T,
req: Self::Request
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where T: AsyncWrite + Unpin + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn write_response<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
protocol: &'life1 Self::Protocol,
io: &'life2 mut T,
res: Self::Response
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where T: AsyncWrite + Unpin + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}
👎Deprecated since 0.24.0: Use re-exports that omit
RequestResponse
prefix, i.e. libp2p::request_response::Codec
Expand description
A RequestResponseCodec
defines the request and response types
for a request-response Behaviour
protocol or
protocol family and how they are encoded / decoded on an I/O stream.
Required Associated Types§
sourcetype Protocol: ProtocolName + Send + Clone
type Protocol: ProtocolName + Send + Clone
👎Deprecated since 0.24.0: Use re-exports that omit
RequestResponse
prefix, i.e. libp2p::request_response::Codec
The type of protocol(s) or protocol versions being negotiated.
Required Methods§
sourcefn read_request<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
protocol: &'life1 Self::Protocol,
io: &'life2 mut T
) -> Pin<Box<dyn Future<Output = Result<Self::Request>> + Send + 'async_trait>>where
T: AsyncRead + Unpin + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn read_request<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 mut self, protocol: &'life1 Self::Protocol, io: &'life2 mut T ) -> Pin<Box<dyn Future<Output = Result<Self::Request>> + Send + 'async_trait>>where T: AsyncRead + Unpin + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,
👎Deprecated since 0.24.0: Use re-exports that omit
RequestResponse
prefix, i.e. libp2p::request_response::Codec
Reads a request from the given I/O stream according to the negotiated protocol.
sourcefn read_response<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
protocol: &'life1 Self::Protocol,
io: &'life2 mut T
) -> Pin<Box<dyn Future<Output = Result<Self::Response>> + Send + 'async_trait>>where
T: AsyncRead + Unpin + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn read_response<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 mut self, protocol: &'life1 Self::Protocol, io: &'life2 mut T ) -> Pin<Box<dyn Future<Output = Result<Self::Response>> + Send + 'async_trait>>where T: AsyncRead + Unpin + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,
👎Deprecated since 0.24.0: Use re-exports that omit
RequestResponse
prefix, i.e. libp2p::request_response::Codec
Reads a response from the given I/O stream according to the negotiated protocol.
sourcefn write_request<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
protocol: &'life1 Self::Protocol,
io: &'life2 mut T,
req: Self::Request
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
T: AsyncWrite + Unpin + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn write_request<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 mut self, protocol: &'life1 Self::Protocol, io: &'life2 mut T, req: Self::Request ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where T: AsyncWrite + Unpin + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,
👎Deprecated since 0.24.0: Use re-exports that omit
RequestResponse
prefix, i.e. libp2p::request_response::Codec
Writes a request to the given I/O stream according to the negotiated protocol.
sourcefn write_response<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
protocol: &'life1 Self::Protocol,
io: &'life2 mut T,
res: Self::Response
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
T: AsyncWrite + Unpin + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn write_response<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 mut self, protocol: &'life1 Self::Protocol, io: &'life2 mut T, res: Self::Response ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where T: AsyncWrite + Unpin + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,
👎Deprecated since 0.24.0: Use re-exports that omit
RequestResponse
prefix, i.e. libp2p::request_response::Codec
Writes a response to the given I/O stream according to the negotiated protocol.