-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from lemo-nade-room/feature/on-lost-key-default…
…-value 鍵を紛失した場合のデフォルト値を設定できるよう変更
- Loading branch information
Showing
6 changed files
with
99 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Foundation | ||
|
||
/// 鍵が無い場合のデフォルト値を持つことができるプロトコル | ||
public protocol CryptoFieldable: Hashable, Codable { | ||
static var onLostKeyValue: Self { get } | ||
} | ||
extension Int: CryptoFieldable { | ||
/// 鍵が紛失した場合のデフォルト値 | ||
@TaskLocal public static var onLostKeyValue = 1 | ||
} | ||
extension String: CryptoFieldable { | ||
/// 鍵が紛失した場合のデフォルト値 | ||
@TaskLocal public static var onLostKeyValue = "Lost" | ||
} | ||
extension Double: CryptoFieldable { | ||
/// 鍵が紛失した場合のデフォルト値 | ||
@TaskLocal public static var onLostKeyValue = 1.0 | ||
} | ||
extension Bool: CryptoFieldable { | ||
/// 鍵が紛失した場合のデフォルト値 | ||
@TaskLocal public static var onLostKeyValue = false | ||
} | ||
extension Date: CryptoFieldable { | ||
/// 鍵が紛失した場合のデフォルト値 | ||
@TaskLocal public static var onLostKeyValue = Date(timeIntervalSince1970: 0) | ||
} | ||
extension Optional: CryptoFieldable where Wrapped: Hashable & Codable { | ||
/// 鍵が紛失した場合のデフォルト値 | ||
public static var onLostKeyValue: Self { nil } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters