Trait libp2p::request_response::codec::RequestResponseCodec[][src]

pub trait RequestResponseCodec {
    type Protocol: Clone + Send + ProtocolName;
    type Request: Send;
    type Response: Send;
#[must_use]    pub 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, Error>> + 'async_trait + Send, Global>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait,
        T: AsyncRead + Unpin + Send + 'async_trait
;
#[must_use] pub 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, Error>> + 'async_trait + Send, Global>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait,
        T: AsyncRead + Unpin + Send + 'async_trait
;
#[must_use] pub 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<(), Error>> + 'async_trait + Send, Global>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait,
        T: AsyncWrite + Unpin + Send + 'async_trait
;
#[must_use] pub 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<(), Error>> + 'async_trait + Send, Global>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait,
        T: AsyncWrite + Unpin + Send + 'async_trait
; }

A RequestResponseCodec defines the request and response types for a RequestResponse protocol or protocol family and how they are encoded / decoded on an I/O stream.

Associated Types

type Protocol: Clone + Send + ProtocolName[src]

The type of protocol(s) or protocol versions being negotiated.

type Request: Send[src]

The type of inbound and outbound requests.

type Response: Send[src]

The type of inbound and outbound responses.

Loading content...

Required methods

#[must_use]pub 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, Error>> + 'async_trait + Send, Global>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait,
    T: AsyncRead + Unpin + Send + 'async_trait, 
[src]

Reads a request from the given I/O stream according to the negotiated protocol.

#[must_use]pub 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, Error>> + 'async_trait + Send, Global>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait,
    T: AsyncRead + Unpin + Send + 'async_trait, 
[src]

Reads a response from the given I/O stream according to the negotiated protocol.

#[must_use]pub 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<(), Error>> + 'async_trait + Send, Global>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait,
    T: AsyncWrite + Unpin + Send + 'async_trait, 
[src]

Writes a request to the given I/O stream according to the negotiated protocol.

#[must_use]pub 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<(), Error>> + 'async_trait + Send, Global>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait,
    T: AsyncWrite + Unpin + Send + 'async_trait, 
[src]

Writes a response to the given I/O stream according to the negotiated protocol.

Loading content...

Implementors

Loading content...