Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/Configuration/ConfigProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public protocol ConfigProvider: Sendable {
/// - updatesHandler: The closure that processes the async sequence of value updates.
/// - Throws: Provider-specific errors or errors thrown by the handler closure.
/// - Returns: The value returned by the closure.
func watchValue<Return>(
func watchValue<Return: ~Copyable>(
forKey key: AbsoluteConfigKey,
type: ConfigType,
updatesHandler: (
Expand Down Expand Up @@ -128,7 +128,7 @@ public protocol ConfigProvider: Sendable {
/// - Parameter updatesHandler: The closure that processes the asynchronous sequence of snapshot updates.
/// - Throws: Provider-specific errors or errors thrown by the handler closure.
/// - Returns: The value returned by the closure.
func watchSnapshot<Return>(
func watchSnapshot<Return: ~Copyable>(
updatesHandler: (ConfigUpdatesAsyncSequence<any ConfigSnapshot, Never>) async throws -> Return
) async throws -> Return
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Configuration/ConfigProviderHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ extension ConfigProvider {
/// - Returns: The value returned by the handler closure.
/// - Throws: Provider-specific errors or errors thrown by the handler.
nonisolated(nonsending)
public func watchValueFromValue<Return>(
public func watchValueFromValue<Return: ~Copyable>(
forKey key: AbsoluteConfigKey,
type: ConfigType,
updatesHandler: (
Expand Down Expand Up @@ -85,7 +85,7 @@ extension ConfigProvider {
/// - Parameter updatesHandler: The closure that processes the async sequence of snapshot updates.
/// - Returns: The value returned by the handler closure.
/// - Throws: Provider-specific errors or errors thrown by the handler.
nonisolated(nonsending) public func watchSnapshotFromSnapshot<Return>(
nonisolated(nonsending) public func watchSnapshotFromSnapshot<Return: ~Copyable>(
updatesHandler: (ConfigUpdatesAsyncSequence<any ConfigSnapshot, Never>) async throws -> Return
) async throws -> Return {
let (stream, continuation) = AsyncStream<any ConfigSnapshot>
Expand Down
6 changes: 3 additions & 3 deletions Sources/Configuration/ConfigReader+internalHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ extension ConfigReader {
/// - updatesHandler: A closure that handles the stream of updates, emits `nil` when no value is found.
/// - Throws: An error if the watch operation fails.
/// - Returns: The value returned by the updates handler.
internal func watchValue<Value: Sendable, Return>(
internal func watchValue<Value: Sendable, Return: ~Copyable>(
forKey key: ConfigKey,
type: ConfigType,
isSecret: Bool,
Expand Down Expand Up @@ -713,7 +713,7 @@ extension ConfigReader {
/// - updatesHandler: A closure that handles the stream of updates, emits the default when no value is found.
/// - Throws: An error if the watch operation fails.
/// - Returns: The value returned by the updates handler.
internal func watchValue<Value: Sendable, Return>(
internal func watchValue<Value: Sendable, Return: ~Copyable>(
forKey key: ConfigKey,
type: ConfigType,
isSecret: Bool,
Expand Down Expand Up @@ -790,7 +790,7 @@ extension ConfigReader {
/// or the value cannot be unwrapped.
/// - Throws: An error if the watch operation fails.
/// - Returns: The value returned by the updates handler.
internal func watchRequiredValue<Value: Sendable, Return>(
internal func watchRequiredValue<Value: Sendable, Return: ~Copyable>(
forKey key: ConfigKey,
type: ConfigType,
isSecret: Bool,
Expand Down
84 changes: 42 additions & 42 deletions Sources/Configuration/ConfigReader+methods.swift

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions Sources/Configuration/ConfigReader+methods.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ extension ConfigReader {
/// produces `nil` if the value is missing or can't be converted.
/// - Returns: The result produced by the handler.
/// - Throws: Rethrows any error thrown by the handler or the underlying watch operation.
public func watch${primitive_type["name"]}<Return>(
public func watch${primitive_type["name"]}<Return: ~Copyable>(
forKey key: ConfigKey,
isSecret: Bool = false,
fileID: String = #fileID,
Expand Down Expand Up @@ -741,7 +741,7 @@ extension ConfigReader {
/// produces the default value if the provider returned a `nil` value or conversion failed.
/// - Returns: The result produced by the handler.
/// - Throws: Rethrows any error thrown by the handler or the underlying watch operation.
public func watch${primitive_type["name"]}<Return>(
public func watch${primitive_type["name"]}<Return: ~Copyable>(
forKey key: ConfigKey,
isSecret: Bool = false,
default defaultValue: ${primitive_type["type"]},
Expand Down Expand Up @@ -785,7 +785,7 @@ extension ConfigReader {
/// produces an error if the provider returned a `nil` value or if the value was of an incorrect type.
/// - Returns: The result produced by the handler.
/// - Throws: Rethrows any error thrown by the handler or the underlying watch operation.
public func watchRequired${primitive_type["name"]}<Return>(
public func watchRequired${primitive_type["name"]}<Return: ~Copyable>(
forKey key: ConfigKey,
isSecret: Bool = false,
fileID: String = #fileID,
Expand Down Expand Up @@ -834,7 +834,7 @@ extension ConfigReader {
/// produces `nil` if the value is missing or can't be converted.
/// - Returns: The result produced by the handler.
/// - Throws: Rethrows any error thrown by the handler or the underlying watch operation.
public func watchString<Value: ${string_convertible_type["protocol"]} & Sendable, Return>(
public func watchString<Value: ${string_convertible_type["protocol"]} & Sendable, Return: ~Copyable>(
forKey key: ConfigKey,
as type: Value.Type = Value.self,
isSecret: Bool = false,
Expand Down Expand Up @@ -879,7 +879,7 @@ extension ConfigReader {
/// produces the default value if the provider returned a `nil` value or conversion failed.
/// - Returns: The result produced by the handler.
/// - Throws: Rethrows any error thrown by the handler or the underlying watch operation.
public func watchString<Value: ${string_convertible_type["protocol"]} & Sendable, Return>(
public func watchString<Value: ${string_convertible_type["protocol"]} & Sendable, Return: ~Copyable>(
forKey key: ConfigKey,
as type: Value.Type = Value.self,
isSecret: Bool = false,
Expand Down Expand Up @@ -925,7 +925,7 @@ extension ConfigReader {
/// produces an error if the provider returned a `nil` value or if the value was of an incorrect type.
/// - Returns: The result produced by the handler.
/// - Throws: Rethrows any error thrown by the handler or the underlying watch operation.
public func watchRequiredString<Value: ${string_convertible_type["protocol"]} & Sendable, Return>(
public func watchRequiredString<Value: ${string_convertible_type["protocol"]} & Sendable, Return: ~Copyable>(
forKey key: ConfigKey,
as type: Value.Type = Value.self,
isSecret: Bool = false,
Expand Down Expand Up @@ -973,7 +973,7 @@ extension ConfigReader {
/// produces `nil` if the value is missing or can't be converted.
/// - Returns: The result produced by the handler.
/// - Throws: Rethrows any error thrown by the handler or the underlying watch operation.
public func watchStringArray<Value: ${string_convertible_type["protocol"]} & Sendable, Return>(
public func watchStringArray<Value: ${string_convertible_type["protocol"]} & Sendable, Return: ~Copyable>(
forKey key: ConfigKey,
as type: Value.Type = Value.self,
isSecret: Bool = false,
Expand Down Expand Up @@ -1018,7 +1018,7 @@ extension ConfigReader {
/// produces the default value if the provider returned a `nil` value or conversion failed.
/// - Returns: The result produced by the handler.
/// - Throws: Rethrows any error thrown by the handler or the underlying watch operation.
public func watchStringArray<Value: ${string_convertible_type["protocol"]} & Sendable, Return>(
public func watchStringArray<Value: ${string_convertible_type["protocol"]} & Sendable, Return: ~Copyable>(
forKey key: ConfigKey,
as type: Value.Type = Value.self,
isSecret: Bool = false,
Expand Down Expand Up @@ -1064,7 +1064,7 @@ extension ConfigReader {
/// produces an error if the provider returned a `nil` value or if the value was of an incorrect type.
/// - Returns: The result produced by the handler.
/// - Throws: Rethrows any error thrown by the handler or the underlying watch operation.
public func watchRequiredStringArray<Value: ${string_convertible_type["protocol"]} & Sendable, Return>(
public func watchRequiredStringArray<Value: ${string_convertible_type["protocol"]} & Sendable, Return: ~Copyable>(
forKey key: ConfigKey,
as type: Value.Type = Value.self,
isSecret: Bool = false,
Expand Down
2 changes: 1 addition & 1 deletion Sources/Configuration/ConfigSnapshotReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ extension ConfigReader {
/// - updatesHandler: A closure that receives an async sequence of `ConfigSnapshotReader` instances.
/// - Returns: The value returned by the handler.
/// - Throws: Any error thrown by the handler.
public func watchSnapshot<Return>(
public func watchSnapshot<Return: ~Copyable>(
fileID: String = #fileID,
line: UInt = #line,
updatesHandler: (ConfigUpdatesAsyncSequence<ConfigSnapshotReader, Never>) async throws -> Return
Expand Down
2 changes: 1 addition & 1 deletion Sources/Configuration/Deprecations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ extension ConfigReader {
/// - Returns: The value returned by the closure.
/// - Throws: Rethrows any errors thrown by the provided closure.
@available(*, deprecated, message: "Renamed to snapshot().")
public func withSnapshot<Failure: Error, Return>(
public func withSnapshot<Failure: Error, Return: ~Copyable>(
_ body: (ConfigSnapshotReader) throws(Failure) -> Return
) throws(Failure) -> Return {
let multiSnapshot = provider.snapshot()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@

### Watching string values
- ``ConfigReader/watchString(forKey:isSecret:fileID:line:updatesHandler:)``
- ``ConfigReader/watchString(forKey:as:isSecret:fileID:line:updatesHandler:)-7mxw1``
- ``ConfigReader/watchString(forKey:as:isSecret:fileID:line:updatesHandler:)-818sy``
- ``ConfigReader/watchString(forKey:as:isSecret:fileID:line:updatesHandler:)-4zs5y``
- ``ConfigReader/watchString(forKey:as:isSecret:fileID:line:updatesHandler:)-8hegv``
- ``ConfigReader/watchString(forKey:isSecret:default:fileID:line:updatesHandler:)``
- ``ConfigReader/watchString(forKey:as:isSecret:default:fileID:line:updatesHandler:)-6m0yu``
- ``ConfigReader/watchString(forKey:as:isSecret:default:fileID:line:updatesHandler:)-6dpc3``
- ``ConfigReader/watchString(forKey:as:isSecret:default:fileID:line:updatesHandler:)-hi1l``
- ``ConfigReader/watchString(forKey:as:isSecret:default:fileID:line:updatesHandler:)-9qsww``

### Watching required string values
- ``ConfigReader/watchRequiredString(forKey:isSecret:fileID:line:updatesHandler:)``
- ``ConfigReader/watchRequiredString(forKey:as:isSecret:fileID:line:updatesHandler:)-86ot1``
- ``ConfigReader/watchRequiredString(forKey:as:isSecret:fileID:line:updatesHandler:)-3lrs7``
- ``ConfigReader/watchRequiredString(forKey:as:isSecret:fileID:line:updatesHandler:)-581rg``
- ``ConfigReader/watchRequiredString(forKey:as:isSecret:fileID:line:updatesHandler:)-13z9o``

### Watching lists of string values
- ``ConfigReader/watchStringArray(forKey:isSecret:fileID:line:updatesHandler:)``
- ``ConfigReader/watchStringArray(forKey:as:isSecret:fileID:line:updatesHandler:)-8t4nb``
- ``ConfigReader/watchStringArray(forKey:as:isSecret:fileID:line:updatesHandler:)-9cmju``
- ``ConfigReader/watchStringArray(forKey:as:isSecret:fileID:line:updatesHandler:)-15oye``
- ``ConfigReader/watchStringArray(forKey:as:isSecret:fileID:line:updatesHandler:)-7snta``
- ``ConfigReader/watchStringArray(forKey:isSecret:default:fileID:line:updatesHandler:)``
- ``ConfigReader/watchStringArray(forKey:as:isSecret:default:fileID:line:updatesHandler:)-59de``
- ``ConfigReader/watchStringArray(forKey:as:isSecret:default:fileID:line:updatesHandler:)-8nsil``
- ``ConfigReader/watchStringArray(forKey:as:isSecret:default:fileID:line:updatesHandler:)-9t8bb``
- ``ConfigReader/watchStringArray(forKey:as:isSecret:default:fileID:line:updatesHandler:)-256k2``

### Watching required lists of string values
- ``ConfigReader/watchRequiredStringArray(forKey:isSecret:fileID:line:updatesHandler:)``
- ``ConfigReader/watchRequiredStringArray(forKey:as:isSecret:fileID:line:updatesHandler:)-3whiy``
- ``ConfigReader/watchRequiredStringArray(forKey:as:isSecret:fileID:line:updatesHandler:)-4zyyq``
- ``ConfigReader/watchRequiredStringArray(forKey:as:isSecret:fileID:line:updatesHandler:)-4acy``
- ``ConfigReader/watchRequiredStringArray(forKey:as:isSecret:fileID:line:updatesHandler:)-8wvyc``

### Watching Boolean values
- ``ConfigReader/watchBool(forKey:isSecret:fileID:line:updatesHandler:)``
Expand Down
16 changes: 8 additions & 8 deletions Sources/Configuration/MultiProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ extension MultiProvider {
/// - Returns: The value returned by the body closure.
/// - Throws: Any error thrown by the nested providers or the body closure.
nonisolated(nonsending)
func watchSnapshot<Return>(
func watchSnapshot<Return: ~Copyable>(
_ body: (ConfigUpdatesAsyncSequence<MultiSnapshot, Never>) async throws -> Return
) async throws -> Return
{
Expand Down Expand Up @@ -287,7 +287,7 @@ extension MultiProvider {
/// - Throws: Any error thrown by the nested providers or the handler closure.
/// - Returns: The value returned by the handler.
nonisolated(nonsending)
func watchValue<Return>(
func watchValue<Return: ~Copyable>(
forKey key: AbsoluteConfigKey,
type: ConfigType,
updatesHandler: (
Expand Down Expand Up @@ -338,13 +338,13 @@ extension MultiProvider {
}

@available(Configuration 1.0, *)
nonisolated(nonsending) private func withProvidersWatchingValue<ReturnInner>(
nonisolated(nonsending) private func withProvidersWatchingValue<Return: ~Copyable>(
providers: ArraySlice<any ConfigProvider>,
updateSequences: inout [any (AsyncSequence<Result<LookupResult, any Error>, Never> & Sendable)],
key: AbsoluteConfigKey,
configType: ConfigType,
body: ([any (AsyncSequence<Result<LookupResult, any Error>, Never> & Sendable)]) async throws -> ReturnInner
) async throws -> ReturnInner {
body: ([any (AsyncSequence<Result<LookupResult, any Error>, Never> & Sendable)]) async throws -> Return
) async throws -> Return {
guard let provider = providers.first else {
// Recursion termination, once we've collected all update sequences, execute the body.
return try await body(updateSequences)
Expand All @@ -362,11 +362,11 @@ nonisolated(nonsending) private func withProvidersWatchingValue<ReturnInner>(
}

@available(Configuration 1.0, *)
nonisolated(nonsending) private func withProvidersWatchingSnapshot<ReturnInner>(
nonisolated(nonsending) private func withProvidersWatchingSnapshot<Return: ~Copyable>(
providers: ArraySlice<any ConfigProvider>,
updateSequences: inout [any (AsyncSequence<any ConfigSnapshot, Never> & Sendable)],
body: ([any (AsyncSequence<any ConfigSnapshot, Never> & Sendable)]) async throws -> ReturnInner
) async throws -> ReturnInner {
body: ([any (AsyncSequence<any ConfigSnapshot, Never> & Sendable)]) async throws -> Return
) async throws -> Return {
guard let provider = providers.first else {
// Recursion termination, once we've collected all update sequences, execute the body.
return try await body(updateSequences)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ extension CommandLineArgumentsProvider: ConfigProvider {
}

// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
public func watchValue<Return>(
public func watchValue<Return: ~Copyable>(
forKey key: AbsoluteConfigKey,
type: ConfigType,
updatesHandler: (ConfigUpdatesAsyncSequence<Result<LookupResult, any Error>, Never>) async throws -> Return
Expand All @@ -164,7 +164,7 @@ extension CommandLineArgumentsProvider: ConfigProvider {
}

// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
public func watchSnapshot<Return>(
public func watchSnapshot<Return: ~Copyable>(
updatesHandler: (ConfigUpdatesAsyncSequence<any ConfigSnapshot, Never>) async throws -> Return
) async throws -> Return {
try await watchSnapshotFromSnapshot(updatesHandler: updatesHandler)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ extension EnvironmentVariablesProvider: ConfigProvider {
}

// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
public func watchValue<Return>(
public func watchValue<Return: ~Copyable>(
forKey key: AbsoluteConfigKey,
type: ConfigType,
updatesHandler: (ConfigUpdatesAsyncSequence<Result<LookupResult, any Error>, Never>) async throws -> Return
Expand All @@ -505,7 +505,7 @@ extension EnvironmentVariablesProvider: ConfigProvider {
}

// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
public func watchSnapshot<Return>(
public func watchSnapshot<Return: ~Copyable>(
updatesHandler: (ConfigUpdatesAsyncSequence<any ConfigSnapshot, Never>) async throws -> Return
) async throws -> Return {
try await watchSnapshotFromSnapshot(updatesHandler: updatesHandler)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ extension DirectoryFilesProvider: ConfigProvider {
}

// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
public func watchValue<Return>(
public func watchValue<Return: ~Copyable>(
forKey key: AbsoluteConfigKey,
type: ConfigType,
updatesHandler: (ConfigUpdatesAsyncSequence<Result<LookupResult, any Error>, Never>) async throws -> Return
Expand All @@ -464,7 +464,7 @@ extension DirectoryFilesProvider: ConfigProvider {
}

// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
public func watchSnapshot<Return>(
public func watchSnapshot<Return: ~Copyable>(
updatesHandler: (ConfigUpdatesAsyncSequence<any ConfigSnapshot, Never>) async throws -> Return
) async throws -> Return {
try await watchSnapshotFromSnapshot(updatesHandler: updatesHandler)
Expand Down
4 changes: 2 additions & 2 deletions Sources/Configuration/Providers/Files/FileProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,14 @@ extension FileProvider: ConfigProvider {
}

// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
public func watchSnapshot<Return>(
public func watchSnapshot<Return: ~Copyable>(
updatesHandler: (ConfigUpdatesAsyncSequence<any ConfigSnapshot, Never>) async throws -> Return
) async throws -> Return {
try await watchSnapshotFromSnapshot(updatesHandler: updatesHandler)
}

// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
public func watchValue<Return>(
public func watchValue<Return: ~Copyable>(
forKey key: AbsoluteConfigKey,
type: ConfigType,
updatesHandler: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ extension ReloadingFileProvider: ConfigProvider {
}

// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
public func watchValue<Return>(
public func watchValue<Return: ~Copyable>(
forKey key: AbsoluteConfigKey,
type: ConfigType,
updatesHandler: (ConfigUpdatesAsyncSequence<Result<LookupResult, any Error>, Never>) async throws -> Return
Expand Down Expand Up @@ -646,7 +646,7 @@ extension ReloadingFileProvider: ConfigProvider {
}

// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
public func watchSnapshot<Return>(
public func watchSnapshot<Return: ~Copyable>(
updatesHandler: (ConfigUpdatesAsyncSequence<any ConfigSnapshot, Never>) async throws -> Return
) async throws -> Return {
let (stream, continuation) = AsyncStream<AnySnapshot>.makeStream(bufferingPolicy: .bufferingNewest(1))
Expand Down
Loading
Loading