In some protocols (HTTP, TCP) the stream of bytes needs to be parsed to be decoded and likewise chunks of encoded content can written out. In other protocols (e.g. RSocket, WebSocket) input and output streams are already split into discrete messages so that each DataBuffer can be decoded and is encoded in full.
Currently Encoder and Decoder contracts are good the former but unnecessarily cumbersome requiring to wrapping in a Mono and joining with DataBufferUtils. Even in WebFlux there are plenty of cases where we've run into this (multipart, form data, etc). We should add decodeDataBuffer to Decoder and encodeValue in Encoder.
Sub-classes of AbstractDataBufferDecoder already have a protected decodeDataBuffer method that does this (on joined buffers). I suspect Jackson and Jaxb2 implementations of decodeToMono could also skip the asynchronous parsing for decoding to Mono and extend this class, see #22783. Likewise Encoder implementations either have methods for encoding one value, or could benefit from one.
In some protocols (HTTP, TCP) the stream of bytes needs to be parsed to be decoded and likewise chunks of encoded content can written out. In other protocols (e.g. RSocket, WebSocket) input and output streams are already split into discrete messages so that each
DataBuffercan be decoded and is encoded in full.Currently
EncoderandDecodercontracts are good the former but unnecessarily cumbersome requiring to wrapping in aMonoand joining withDataBufferUtils. Even in WebFlux there are plenty of cases where we've run into this (multipart, form data, etc). We should adddecodeDataBuffertoDecoderandencodeValueinEncoder.Sub-classes of
AbstractDataBufferDecoderalready have a protecteddecodeDataBuffermethod that does this (on joined buffers). I suspect Jackson and Jaxb2 implementations of decodeToMono could also skip the asynchronous parsing for decoding toMonoand extend this class, see #22783. Likewise Encoder implementations either have methods for encoding one value, or could benefit from one.