WIP
@DataStorage
Makes it easy to work with Data.
Data
@DataStorage struct DataHolder {}
Expands to:
struct DataHolder { let data: Data init(data: Data) { self.data = data } }
byteCount
@DataStorage(named: "key", byteCount: 32) public struct PublicKey {}
public struct PublicKey { public static let byteCount = 32 public let key: Data public init(key: Data) throws { guard key.count == Self.byteCount else { throw InvalidByteCount(actual: key.count) } self.key = key } } extension PubliKey { struct InvalidByteCount: Swift.Error, CustomStringConvertible { let actual: Int var description: String { "Invalid byteCount, expected: \(PublicKey.byteCount), but got: \(actual)" } } }
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
@DataStorage
Makes it easy to work with
Data
.No args
Expands to:
byteCount
Expands to: