[−][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 tothen
. 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 theReadRespond
type impossible to express as a concrete type. Once theimpl Trait
syntax is allowed within traits, we can remove this parameter.