//
// Copyright © 2023 Nevis Security AG. All rights reserved.
//

import NevisMobileAuthentication

protocol MethodHandler {
	func execute(using client: MobileAuthenticationClient, with message: ChannelInMessage)
}

extension MethodHandler {
	func validate<T>(message: ChannelInMessage) -> T {
		guard type(of: message) is T.Type else {
			fatalError("Wrong type of message received!")
		}

		return message as! T
	}

	func validate<T>(state: OperationState) -> T {
		guard type(of: state) is T.Type else {
			fatalError("Operation state is missing or not \(String(describing: T.self))!")
		}

		return state as! T
	}
}
