Skip to content

Refactor `RESPTranslator` to mutate the passed `ByteBuffer` directly.

Nathan Harris requested to merge resp-translator-refactor into 47-proposal-feedback

Motivation:

During proposal review, it was pointed out that the code with a position index was redundant and error prone over relying on ByteBuffer's readerIndex.

Modifications:

Refactored RESPTranslator to rely on ByteBuffer.readerIndex for position of current parsing cursor, and eliminated ParsingResult enum to instead return RESPValue?.

The implementation for writing out RESPValue has been expanded to RESPValueConvertible and moved to an extension of ByteBuffer.

Result:

Parsing RESPValue into and out of ByteBuffer should be less error-prone and more straight forward.

This contributes to issues #47 (closed) and #55 (closed)

Edited by Nathan Harris

Merge request reports