-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStorageKeysDomainProtocol.swift
More file actions
29 lines (24 loc) · 1020 Bytes
/
StorageKeysDomainProtocol.swift
File metadata and controls
29 lines (24 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import Casification
public protocol StorageKeysTopLevelDomainProtocol: Sendable {
typealias EntryKeyPath = KeyPath<StorageKeyBuilder<Self>, StorageKeyEntry>
typealias StrictEntryKeyPath<Value> = KeyPath<StorageKeyBuilder<Self>, StorageKeyEntry.Strict<Value>>
typealias Builder<Domain> = StorageKeyBuilder<Domain>
static subscript(_ keyPath: EntryKeyPath) -> String { get }
static subscript<T>(_ keyPath: StrictEntryKeyPath<T>) -> String { get }
}
extension StorageKeysTopLevelDomainProtocol {
public static subscript(_ keyPath: EntryKeyPath) -> String {
StorageKeyBuilder()[keyPath: keyPath].rawValue
}
public static subscript<Value>(_ keyPath: StrictEntryKeyPath<Value>) -> String {
StorageKeyBuilder()[keyPath: keyPath].rawValue
}
public func subdomain<Child>(
_ key: String = #function,
format modifier: String.Casification.Modifier = .snake,
separator: String = "-"
) -> Builder<Child> {
return Builder<Self>(rawValue: "")
.subdomain(key, format: modifier, separator: separator)
}
}