mutating func sendRstStream()

in Sources/NIOHTTP2/ConnectionStateMachine/ConnectionStateMachine.swift [969:1026]


    mutating func sendRstStream(streamID: HTTP2StreamID, reason: HTTP2ErrorCode) -> StateMachineResultWithEffect {
        switch self.state {
        case .prefaceSent(var state):
            return self.avoidingStateMachineCoW { newState in
                let result = state.sendRstStream(streamID: streamID, reason: reason)
                newState = .prefaceSent(state)
                return result
            }

        case .active(var state):
            return self.avoidingStateMachineCoW { newState in
                let result = state.sendRstStream(streamID: streamID, reason: reason)
                newState = .active(state)
                return result
            }

        case .locallyQuiesced(var state):
            return self.avoidingStateMachineCoW { newState in
                let result = state.sendRstStream(streamID: streamID, reason: reason)
                newState = .locallyQuiesced(state)
                newState.closeIfNeeded(state)
                return result
            }

        case .remotelyQuiesced(var state):
            return self.avoidingStateMachineCoW { newState in
                let result = state.sendRstStream(streamID: streamID, reason: reason)
                newState = .remotelyQuiesced(state)
                newState.closeIfNeeded(state)
                return result
            }

        case .bothQuiescing(var state):
            return self.avoidingStateMachineCoW { newState in
                let result = state.sendRstStream(streamID: streamID, reason: reason)
                newState = .bothQuiescing(state)
                newState.closeIfNeeded(state)
                return result
            }

        case .quiescingPrefaceSent(var state):
            return self.avoidingStateMachineCoW { newState in
                let result = state.sendRstStream(streamID: streamID, reason: reason)
                newState = .quiescingPrefaceSent(state)
                return result
            }

        case .idle, .prefaceReceived, .quiescingPrefaceReceived:
            // We're waiting for the local preface.
            return .init(result: .connectionError(underlyingError: NIOHTTP2Errors.missingPreface(), type: .protocolError), effect: nil)

        case .fullyQuiesced:
            return .init(result: .connectionError(underlyingError: NIOHTTP2Errors.ioOnClosedConnection(), type: .protocolError), effect: nil)

        case .modifying:
            preconditionFailure("Must not be left in modifying state")
        }
    }