Implement Codable for NdbNote

Makes it easier to work with other Swift types

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
Daniel D’Aquino
2025-04-30 16:26:47 -07:00
parent 1a6c17e308
commit 7fa2118480
2 changed files with 132 additions and 29 deletions

View File

@@ -143,8 +143,16 @@ struct ReplaceableParam: TagConvertible {
var keychar: AsciiCharacter { "d" }
}
struct Signature: Hashable, Equatable {
struct Signature: Codable, Hashable, Equatable {
let data: Data
init(from decoder: Decoder) throws {
self.init(try hex_decoder(decoder, expected_len: 64))
}
func encode(to encoder: Encoder) throws {
try hex_encoder(to: encoder, data: self.data)
}
init(_ p: Data) {
self.data = p