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

pub fn read_respond<TSocket, TThen, TParam, TOut, TErr>(
    socket: TSocket,
    max_size: usize,
    param: TParam,
    then: TThen
) -> ReadRespond<TSocket, TParam, TThen> where
    TErr: From<ReadOneError>,
    TSocket: AsyncRead,
    TThen: FnOnce(TSocket, Vec<u8>, TParam) -> Result<TOut, TErr>, 

Similar to read_one, but applies a transformation on the output buffer.

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.