[][src]Function libp2p::core::upgrade::request_response

pub fn request_response<TSocket, TData, TParam, TThen, TOut, TErr>(
    socket: TSocket,
    data: TData,
    max_size: usize,
    param: TParam,
    then: TThen
) -> RequestResponse<TSocket, TParam, TThen, TData> where
    TData: AsRef<[u8]>,
    TSocket: AsyncRead + AsyncWrite,
    TThen: FnOnce(Vec<u8>, TParam) -> Result<TOut, TErr>, 

Send a message to the given socket, then shuts down the writing side, then reads an answer.

This combines write_one followed with read_one_then.

Note: The param parameter is an arbitrary value that will be passed back to then. This parameter is normally not necessary, as we could just pass a closure that has ownership of any data we want. In practice, though, this would make the ReadRespond type impossible to express as a concrete type. Once the impl Trait syntax is allowed within traits, we can remove this parameter.