mirror of
https://github.com/apple/swift-nio
synced 2026-11-30 05:28:44 +00:00
Adopt swift-format (#2794)
* Apply formatting
* Apply no block comments rule
* Apply OmitExplicitReturns
* Apple OnlyOneTrailingClosureArgument
* Apply NoAssignmentInExpressions
* Fix up DontRepeatTypeInStaticProperties lint errors
* Apply `OrderedImports`
* Apply `ReplaceForEachWithForLoop`
* format file
* Enable the formatting pipeline
* Adopt `AmbiguousTrailingClosureOverload`
* Fix license header
* Fix format check
* Fix `EndOfLineComment`
* Fix CI
* Adapt CI script to check if changes when running formatting
* Separate lint and format into to steps
* Fix format
* Adopt `UseEarlyExits`
* Revert "Adopt `UseEarlyExits`"
This reverts commit d1ac5bbe12.
This commit is contained in:
1 parent
980bd3e630
commit
c9756e1083
374 files changed
+23992
-14890
No files matched your search
@@ -12,7 +12,6 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
/// A simplified version of `ByteToMessageDecoder` that can generate zero or one messages for each invocation of `decode` or `decodeLast`.
|
||||
/// Having `decode` and `decodeLast` return an optional message avoids re-entrancy problems, since the functions relinquish exclusive access
|
||||
/// to the `ByteBuffer` when returning. This allows for greatly simplified processing.
|
||||
@@ -51,7 +50,6 @@ public protocol NIOSingleStepByteToMessageDecoder: ByteToMessageDecoder {
|
||||
mutating func decodeLast(buffer: inout ByteBuffer, seenEOF: Bool) throws -> InboundOut?
|
||||
}
|
||||
|
||||
|
||||
// MARK: NIOSingleStepByteToMessageDecoder: ByteToMessageDecoder
|
||||
extension NIOSingleStepByteToMessageDecoder {
|
||||
public mutating func decode(context: ChannelHandlerContext, buffer: inout ByteBuffer) throws -> DecodingState {
|
||||
@@ -63,7 +61,11 @@ extension NIOSingleStepByteToMessageDecoder {
|
||||
}
|
||||
}
|
||||
|
||||
public mutating func decodeLast(context: ChannelHandlerContext, buffer: inout ByteBuffer, seenEOF: Bool) throws -> DecodingState {
|
||||
public mutating func decodeLast(
|
||||
context: ChannelHandlerContext,
|
||||
buffer: inout ByteBuffer,
|
||||
seenEOF: Bool
|
||||
) throws -> DecodingState {
|
||||
if let message = try self.decodeLast(buffer: &buffer, seenEOF: seenEOF) {
|
||||
context.fireChannelRead(Self.wrapInboundOut(message))
|
||||
return .continue
|
||||
@@ -73,7 +75,6 @@ extension NIOSingleStepByteToMessageDecoder {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// `NIOSingleStepByteToMessageProcessor` uses a `NIOSingleStepByteToMessageDecoder` to produce messages
|
||||
/// from a stream of incoming bytes. It works like `ByteToMessageHandler` but may be used outside of the channel pipeline. This allows
|
||||
/// processing of wrapped protocols in a general way.
|
||||
@@ -238,7 +239,11 @@ public final class NIOSingleStepByteToMessageProcessor<Decoder: NIOSingleStepByt
|
||||
}
|
||||
|
||||
@inlinable
|
||||
func _decodeLoop(decodeMode: DecodeMode, seenEOF: Bool = false, _ messageReceiver: (Decoder.InboundOut) throws -> Void) throws {
|
||||
func _decodeLoop(
|
||||
decodeMode: DecodeMode,
|
||||
seenEOF: Bool = false,
|
||||
_ messageReceiver: (Decoder.InboundOut) throws -> Void
|
||||
) throws {
|
||||
// we want to call decodeLast once with an empty buffer if we have nothing
|
||||
if decodeMode == .last && (self._buffer == nil || self._buffer!.readableBytes == 0) {
|
||||
var emptyBuffer = self._buffer == nil ? ByteBuffer() : self._buffer!
|
||||
|
||||
Reference in new issue
Block a user