Update ImmutablePlugin associatedtype (#6)

This commit is contained in:
Zach 2023-02-08 17:07:42 -07:00 committed by GitHub
parent 9a84b81ac4
commit 415a13b088
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -1,26 +1,25 @@
/// A protocol that defines a plugin that can be registered and handled by a `Pluginable` object.
public protocol ImmutablePlugin: Plugin where Output == Void, Source == ImmutablePluginable {
/// The input value that the plugin will handle.
associatedtype Value
associatedtype Input = Input
/// Handles the input value.
///
/// - Parameters:
/// - value: The input value that the plugin will handle.
/// - Throws: Any errors that occur during handling of the input value.
func handle(value: Value) async throws
func handle(value: Input) async throws
}
// MARK: Public Implementation
extension ImmutablePlugin where Value == Input {
extension ImmutablePlugin {
/// A keypath that provides access to the `immutable` property of the `Source`.
public var keyPath: WritableKeyPath<Source, ()> {
get { \.immutable }
set { }
}
public func handle(value: Value, output: inout ()) async throws {
public func handle(value: Input, output: inout ()) async throws {
try await handle(value: value)
}
}