2
2
//
3
3
// This source file is part of the RediStack open source project
4
4
//
5
- // Copyright (c) 2019 RediStack project authors
5
+ // Copyright (c) 2019-2022 RediStack project authors
6
6
// Licensed under Apache License v2.0
7
7
//
8
8
// See LICENSE.txt for license information
@@ -17,8 +17,8 @@ import NIOCore
17
17
/// Handles incoming byte messages from Redis
18
18
/// and decodes them according to the Redis Serialization Protocol (RESP).
19
19
///
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 {
22
22
/// `ByteToMessageDecoder.InboundOut`
23
23
public typealias InboundOut = RESPValue
24
24
@@ -28,18 +28,13 @@ public final class RedisByteDecoder: ByteToMessageDecoder {
28
28
self . parser = RESPTranslator ( )
29
29
}
30
30
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)
37
34
}
38
35
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
+ }
45
40
}
0 commit comments