Function swimos_encoding::consume_bounded
source · pub fn consume_bounded<D: Decoder>(
remaining: usize,
src: &mut BytesMut,
decoder: &mut D,
) -> (usize, Result<Option<<D as Decoder>::Item>, <D as Decoder>::Error>)Expand description
Feed a bounded number of bytes into a Decoder. If the input buffer contains more bytes than
the limit, the decoder is passed the limited prefix and Decoder::decode_eof is called, rather than
Decoder::decode. This is useful when Decoders are composed and some subset of the input of
one encoder is delegated to another.
The return value is the number of bytes yet to be consumed (which will be non-zero if the buffer contained less than the limit) and the result of the decode operation.
§Arguments
remaining- The remaining number of bytes to pass to the decoder.src- The input buffer.decoder- The decoder to which to feed the input.