NdbProfile.swift (13281B)
1 // automatically generated by the FlatBuffers compiler, do not modify 2 // swiftlint:disable all 3 // swiftformat:disable all 4 5 import FlatBuffers 6 7 public struct NdbProfile: FlatBufferObject, Verifiable { 8 9 static func validateVersion() { FlatBuffersVersion_23_5_26() } 10 public var __buffer: ByteBuffer! { return _accessor.bb } 11 private var _accessor: Table 12 13 private init(_ t: Table) { _accessor = t } 14 public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) } 15 16 private enum VTOFFSET: VOffset { 17 case name = 4 18 case website = 6 19 case about = 8 20 case lud16 = 10 21 case banner = 12 22 case displayName = 14 23 case reactions = 16 24 case picture = 18 25 case nip05 = 20 26 case damusDonation = 22 27 case damusDonationV2 = 24 28 case lud06 = 26 29 var v: Int32 { Int32(self.rawValue) } 30 var p: VOffset { self.rawValue } 31 } 32 33 public var name: String? { let o = _accessor.offset(VTOFFSET.name.v); return o == 0 ? nil : _accessor.string(at: o) } 34 public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.name.v) } 35 public var website: String? { let o = _accessor.offset(VTOFFSET.website.v); return o == 0 ? nil : _accessor.string(at: o) } 36 public var websiteSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.website.v) } 37 public var about: String? { let o = _accessor.offset(VTOFFSET.about.v); return o == 0 ? nil : _accessor.string(at: o) } 38 public var aboutSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.about.v) } 39 public var lud16: String? { let o = _accessor.offset(VTOFFSET.lud16.v); return o == 0 ? nil : _accessor.string(at: o) } 40 public var lud16SegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.lud16.v) } 41 public var banner: String? { let o = _accessor.offset(VTOFFSET.banner.v); return o == 0 ? nil : _accessor.string(at: o) } 42 public var bannerSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.banner.v) } 43 public var displayName: String? { let o = _accessor.offset(VTOFFSET.displayName.v); return o == 0 ? nil : _accessor.string(at: o) } 44 public var displayNameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.displayName.v) } 45 public var reactions: Bool { let o = _accessor.offset(VTOFFSET.reactions.v); return o == 0 ? true : _accessor.readBuffer(of: Bool.self, at: o) } 46 public var picture: String? { let o = _accessor.offset(VTOFFSET.picture.v); return o == 0 ? nil : _accessor.string(at: o) } 47 public var pictureSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.picture.v) } 48 public var nip05: String? { let o = _accessor.offset(VTOFFSET.nip05.v); return o == 0 ? nil : _accessor.string(at: o) } 49 public var nip05SegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.nip05.v) } 50 public var damusDonation: Int32 { let o = _accessor.offset(VTOFFSET.damusDonation.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) } 51 public var damusDonationV2: Int32 { let o = _accessor.offset(VTOFFSET.damusDonationV2.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) } 52 public var lud06: String? { let o = _accessor.offset(VTOFFSET.lud06.v); return o == 0 ? nil : _accessor.string(at: o) } 53 public var lud06SegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.lud06.v) } 54 public static func startNdbProfile(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 12) } 55 public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VTOFFSET.name.p) } 56 public static func add(website: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: website, at: VTOFFSET.website.p) } 57 public static func add(about: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: about, at: VTOFFSET.about.p) } 58 public static func add(lud16: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: lud16, at: VTOFFSET.lud16.p) } 59 public static func add(banner: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: banner, at: VTOFFSET.banner.p) } 60 public static func add(displayName: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: displayName, at: VTOFFSET.displayName.p) } 61 public static func add(reactions: Bool, _ fbb: inout FlatBufferBuilder) { fbb.add(element: reactions, def: true, 62 at: VTOFFSET.reactions.p) } 63 public static func add(picture: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: picture, at: VTOFFSET.picture.p) } 64 public static func add(nip05: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: nip05, at: VTOFFSET.nip05.p) } 65 public static func add(damusDonation: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: damusDonation, def: 0, at: VTOFFSET.damusDonation.p) } 66 public static func add(damusDonationV2: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: damusDonationV2, def: 0, at: VTOFFSET.damusDonationV2.p) } 67 public static func add(lud06: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: lud06, at: VTOFFSET.lud06.p) } 68 public static func endNdbProfile(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end } 69 public static func createNdbProfile( 70 _ fbb: inout FlatBufferBuilder, 71 nameOffset name: Offset = Offset(), 72 websiteOffset website: Offset = Offset(), 73 aboutOffset about: Offset = Offset(), 74 lud16Offset lud16: Offset = Offset(), 75 bannerOffset banner: Offset = Offset(), 76 displayNameOffset displayName: Offset = Offset(), 77 reactions: Bool = true, 78 pictureOffset picture: Offset = Offset(), 79 nip05Offset nip05: Offset = Offset(), 80 damusDonation: Int32 = 0, 81 damusDonationV2: Int32 = 0, 82 lud06Offset lud06: Offset = Offset() 83 ) -> Offset { 84 let __start = NdbProfile.startNdbProfile(&fbb) 85 NdbProfile.add(name: name, &fbb) 86 NdbProfile.add(website: website, &fbb) 87 NdbProfile.add(about: about, &fbb) 88 NdbProfile.add(lud16: lud16, &fbb) 89 NdbProfile.add(banner: banner, &fbb) 90 NdbProfile.add(displayName: displayName, &fbb) 91 NdbProfile.add(reactions: reactions, &fbb) 92 NdbProfile.add(picture: picture, &fbb) 93 NdbProfile.add(nip05: nip05, &fbb) 94 NdbProfile.add(damusDonation: damusDonation, &fbb) 95 NdbProfile.add(damusDonationV2: damusDonationV2, &fbb) 96 NdbProfile.add(lud06: lud06, &fbb) 97 return NdbProfile.endNdbProfile(&fbb, start: __start) 98 } 99 100 public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable { 101 var _v = try verifier.visitTable(at: position) 102 try _v.visit(field: VTOFFSET.name.p, fieldName: "name", required: false, type: ForwardOffset<String>.self) 103 try _v.visit(field: VTOFFSET.website.p, fieldName: "website", required: false, type: ForwardOffset<String>.self) 104 try _v.visit(field: VTOFFSET.about.p, fieldName: "about", required: false, type: ForwardOffset<String>.self) 105 try _v.visit(field: VTOFFSET.lud16.p, fieldName: "lud16", required: false, type: ForwardOffset<String>.self) 106 try _v.visit(field: VTOFFSET.banner.p, fieldName: "banner", required: false, type: ForwardOffset<String>.self) 107 try _v.visit(field: VTOFFSET.displayName.p, fieldName: "displayName", required: false, type: ForwardOffset<String>.self) 108 try _v.visit(field: VTOFFSET.reactions.p, fieldName: "reactions", required: false, type: Bool.self) 109 try _v.visit(field: VTOFFSET.picture.p, fieldName: "picture", required: false, type: ForwardOffset<String>.self) 110 try _v.visit(field: VTOFFSET.nip05.p, fieldName: "nip05", required: false, type: ForwardOffset<String>.self) 111 try _v.visit(field: VTOFFSET.damusDonation.p, fieldName: "damusDonation", required: false, type: Int32.self) 112 try _v.visit(field: VTOFFSET.damusDonationV2.p, fieldName: "damusDonationV2", required: false, type: Int32.self) 113 try _v.visit(field: VTOFFSET.lud06.p, fieldName: "lud06", required: false, type: ForwardOffset<String>.self) 114 _v.finish() 115 } 116 } 117 118 extension NdbProfile: Encodable { 119 120 enum CodingKeys: String, CodingKey { 121 case name = "name" 122 case website = "website" 123 case about = "about" 124 case lud16 = "lud16" 125 case banner = "banner" 126 case displayName = "display_name" 127 case reactions = "reactions" 128 case picture = "picture" 129 case nip05 = "nip05" 130 case damusDonation = "damus_donation" 131 case damusDonationV2 = "damus_donation_v2" 132 case lud06 = "lud06" 133 } 134 public func encode(to encoder: Encoder) throws { 135 var container = encoder.container(keyedBy: CodingKeys.self) 136 try container.encodeIfPresent(name, forKey: .name) 137 try container.encodeIfPresent(website, forKey: .website) 138 try container.encodeIfPresent(about, forKey: .about) 139 try container.encodeIfPresent(lud16, forKey: .lud16) 140 try container.encodeIfPresent(banner, forKey: .banner) 141 try container.encodeIfPresent(displayName, forKey: .displayName) 142 if reactions != true { 143 try container.encodeIfPresent(reactions, forKey: .reactions) 144 } 145 try container.encodeIfPresent(picture, forKey: .picture) 146 try container.encodeIfPresent(nip05, forKey: .nip05) 147 if damusDonation != 0 { 148 try container.encodeIfPresent(damusDonation, forKey: .damusDonation) 149 } 150 if damusDonationV2 != 0 { 151 try container.encodeIfPresent(damusDonationV2, forKey: .damusDonationV2) 152 } 153 try container.encodeIfPresent(lud06, forKey: .lud06) 154 } 155 } 156 157 public struct NdbProfileRecord: FlatBufferObject, Verifiable { 158 159 static func validateVersion() { FlatBuffersVersion_23_5_26() } 160 public var __buffer: ByteBuffer! { return _accessor.bb } 161 private var _accessor: Table 162 163 private init(_ t: Table) { _accessor = t } 164 public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) } 165 166 private enum VTOFFSET: VOffset { 167 case profile = 4 168 case receivedAt = 6 169 case noteKey = 8 170 case lnurl = 10 171 var v: Int32 { Int32(self.rawValue) } 172 var p: VOffset { self.rawValue } 173 } 174 175 public var profile: NdbProfile? { let o = _accessor.offset(VTOFFSET.profile.v); return o == 0 ? nil : NdbProfile(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) } 176 public var receivedAt: UInt64 { let o = _accessor.offset(VTOFFSET.receivedAt.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt64.self, at: o) } 177 public var noteKey: UInt64 { let o = _accessor.offset(VTOFFSET.noteKey.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt64.self, at: o) } 178 public var lnurl: String? { let o = _accessor.offset(VTOFFSET.lnurl.v); return o == 0 ? nil : _accessor.string(at: o) } 179 public var lnurlSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.lnurl.v) } 180 public static func startNdbProfileRecord(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 4) } 181 public static func add(profile: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: profile, at: VTOFFSET.profile.p) } 182 public static func add(receivedAt: UInt64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: receivedAt, def: 0, at: VTOFFSET.receivedAt.p) } 183 public static func add(noteKey: UInt64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: noteKey, def: 0, at: VTOFFSET.noteKey.p) } 184 public static func add(lnurl: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: lnurl, at: VTOFFSET.lnurl.p) } 185 public static func endNdbProfileRecord(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end } 186 public static func createNdbProfileRecord( 187 _ fbb: inout FlatBufferBuilder, 188 profileOffset profile: Offset = Offset(), 189 receivedAt: UInt64 = 0, 190 noteKey: UInt64 = 0, 191 lnurlOffset lnurl: Offset = Offset() 192 ) -> Offset { 193 let __start = NdbProfileRecord.startNdbProfileRecord(&fbb) 194 NdbProfileRecord.add(profile: profile, &fbb) 195 NdbProfileRecord.add(receivedAt: receivedAt, &fbb) 196 NdbProfileRecord.add(noteKey: noteKey, &fbb) 197 NdbProfileRecord.add(lnurl: lnurl, &fbb) 198 return NdbProfileRecord.endNdbProfileRecord(&fbb, start: __start) 199 } 200 201 public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable { 202 var _v = try verifier.visitTable(at: position) 203 try _v.visit(field: VTOFFSET.profile.p, fieldName: "profile", required: false, type: ForwardOffset<NdbProfile>.self) 204 try _v.visit(field: VTOFFSET.receivedAt.p, fieldName: "receivedAt", required: false, type: UInt64.self) 205 try _v.visit(field: VTOFFSET.noteKey.p, fieldName: "noteKey", required: false, type: UInt64.self) 206 try _v.visit(field: VTOFFSET.lnurl.p, fieldName: "lnurl", required: false, type: ForwardOffset<String>.self) 207 _v.finish() 208 } 209 } 210 211 extension NdbProfileRecord: Encodable { 212 213 enum CodingKeys: String, CodingKey { 214 case profile = "profile" 215 case receivedAt = "received_at" 216 case noteKey = "note_key" 217 case lnurl = "lnurl" 218 } 219 public func encode(to encoder: Encoder) throws { 220 var container = encoder.container(keyedBy: CodingKeys.self) 221 try container.encodeIfPresent(profile, forKey: .profile) 222 if receivedAt != 0 { 223 try container.encodeIfPresent(receivedAt, forKey: .receivedAt) 224 } 225 if noteKey != 0 { 226 try container.encodeIfPresent(noteKey, forKey: .noteKey) 227 } 228 try container.encodeIfPresent(lnurl, forKey: .lnurl) 229 } 230 } 231