[][src]Function libp2p_core::upgrade::read_one_then

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

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.