Skip to content

Instance Method

decode(context:buffer:)

Decode from a ByteBuffer.
mutating func decode(context: ChannelHandlerContext, buffer: inout ByteBuffer) throws -> DecodingState

Parameters

context

The ChannelHandlerContext which this ByteToMessageDecoder belongs to.

buffer

The ByteBuffer from which we decode.

Return Value

DecodingState.continue if we should continue calling this method or DecodingState.needMoreData if it should be called again once more data is present in the ByteBuffer.

Discussion

This method will be called in a loop until either the input ByteBuffer has nothing to read left or DecodingState.needMoreData is returned. If DecodingState.continue is returned and the ByteBuffer contains more readable bytes, this method will immediately be invoked again, unless decodeLast needs to be invoked instead.