Repository: apple/swift-nio
File: Sources/NIOEmbedded/Embedded.swift (Swift)

Code before:
        pipeline: self._pipeline,
        eventLoop: self.eventLoop
    )

    /// - see: `Channel._channelCore`
    public var _channelCore: ChannelCore {
        self.embeddedEventLoop.checkCorrectThread()
        return self.channelcore
    }

    /// - see: `Channel.pipeline`
    public var pipeline: ChannelPipeline {
        self.embeddedEventLoop.checkCorrectThread()
        return self._pipeline
    }

    /// - see: `Channel.isWritable`
    public var isWritable: Bool = true


    @usableFromInline
    internal var _options: [(option: any ChannelOption, value: any Sendable)] = []

    /// The `ChannelOption`s set on this channel.
    /// - see: `Embedded.setOption`
    public var options: [(option: any ChannelOption, value: any Sendable)] { _options }

    /// Synchronously closes the `EmbeddedChannel`.
    ///
    /// Errors in the `EmbeddedChannel` can be consumed using `throwIfErrorCaught`.
    ///
    /// - Parameters:
    ///   - acceptAlreadyClosed: Whether `finish` should throw if the `EmbeddedChannel` has been previously `close`d.
    /// - Returns: The `LeftOverState` of the `EmbeddedChannel`. If all the inbound and outbound events have been
    ///            consumed (using `readInbound` / `readOutbound`) and there are no pending outbound events (unflushed
    ///            writes) this will be `.clean`. If there are any unconsumed inbound, outbound, or pending outbound
    ///            events, the `EmbeddedChannel` will returns those as `.leftOvers(inbound:outbound:pendingOutbound:)`.
    public func finish(acceptAlreadyClosed: Bool) throws -> LeftOverState {
        self.embeddedEventLoop.checkCorrectThread()
        do {
            try close().wait()
        } catch let error as ChannelError {
            guard error == .alreadyClosed && acceptAlreadyClosed else {
                throw error
            }
        }
        self.embeddedEventLoop.run()
        self.embeddedEventLoop.cancelRemainingScheduledTasks()
        try throwIfErrorCaught()
        let c = self.channelcore
        if c.outboundBuffer.isEmpty && c.inboundBuffer.isEmpty && c.pendingOutboundBuffer.isEmpty {

Review comment (suggestion):
Nit:

```suggestion
    public var options: [(option: any ChannelOption, value: any Sendable)] { self._options }
```

Code after:
    }

    /// - see: `Channel.closeFuture`
    public var closeFuture: EventLoopFuture<Void> { channelcore.closePromise.futureResult }

    @usableFromInline
    lazy var channelcore: EmbeddedChannelCore = EmbeddedChannelCore(
        pipeline: self._pipeline,
        eventLoop: self.eventLoop
    )

    /// - see: `Channel._channelCore`
    public var _channelCore: ChannelCore {
        self.embeddedEventLoop.checkCorrectThread()
        return self.channelcore
    }

    /// - see: `Channel.pipeline`
    public var pipeline: ChannelPipeline {
        self.embeddedEventLoop.checkCorrectThread()
        return self._pipeline
    }

    /// - see: `Channel.isWritable`
    public var isWritable: Bool = true

    @usableFromInline
    internal var _options: [(option: any ChannelOption, value: any Sendable)] = []

    /// The `ChannelOption`s set on this channel.
    /// - see: `Embedded.setOption`
    public var options: [(option: any ChannelOption, value: any Sendable)] { self._options }

    /// Synchronously closes the `EmbeddedChannel`.
    ///
    /// Errors in the `EmbeddedChannel` can be consumed using `throwIfErrorCaught`.
    ///
    /// - Parameters:
    ///   - acceptAlreadyClosed: Whether `finish` should throw if the `EmbeddedChannel` has been previously `close`d.
    /// - Returns: The `LeftOverState` of the `EmbeddedChannel`. If all the inbound and outbound events have been
    ///            consumed (using `readInbound` / `readOutbound`) and there are no pending outbound events (unflushed
    ///            writes) this will be `.clean`. If there are any unconsumed inbound, outbound, or pending outbound
    ///            events, the `EmbeddedChannel` will returns those as `.leftOvers(inbound:outbound:pendingOutbound:)`.
    public func finish(acceptAlreadyClosed: Bool) throws -> LeftOverState {
        self.embeddedEventLoop.checkCorrectThread()
        do {
            try close().wait()
        } catch let error as ChannelError {
            guard error == .alreadyClosed && acceptAlreadyClosed else {
                throw error
            }