-
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.
- feat: ✨ CryptoField追加、onLostKeyValue対応のCryptoFieldableプロトコル導入
- Loading branch information
1 parent
16601b5
commit 87b72d8
Showing
7 changed files
with
105 additions
and
64 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
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