Library Moduleswift-nio 2.74.0NIOCore

    NIOCore

    The core abstractions that make up SwiftNIO.

    index.md
    import NIOCore

    Module information

    Declarations
    1480
    Symbols
    2237

    Coverage

    67.0 percent of the declarations in NIOCore are fully documented29.7 percent of the declarations in NIOCore are indirectly documented3.2 percent of the declarations in NIOCore are completely undocumented

    Declarations

    1.7 percent of the declarations in NIOCore are operators25.2 percent of the declarations in NIOCore are initializers, type members, or enum cases41.6 percent of the declarations in NIOCore are instance members0.5 percent of the declarations in NIOCore are instance subscripts2.2 percent of the declarations in NIOCore are protocols9.8 percent of the declarations in NIOCore are protocol requirements5.1 percent of the declarations in NIOCore are default implementations8.0 percent of the declarations in NIOCore are structures0.9 percent of the declarations in NIOCore are classes5.1 percent of the declarations in NIOCore are typealiases

    Interfaces

    97.8 percent of the declarations in NIOCore are unrestricted2.2 percent of the declarations in NIOCore are underscored
    Module stats and coverage details

    Overview

    NIOCore contains the fundamental abstractions that are used in all SwiftNIO programs. The goal of this module is to be platform-independent, and to be the most-common building block used for NIO protocol implementations.

    More specialized modules provide concrete implementations of many of the abstractions defined in NIOCore.

    Articles

    Event Loops and Event Loop Groups

    Channels and Channel Handlers

    • protocol Channel

      A Channel is easiest thought of as a network socket. But it can be anything that is capable of I/O operations such as read, write, connect, and bind.

    • protocol MulticastChannel

      A MulticastChannel is a Channel that supports IP multicast operations: that is, a channel that can join multicast groups.

    • protocol ChannelHandler

      Base protocol for handlers that handle I/O events or intercept an I/O operation.

    • protocol ChannelOutboundHandler

      ChannelHandler which handles outbound I/O events or intercept an outbound I/O operation for a Channel.

    • protocol ChannelInboundHandler

      ChannelHandler which handles inbound I/O events for a Channel.

    • typealias ChannelDuplexHandler

      A combination of ChannelInboundHandler and ChannelOutboundHandler.

    • class ChannelHandlerContext

      Every ChannelHandler has – when added to a ChannelPipeline – a corresponding ChannelHandlerContext which is the way ChannelHandlers can interact with other ChannelHandlers in the pipeline.

    • class ChannelPipeline

      A list of ChannelHandlers that handle or intercept inbound events and outbound operations of a Channel. ChannelPipeline implements an advanced form of the Intercepting Filter pattern to give a user full control over how an event is handled and how the ChannelHandlers in a pipeline interact with each other.

    • protocol RemovableChannelHandler

      A RemovableChannelHandler is a ChannelHandler that can be dynamically removed from a ChannelPipeline whilst the Channel is operating normally. A RemovableChannelHandler is required to remove itself from the ChannelPipeline (using ChannelHandlerContext.leavePipeline) as soon as possible.

    • struct NIOAny

      NIOAny is an opaque container for values of any type, similar to Swift’s builtin Any type. Contrary to Any the overhead of NIOAny depends on the the type of the wrapped value. Certain types that are important for the performance of a SwiftNIO application like ByteBuffer, FileRegion and AddressEnvelope<ByteBuffer> can be expected to be wrapped almost without overhead. All others will have similar performance as if they were passed as an Any as NIOAny just like Any will contain them within an existential container.

    • enum ChannelEvent

      An Channel related event that is passed through the ChannelPipeline to notify the user.

    • enum CloseMode

      Specify what kind of close operation is requested.

    • struct ChannelShouldQuiesceEvent

      A Channel user event that is sent when the Channel has been asked to quiesce.

    Buffers and Files

    Futures and Promises

    Configuring Channels

    Message Oriented Protocol Helpers

    Generic Bootstraps

    Simple Message Handling

    • protocol ByteToMessageDecoder

      ByteToMessageDecoders decode bytes in a stream-like fashion from ByteBuffer to another message type.

    • protocol WriteObservingByteToMessageDecoder

      Some ByteToMessageDecoders need to observe writes (which are outbound events). ByteToMessageDecoders which implement the WriteObservingByteToMessageDecoder protocol will be notified about every outbound write.

    • enum DecodingState

      State of the current decoding process.

    • class ByteToMessageHandler<Decoder>

      A handler which turns a given ByteToMessageDecoder into a ChannelInboundHandler that can then be added to a ChannelPipeline.

    • protocol NIOSingleStepByteToMessageDecoder

      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.

    • class NIOSingleStepByteToMessageProcessor<Decoder>

      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.

    • protocol MessageToByteEncoder

      A protocol for straightforward encoders which encode custom messages to ByteBuffers. To add a MessageToByteEncoder to a ChannelPipeline, use channel.pipeline.addHandler(MessageToByteHandler(myEncoder).

    • class MessageToByteHandler<Encoder>

      A handler which turns a given MessageToByteEncoder into a ChannelOutboundHandler that can then be added to a ChannelPipeline.

    Core Channel Handlers

    • class AcceptBackoffHandler

      A ChannelHandler that implements a backoff for a ServerChannel when accept produces an IOError. These errors are often recoverable by reducing the rate at which we call accept.

    • class BackPressureHandler

      ChannelHandler implementation which enforces back-pressure by stopping to read from the remote peer when it cannot write back fast enough. It will start reading again once pending data was written.

    • class NIOCloseOnErrorHandler

      A ChannelInboundHandler that closes the channel when an error is caught

    • class IdleStateHandler

      Triggers an IdleStateEvent when a Channel has not performed read, write, or both operation for a while.

    Async Sequences

    Time

    Circular Buffers

    • struct CircularBuffer<Element>

      An automatically expanding ring buffer implementation backed by a ContiguousArray. Even though this implementation will automatically expand if more elements than initialCapacity are stored, it’s advantageous to prevent expansions from happening frequently. Expansions will always force an allocation and a copy to happen.

    • struct MarkedCircularBuffer<Element>

      A circular buffer that allows one object at a time to be “marked” and easily identified and retrieved later.

    Operating System State

    Implementing Core Abstractions

    • protocol ChannelCore

      The core Channel methods that are for internal use of the Channel implementation only.

    • protocol ChannelInvoker

      A protocol that signals that outbound and inbound events are triggered by this invoker.

    • protocol ChannelInboundInvoker

      Fire inbound events related to a Channel through the ChannelPipeline until its end is reached or it’s consumed by a ChannelHandler.

    • protocol ChannelOutboundInvoker

      Allows users to invoke an “outbound” operation related to a Channel that will flow through the ChannelPipeline until it will finally be executed by the the ChannelCore implementation.

    Sendable Helpers

    Error Types

    Uncategorized

    Protocols

    Show implementation details (4)

    Hide implementation details

    Types

    Show implementation details (1)

    Hide implementation details

    Typealiases

    Other modules