22//
33// This source file is part of the RediStack open source project
44//
5- // Copyright (c) 2019 RediStack project authors
5+ // Copyright (c) 2019-2022 RediStack project authors
66// Licensed under Apache License v2.0
77//
88// See LICENSE.txt for license information
@@ -17,8 +17,8 @@ import NIOCore
1717/// Handles incoming byte messages from Redis
1818/// and decodes them according to the Redis Serialization Protocol (RESP).
1919///
20- /// See `NIO.ByteToMessageDecoder `, `RESPTranslator` and [https://redis.io/topics/protocol](https://redis.io/topics/protocol)
21- public final class RedisByteDecoder : ByteToMessageDecoder {
20+ /// See `NIO.NIOSingleStepByteToMessageDecoder `, `RESPTranslator` and [https://redis.io/topics/protocol](https://redis.io/topics/protocol)
21+ public final class RedisByteDecoder : NIOSingleStepByteToMessageDecoder {
2222 /// `ByteToMessageDecoder.InboundOut`
2323 public typealias InboundOut = RESPValue
2424
@@ -28,18 +28,13 @@ public final class RedisByteDecoder: ByteToMessageDecoder {
2828 self . parser = RESPTranslator ( )
2929 }
3030
31- /// See `ByteToMessageDecoder.decode(context:buffer:)`
32- public func decode( context: ChannelHandlerContext , buffer: inout ByteBuffer ) throws -> DecodingState {
33- guard let value = try self . parser. parseBytes ( from: & buffer) else { return . needMoreData }
34-
35- context. fireChannelRead ( wrapInboundOut ( value) )
36- return . continue
31+ /// See `NIOSingleStepByteToMessageDecoder.decode(buffer:)`
32+ public func decode( buffer: inout ByteBuffer ) throws -> RESPValue ? {
33+ try self . parser. parseBytes ( from: & buffer)
3734 }
3835
39- /// See `ByteToMessageDecoder.decodeLast(context:buffer:seenEOF)`
40- public func decodeLast(
41- context: ChannelHandlerContext ,
42- buffer: inout ByteBuffer ,
43- seenEOF: Bool
44- ) throws -> DecodingState { return . needMoreData }
36+ /// See `NIOSingleStepByteToMessageDecoder.decodeLast(buffer:seenEOF)`
37+ public func decodeLast( buffer: inout ByteBuffer , seenEOF: Bool ) throws -> RESPValue ? {
38+ try self . decode ( buffer: & buffer)
39+ }
4540}
0 commit comments