ChannelCore

public protocol ChannelCore : AnyObject

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

Warning

If you are not implementing a custom Channel type, you should never call any of these.

Note

All methods must be called from the EventLoop thread.

  • unwrapData(_:as:) Extension method

    Unwraps the given NIOAny as a specific concrete type.

    This method is intended for use when writing custom ChannelCore implementations. This can safely be called in methods like write0 to extract data from the NIOAny provided in those cases.

    Note that if the unwrap fails, this will cause a runtime trap. ChannelCore implementations should be concrete about what types they support writing. If multiple types are supported, considere using a tagged union to store the type information like NIO’s own IOData, which will minimise the amount of runtime type checking.

    Declaration

    Swift

    @inlinable
    public func unwrapData<T>(_ data: NIOAny, as: T.Type = T.self) -> T

    Parameters

    data

    The NIOAny to unwrap.

    as

    The type to extract from the NIOAny.

    Return Value

    The content of the NIOAny.

  • removeHandlers(channel:) Extension method

    Removes the ChannelHandlers from the ChannelPipeline belonging to channel, and closes that ChannelPipeline.

    This method is intended for use when writing custom ChannelCore implementations. This can be called from close0 to tear down the ChannelPipeline when closure is complete.

    Declaration

    Swift

    public func removeHandlers(channel: Channel)

    Parameters

    channel

    The Channel whose ChannelPipeline will be closed.