mirror of
https://github.com/apple/swift-nio
synced 2026-11-28 05:14:23 +00:00
Motivation: The name `mapIfError` implied that you can transform the error value but really that's never what it did. Instead, it allowed you to recover from a failure. Modifications: - rename `mapIfError` to `recover` Result: cleaner method names
2.6 KiB
2.6 KiB
Changes in the Public API from NIO 1 to NIO 2
- removed all previously deprecated functions, types and modules.
- renamed
SniResulttoSNIResult - renamed
SniHandlertoSNIHandler - made
EventLoopGroup.makeIterator()a required method TimeAmount.Valueis nowInt64(fromInton 64 bit platforms, no change for 32 bit platforms)ByteToMessageDecoders now need to be wrapped inByteToMessageHandlerbefore they can be added to the pipeline. before:pipeline.add(MyDecoder()), after:pipeline.add(ByteToMessageHandler(MyDecoder()))EventLoop.makePromise/makeSucceededFuture/makeFailedFutureinstead ofnew*, alsoresult:/error:labels droppedSocketAddress.makeAddressResolvingHost(:port:)instead ofSocketAddress.newAddressResolving(host:port:)- changed all ports to
Int(fromUInt16) - changed
HTTPVersion'smajorandminorproperties toInt(fromUInt16) - renamed the generic parameter name to
Byteswhere we're talking about a generic collection of bytes - Moved error
ChannelLifecycleError.inappropriateOperationForStatetoChannelError.inappropriateOperationForState. - Moved all errors in
MulticastErrorenum intoChannelError. - Removed
ChannelError.connectFailed. All errors that triggered this now throwNIOConnectErrordirectly. - Made
WebSocketOpcodea struct. RemovedWebSocketOpcode.unknownControlandWebSocketOpcode.unknownNonControlvalues: these should be replaced by simply instantiatingWebSocketOpcodewith the value. markedElementIndex(),markedElement()andhasMark()are now computed variables instead of functions.ByteBuffer.set(string:at:)no longer returns anInt?, instead it returnsIntand has had its return value made discardable.ByteBuffer.write(string:)no longer returns anInt?, instead it returnsIntand has had its return value made discardable.- removed ContiguousCollection
- EventLoopFuture.whenComplete now provides Result<T, Error>
- renamed
EventLoopFuture.thentoEventLoopFuture.flatMap - renamed
EventLoopFuture.thenIfErrortoEventLoopFuture.flatMapError - renamed
EventLoopFuture.mapIfErrortoEventLoopFuture.recover - renamed
EventLoopFuture.thenThrowingtoEventLoopFuture.flatMapThrowing - renamed
EventLoopFuture's generic parameter fromTtoValue - renamed
EventLoopFuture.and(result:)toEventLoopFuture.and(value:) EventLoopPromise.succeed(result: Value)lost its label so is nowEventLoopPromise.succeed(Value)EventLoopPromise.fail(error: Error)lost its label so is nowEventLoopPromise.fail(Error)