// automatically generated by the FlatBuffers compiler, do not modify
// swiftlint:disable all
// swiftformat:disable all
import FlatBuffers
public enum Character: UInt8, UnionEnum {
  public typealias T = UInt8
  public init?(value: T) {
    self.init(rawValue: value)
  }
  public static var byteSize: Int { return MemoryLayout<UInt8>.size }
  public var value: UInt8 { return self.rawValue }
  case none_ = 0
  case mulan = 1
  case rapunzel = 2
  case belle = 3
  case bookfan = 4
  case other = 5
  case unused = 6
  public static var max: Character { return .unused }
  public static var min: Character { return .none_ }
}
extension Character: Encodable {
  public func encode(to encoder: Encoder) throws {
    var container = encoder.singleValueContainer()
    switch self {
    case .none_: try container.encode("NONE")
    case .mulan: try container.encode("MuLan")
    case .rapunzel: try container.encode("Rapunzel")
    case .belle: try container.encode("Belle")
    case .bookfan: try container.encode("BookFan")
    case .other: try container.encode("Other")
    case .unused: try container.encode("Unused")
    }
  }
}
public struct CharacterUnion {
  public var type: Character
  public var value: NativeObject?
  public init(_ v: NativeObject?, type: Character) {
    self.type = type
    self.value = v
  }
  public func pack(builder: inout FlatBufferBuilder) -> Offset {
    switch type {
    case .mulan:
      var __obj = value as? AttackerT
      return Attacker.pack(&builder, obj: &__obj)
    case .rapunzel:
      var __obj = value as? Rapunzel
      return Rapunzel_Mutable.pack(&builder, obj: &__obj)
    case .belle:
      var __obj = value as? BookReader
      return BookReader_Mutable.pack(&builder, obj: &__obj)
    case .bookfan:
      var __obj = value as? BookReader
      return BookReader_Mutable.pack(&builder, obj: &__obj)
    case .other:
      var __obj = value as? String
      return String.pack(&builder, obj: &__obj)
    case .unused:
      var __obj = value as? String
      return String.pack(&builder, obj: &__obj)
    default: return Offset()
    }
  }
}
public enum Gadget: UInt8, UnionEnum {
  public typealias T = UInt8
  public init?(value: T) {
    self.init(rawValue: value)
  }
  public static var byteSize: Int { return MemoryLayout<UInt8>.size }
  public var value: UInt8 { return self.rawValue }
  case none_ = 0
  case fallingtub = 1
  case handfan = 2
  public static var max: Gadget { return .handfan }
  public static var min: Gadget { return .none_ }
}
extension Gadget: Encodable {
  public func encode(to encoder: Encoder) throws {
    var container = encoder.singleValueContainer()
    switch self {
    case .none_: try container.encode("NONE")
    case .fallingtub: try container.encode("FallingTub")
    case .handfan: try container.encode("HandFan")
    }
  }
}
public struct GadgetUnion {
  public var type: Gadget
  public var value: NativeObject?
  public init(_ v: NativeObject?, type: Gadget) {
    self.type = type
    self.value = v
  }
  public func pack(builder: inout FlatBufferBuilder) -> Offset {
    switch type {
    case .fallingtub:
      var __obj = value as? FallingTub
      return FallingTub_Mutable.pack(&builder, obj: &__obj)
    case .handfan:
      var __obj = value as? HandFanT
      return HandFan.pack(&builder, obj: &__obj)
    default: return Offset()
    }
  }
}
public struct Rapunzel: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
  static func validateVersion() { FlatBuffersVersion_23_5_9() }
  private var _hairLength: Int32
  public init(_ bb: ByteBuffer, o: Int32) {
    let _accessor = Struct(bb: bb, position: o)
    _hairLength = _accessor.readBuffer(of: Int32.self, at: 0)
  }
  public init(hairLength: Int32) {
    _hairLength = hairLength
  }
  public init() {
    _hairLength = 0
  }
  public init(_ _t: inout Rapunzel_Mutable) {
    _hairLength = _t.hairLength
  }
  public var hairLength: Int32 { _hairLength }
  public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
    try verifier.inBuffer(position: position, of: Rapunzel.self)
  }
}
extension Rapunzel: Encodable {
  enum CodingKeys: String, CodingKey {
    case hairLength = "hair_length"
  }
  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if hairLength != 0 {
      try container.encodeIfPresent(hairLength, forKey: .hairLength)
    }
  }
}
public struct Rapunzel_Mutable: FlatBufferObject {
  static func validateVersion() { FlatBuffersVersion_23_5_9() }
  public var __buffer: ByteBuffer! { return _accessor.bb }
  private var _accessor: Struct
  public init(_ bb: ByteBuffer, o: Int32) { _accessor = Struct(bb: bb, position: o) }
  public var hairLength: Int32 { return _accessor.readBuffer(of: Int32.self, at: 0) }

  public mutating func unpack() -> Rapunzel {
    return Rapunzel(&self)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout Rapunzel?) -> Offset {
    guard var obj = obj else { return Offset() }
    return pack(&builder, obj: &obj)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout Rapunzel) -> Offset {
    return builder.create(struct: obj)
  }
}
public struct BookReader: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
  static func validateVersion() { FlatBuffersVersion_23_5_9() }
  private var _booksRead: Int32
  public init(_ bb: ByteBuffer, o: Int32) {
    let _accessor = Struct(bb: bb, position: o)
    _booksRead = _accessor.readBuffer(of: Int32.self, at: 0)
  }
  public init(booksRead: Int32) {
    _booksRead = booksRead
  }
  public init() {
    _booksRead = 0
  }
  public init(_ _t: inout BookReader_Mutable) {
    _booksRead = _t.booksRead
  }
  public var booksRead: Int32 { _booksRead }
  public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
    try verifier.inBuffer(position: position, of: BookReader.self)
  }
}
extension BookReader: Encodable {
  enum CodingKeys: String, CodingKey {
    case booksRead = "books_read"
  }
  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if booksRead != 0 {
      try container.encodeIfPresent(booksRead, forKey: .booksRead)
    }
  }
}
public struct BookReader_Mutable: FlatBufferObject {
  static func validateVersion() { FlatBuffersVersion_23_5_9() }
  public var __buffer: ByteBuffer! { return _accessor.bb }
  private var _accessor: Struct
  public init(_ bb: ByteBuffer, o: Int32) { _accessor = Struct(bb: bb, position: o) }
  public var booksRead: Int32 { return _accessor.readBuffer(of: Int32.self, at: 0) }

  public mutating func unpack() -> BookReader {
    return BookReader(&self)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout BookReader?) -> Offset {
    guard var obj = obj else { return Offset() }
    return pack(&builder, obj: &obj)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout BookReader) -> Offset {
    return builder.create(struct: obj)
  }
}
public struct FallingTub: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
  static func validateVersion() { FlatBuffersVersion_23_5_9() }
  private var _weight: Int32
  public init(_ bb: ByteBuffer, o: Int32) {
    let _accessor = Struct(bb: bb, position: o)
    _weight = _accessor.readBuffer(of: Int32.self, at: 0)
  }
  public init(weight: Int32) {
    _weight = weight
  }
  public init() {
    _weight = 0
  }
  public init(_ _t: inout FallingTub_Mutable) {
    _weight = _t.weight
  }
  public var weight: Int32 { _weight }
  public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
    try verifier.inBuffer(position: position, of: FallingTub.self)
  }
}
extension FallingTub: Encodable {
  enum CodingKeys: String, CodingKey {
    case weight = "weight"
  }
  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if weight != 0 {
      try container.encodeIfPresent(weight, forKey: .weight)
    }
  }
}
public struct FallingTub_Mutable: FlatBufferObject {
  static func validateVersion() { FlatBuffersVersion_23_5_9() }
  public var __buffer: ByteBuffer! { return _accessor.bb }
  private var _accessor: Struct
  public init(_ bb: ByteBuffer, o: Int32) { _accessor = Struct(bb: bb, position: o) }
  public var weight: Int32 { return _accessor.readBuffer(of: Int32.self, at: 0) }

  public mutating func unpack() -> FallingTub {
    return FallingTub(&self)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout FallingTub?) -> Offset {
    guard var obj = obj else { return Offset() }
    return pack(&builder, obj: &obj)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout FallingTub) -> Offset {
    return builder.create(struct: obj)
  }
}
public struct Attacker: FlatBufferObject, Verifiable, ObjectAPIPacker {
  static func validateVersion() { FlatBuffersVersion_23_5_9() }
  public var __buffer: ByteBuffer! { return _accessor.bb }
  private var _accessor: Table
  public static var id: String { "MOVI" }
  public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: Attacker.id, addPrefix: prefix) }
  private init(_ t: Table) { _accessor = t }
  public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
  private enum VTOFFSET: VOffset {
    case swordAttackDamage = 4
    var v: Int32 { Int32(self.rawValue) }
    var p: VOffset { self.rawValue }
  }
  public var swordAttackDamage: Int32 { let o = _accessor.offset(VTOFFSET.swordAttackDamage.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) }
  public static func startAttacker(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
  public static func add(swordAttackDamage: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: swordAttackDamage, def: 0, at: VTOFFSET.swordAttackDamage.p) }
  public static func endAttacker(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
  public static func createAttacker(
    _ fbb: inout FlatBufferBuilder,
    swordAttackDamage: Int32 = 0
  ) -> Offset {
    let __start = Attacker.startAttacker(&fbb)
    Attacker.add(swordAttackDamage: swordAttackDamage, &fbb)
    return Attacker.endAttacker(&fbb, start: __start)
  }

  public mutating func unpack() -> AttackerT {
    return AttackerT(&self)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout AttackerT?) -> Offset {
    guard var obj = obj else { return Offset() }
    return pack(&builder, obj: &obj)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout AttackerT) -> Offset {
    let __root = Attacker.startAttacker(&builder)
    Attacker.add(swordAttackDamage: obj.swordAttackDamage, &builder)
    return Attacker.endAttacker(&builder, start: __root)
  }
  public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
    var _v = try verifier.visitTable(at: position)
    try _v.visit(field: VTOFFSET.swordAttackDamage.p, fieldName: "swordAttackDamage", required: false, type: Int32.self)
    _v.finish()
  }
}
extension Attacker: Encodable {
  enum CodingKeys: String, CodingKey {
    case swordAttackDamage = "sword_attack_damage"
  }
  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if swordAttackDamage != 0 {
      try container.encodeIfPresent(swordAttackDamage, forKey: .swordAttackDamage)
    }
  }
}
public class AttackerT: NativeObject {
  public var swordAttackDamage: Int32
  public init(_ _t: inout Attacker) {
    swordAttackDamage = _t.swordAttackDamage
  }
  public init() {
    swordAttackDamage = 0
  }
  public func serialize() -> ByteBuffer { return serialize(type: Attacker.self) }
}
public struct HandFan: FlatBufferObject, Verifiable, ObjectAPIPacker {
  static func validateVersion() { FlatBuffersVersion_23_5_9() }
  public var __buffer: ByteBuffer! { return _accessor.bb }
  private var _accessor: Table
  public static var id: String { "MOVI" }
  public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: HandFan.id, addPrefix: prefix) }
  private init(_ t: Table) { _accessor = t }
  public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
  private enum VTOFFSET: VOffset {
    case length = 4
    var v: Int32 { Int32(self.rawValue) }
    var p: VOffset { self.rawValue }
  }
  public var length: Int32 { let o = _accessor.offset(VTOFFSET.length.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) }
  public static func startHandFan(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
  public static func add(length: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: length, def: 0, at: VTOFFSET.length.p) }
  public static func endHandFan(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
  public static func createHandFan(
    _ fbb: inout FlatBufferBuilder,
    length: Int32 = 0
  ) -> Offset {
    let __start = HandFan.startHandFan(&fbb)
    HandFan.add(length: length, &fbb)
    return HandFan.endHandFan(&fbb, start: __start)
  }

  public mutating func unpack() -> HandFanT {
    return HandFanT(&self)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout HandFanT?) -> Offset {
    guard var obj = obj else { return Offset() }
    return pack(&builder, obj: &obj)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout HandFanT) -> Offset {
    let __root = HandFan.startHandFan(&builder)
    HandFan.add(length: obj.length, &builder)
    return HandFan.endHandFan(&builder, start: __root)
  }
  public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
    var _v = try verifier.visitTable(at: position)
    try _v.visit(field: VTOFFSET.length.p, fieldName: "length", required: false, type: Int32.self)
    _v.finish()
  }
}
extension HandFan: Encodable {
  enum CodingKeys: String, CodingKey {
    case length = "length"
  }
  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if length != 0 {
      try container.encodeIfPresent(length, forKey: .length)
    }
  }
}
public class HandFanT: NativeObject {
  public var length: Int32
  public init(_ _t: inout HandFan) {
    length = _t.length
  }
  public init() {
    length = 0
  }
  public func serialize() -> ByteBuffer { return serialize(type: HandFan.self) }
}
public struct Movie: FlatBufferObject, Verifiable, ObjectAPIPacker {
  static func validateVersion() { FlatBuffersVersion_23_5_9() }
  public var __buffer: ByteBuffer! { return _accessor.bb }
  private var _accessor: Table
  public static var id: String { "MOVI" }
  public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: Movie.id, addPrefix: prefix) }
  private init(_ t: Table) { _accessor = t }
  public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
  private enum VTOFFSET: VOffset {
    case mainCharacterType = 4
    case mainCharacter = 6
    case charactersType = 8
    case characters = 10
    var v: Int32 { Int32(self.rawValue) }
    var p: VOffset { self.rawValue }
  }
  public var mainCharacterType: Character { let o = _accessor.offset(VTOFFSET.mainCharacterType.v); return o == 0 ? .none_ : Character(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
  public func mainCharacter<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.mainCharacter.v); return o == 0 ? nil : _accessor.union(o) }
  public var hasCharactersType: Bool { let o = _accessor.offset(VTOFFSET.charactersType.v); return o == 0 ? false : true }
  public var charactersTypeCount: Int32 { let o = _accessor.offset(VTOFFSET.charactersType.v); return o == 0 ? 0 : _accessor.vector(count: o) }
  public func charactersType(at index: Int32) -> Character? { let o = _accessor.offset(VTOFFSET.charactersType.v); return o == 0 ? Character.none_ : Character(rawValue: _accessor.directRead(of: UInt8.self, offset: _accessor.vector(at: o) + index * 1)) }
  public var hasCharacters: Bool { let o = _accessor.offset(VTOFFSET.characters.v); return o == 0 ? false : true }
  public var charactersCount: Int32 { let o = _accessor.offset(VTOFFSET.characters.v); return o == 0 ? 0 : _accessor.vector(count: o) }
  public func characters<T: FlatbuffersInitializable>(at index: Int32, type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.characters.v); return o == 0 ? nil : _accessor.directUnion(_accessor.vector(at: o) + index * 4) }
  public static func startMovie(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 4) }
  public static func add(mainCharacterType: Character, _ fbb: inout FlatBufferBuilder) { fbb.add(element: mainCharacterType.rawValue, def: 0, at: VTOFFSET.mainCharacterType.p) }
  public static func add(mainCharacter: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: mainCharacter, at: VTOFFSET.mainCharacter.p) }
  public static func addVectorOf(charactersType: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: charactersType, at: VTOFFSET.charactersType.p) }
  public static func addVectorOf(characters: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: characters, at: VTOFFSET.characters.p) }
  public static func endMovie(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
  public static func createMovie(
    _ fbb: inout FlatBufferBuilder,
    mainCharacterType: Character = .none_,
    mainCharacterOffset mainCharacter: Offset = Offset(),
    charactersTypeVectorOffset charactersType: Offset = Offset(),
    charactersVectorOffset characters: Offset = Offset()
  ) -> Offset {
    let __start = Movie.startMovie(&fbb)
    Movie.add(mainCharacterType: mainCharacterType, &fbb)
    Movie.add(mainCharacter: mainCharacter, &fbb)
    Movie.addVectorOf(charactersType: charactersType, &fbb)
    Movie.addVectorOf(characters: characters, &fbb)
    return Movie.endMovie(&fbb, start: __start)
  }

  public mutating func unpack() -> MovieT {
    return MovieT(&self)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MovieT?) -> Offset {
    guard var obj = obj else { return Offset() }
    return pack(&builder, obj: &obj)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MovieT) -> Offset {
    let __mainCharacter = obj.mainCharacter?.pack(builder: &builder) ?? Offset()
    var __characters__: [Offset] = []
    for i in obj.characters {
      guard let off = i?.pack(builder: &builder) else { continue }
      __characters__.append(off)
    }
    let __characters = builder.createVector(ofOffsets: __characters__)
    let __charactersType = builder.createVector(obj.characters.compactMap { $0?.type })
    let __root = Movie.startMovie(&builder)
    if let o = obj.mainCharacter?.type {
      Movie.add(mainCharacterType: o, &builder)
      Movie.add(mainCharacter: __mainCharacter, &builder)
    }
    Movie.addVectorOf(charactersType: __charactersType, &builder)
    Movie.addVectorOf(characters: __characters, &builder)
    return Movie.endMovie(&builder, start: __root)
  }
  public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
    var _v = try verifier.visitTable(at: position)
    try _v.visit(unionKey: VTOFFSET.mainCharacterType.p, unionField: VTOFFSET.mainCharacter.p, unionKeyName: "mainCharacterType", fieldName: "mainCharacter", required: false, completion: { (verifier, key: Character, pos) in
      switch key {
      case .none_:
        break // NOTE - SWIFT doesnt support none
      case .mulan:
        try ForwardOffset<Attacker>.verify(&verifier, at: pos, of: Attacker.self)
      case .rapunzel:
        try Rapunzel.verify(&verifier, at: pos, of: Rapunzel.self)
      case .belle:
        try BookReader.verify(&verifier, at: pos, of: BookReader.self)
      case .bookfan:
        try BookReader.verify(&verifier, at: pos, of: BookReader.self)
      case .other:
        try ForwardOffset<String>.verify(&verifier, at: pos, of: String.self)
      case .unused:
        try ForwardOffset<String>.verify(&verifier, at: pos, of: String.self)
      }
    })
    try _v.visitUnionVector(unionKey: VTOFFSET.charactersType.p, unionField: VTOFFSET.characters.p, unionKeyName: "charactersType", fieldName: "characters", required: false, completion: { (verifier, key: Character, pos) in
      switch key {
      case .none_:
        break // NOTE - SWIFT doesnt support none
      case .mulan:
        try ForwardOffset<Attacker>.verify(&verifier, at: pos, of: Attacker.self)
      case .rapunzel:
        try Rapunzel.verify(&verifier, at: pos, of: Rapunzel.self)
      case .belle:
        try BookReader.verify(&verifier, at: pos, of: BookReader.self)
      case .bookfan:
        try BookReader.verify(&verifier, at: pos, of: BookReader.self)
      case .other:
        try ForwardOffset<String>.verify(&verifier, at: pos, of: String.self)
      case .unused:
        try ForwardOffset<String>.verify(&verifier, at: pos, of: String.self)
      }
    })
    _v.finish()
  }
}
extension Movie: Encodable {
  enum CodingKeys: String, CodingKey {
    case mainCharacterType = "main_character_type"
    case mainCharacter = "main_character"
    case charactersType = "characters_type"
    case characters = "characters"
  }
  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if mainCharacterType != .none_ {
      try container.encodeIfPresent(mainCharacterType, forKey: .mainCharacterType)
    }
    switch mainCharacterType {
    case .mulan:
      let _v = mainCharacter(type: Attacker.self)
      try container.encodeIfPresent(_v, forKey: .mainCharacter)
    case .rapunzel:
      let _v = mainCharacter(type: Rapunzel.self)
      try container.encodeIfPresent(_v, forKey: .mainCharacter)
    case .belle:
      let _v = mainCharacter(type: BookReader.self)
      try container.encodeIfPresent(_v, forKey: .mainCharacter)
    case .bookfan:
      let _v = mainCharacter(type: BookReader.self)
      try container.encodeIfPresent(_v, forKey: .mainCharacter)
    case .other:
      let _v = mainCharacter(type: String.self)
      try container.encodeIfPresent(_v, forKey: .mainCharacter)
    case .unused:
      let _v = mainCharacter(type: String.self)
      try container.encodeIfPresent(_v, forKey: .mainCharacter)
    default: break;
    }
    if charactersCount > 0 {
      var enumsEncoder = container.nestedUnkeyedContainer(forKey: .charactersType)
      var contentEncoder = container.nestedUnkeyedContainer(forKey: .characters)
      for index in 0..<charactersCount {
        guard let type = charactersType(at: index) else { continue }
        try enumsEncoder.encode(type)
        switch type {
        case .mulan:
          let _v = characters(at: index, type: Attacker.self)
          try contentEncoder.encode(_v)
        case .rapunzel:
          let _v = characters(at: index, type: Rapunzel.self)
          try contentEncoder.encode(_v)
        case .belle:
          let _v = characters(at: index, type: BookReader.self)
          try contentEncoder.encode(_v)
        case .bookfan:
          let _v = characters(at: index, type: BookReader.self)
          try contentEncoder.encode(_v)
        case .other:
          let _v = characters(at: index, type: String.self)
          try contentEncoder.encode(_v)
        case .unused:
          let _v = characters(at: index, type: String.self)
          try contentEncoder.encode(_v)
        default: break;
        }
      }
    }
  }
}
public class MovieT: NativeObject {
  public var mainCharacter: CharacterUnion?
  public var characters: [CharacterUnion?]
  public init(_ _t: inout Movie) {
    switch _t.mainCharacterType {
    case .mulan:
      var _v = _t.mainCharacter(type: Attacker.self)
      mainCharacter = CharacterUnion(_v?.unpack(), type: .mulan)
    case .rapunzel:
      var _v = _t.mainCharacter(type: Rapunzel_Mutable.self)
      mainCharacter = CharacterUnion(_v?.unpack(), type: .rapunzel)
    case .belle:
      var _v = _t.mainCharacter(type: BookReader_Mutable.self)
      mainCharacter = CharacterUnion(_v?.unpack(), type: .belle)
    case .bookfan:
      var _v = _t.mainCharacter(type: BookReader_Mutable.self)
      mainCharacter = CharacterUnion(_v?.unpack(), type: .bookfan)
    case .other:
      var _v = _t.mainCharacter(type: String.self)
      mainCharacter = CharacterUnion(_v?.unpack(), type: .other)
    case .unused:
      var _v = _t.mainCharacter(type: String.self)
      mainCharacter = CharacterUnion(_v?.unpack(), type: .unused)
    default: break
    }
    characters = []
    for index in 0..<_t.charactersCount {
        switch _t.charactersType(at: index) {
        case .mulan:
          var _v = _t.characters(at: index, type: Attacker.self)
          characters.append(CharacterUnion(_v?.unpack(), type: .mulan))
        case .rapunzel:
          var _v = _t.characters(at: index, type: Rapunzel_Mutable.self)
          characters.append(CharacterUnion(_v?.unpack(), type: .rapunzel))
        case .belle:
          var _v = _t.characters(at: index, type: BookReader_Mutable.self)
          characters.append(CharacterUnion(_v?.unpack(), type: .belle))
        case .bookfan:
          var _v = _t.characters(at: index, type: BookReader_Mutable.self)
          characters.append(CharacterUnion(_v?.unpack(), type: .bookfan))
        case .other:
          var _v = _t.characters(at: index, type: String.self)
          characters.append(CharacterUnion(_v?.unpack(), type: .other))
        case .unused:
          var _v = _t.characters(at: index, type: String.self)
          characters.append(CharacterUnion(_v?.unpack(), type: .unused))
        default: break
        }
    }
  }
  public init() {
    characters = []
  }
  public func serialize() -> ByteBuffer { return serialize(type: Movie.self) }
}


FlatbuffersDoubleTests

/*
final class FlatBuffersDoubleTests: XCTestCase {
  let country = "Norway"
  func testCreateFinish() {
    var b = FlatBufferBuilder(initialSize: 16)
    let countryOff = CountryDouble.createCountry(
      builder: &b,
      name: country,
      log: 200,
      lan: 100)
    b.finish(offset: countryOff)
    // swiftformat:disable all
    let v: [UInt8] = [
      16, 0, 0, 0, 0, 0, 10, 0, 28, 0, 4, 0, 8, 0, 16, 0, 10,
      0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 89, 64, 0, 0, 0,
      0, 0, 0, 105, 64, 0, 0, 0, 0, 6, 0, 0, 0, 78, 111, 114, 119,
      97, 121, 0, 0
    ]
    // swiftformat:enable all
    XCTAssertEqual(b.sizedByteArray, v)
  }
  func testCreateFinishWithPrefix() {
    var b = FlatBufferBuilder(initialSize: 16)
    let countryOff = CountryDouble.createCountry(
      builder: &b,
      name: country,
      log: 200,
      lan: 100)
    b.finish(offset: countryOff, addPrefix: true)
    // swiftformat:disable all
    let v: [UInt8] = [
      60, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 28
      , 0, 4, 0, 8, 0, 16, 0, 10, 0, 0, 0, 24, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 89, 64, 0, 0, 0, 0, 0, 0, 105, 64, 0, 0, 0,
      0, 6, 0, 0, 0, 78, 111, 114, 119, 97, 121, 0, 0
    ]
    // swiftformat:enable all
    XCTAssertEqual(b.sizedByteArray, v)
  }
}
class CountryDouble {
  static let offsets: (name: VOffset, lan: VOffset, lng: VOffset) = (4, 6, 8)
  private var table: Table
  private init(table t: Table) { table = t }
  static func getRootAsCountry(_ bb: ByteBuffer) -> CountryDouble {
    let pos = bb.read(def: Int32.self, position: Int(bb.size))
    return CountryDouble(table: Table(bb: bb, position: Int32(pos)))
  }
  static func createCountry(
    builder: inout FlatBufferBuilder,
    name: String,
    log: Double,
    lan: Double) -> Offset
  {
    createCountry(
      builder: &builder,
      offset: builder.create(string: name),
      log: log,
      lan: lan)
  }
  static func createCountry(
    builder: inout FlatBufferBuilder,
    offset: Offset,
    log: Double,
    lan: Double) -> Offset
  {
    let _start = builder.startTable(with: 3)
    CountryDouble.add(builder: &builder, lng: log)
    CountryDouble.add(builder: &builder, lan: lan)
    CountryDouble.add(builder: &builder, name: offset)
    return CountryDouble.end(builder: &builder, startOffset: _start)
  }
  static func end(
    builder: inout FlatBufferBuilder,
    startOffset: UOffset) -> Offset
  {
    Offset(offset: builder.endTable(at: startOffset))
  }
  static func add(builder: inout FlatBufferBuilder, name: String) {
    add(builder: &builder, name: builder.create(string: name))
  }
  static func add(builder: inout FlatBufferBuilder, name: Offset) {
    builder.add(offset: name, at: Country.offsets.name)
  }
  static func add(builder: inout FlatBufferBuilder, lan: Double) {
    builder.add(element: lan, def: 0, at: Country.offsets.lan)
  }
  static func add(builder: inout FlatBufferBuilder, lng: Double) {
    builder.add(element: lng, def: 0, at: Country.offsets.lng)
  }
}


// automatically generated by the FlatBuffers compiler, do not modify
// swiftlint:disable all
// swiftformat:disable all

import FlatBuffers

public struct Swift_Tests_NanInfTable: FlatBufferObject, Verifiable {

  static func validateVersion() { FlatBuffersVersion_23_5_9() }
  public var __buffer: ByteBuffer! { return _accessor.bb }
  private var _accessor: Table

  private init(_ t: Table) { _accessor = t }
  public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }

  private enum VTOFFSET: VOffset {
    case defaultNan = 4
    case defaultInf = 6
    case defaultNinf = 8
    case valueNan = 10
    case valueInf = 12
    case valueNinf = 14
    case value = 16
    var v: Int32 { Int32(self.rawValue) }
    var p: VOffset { self.rawValue }
  }

  public var defaultNan: Double { let o = _accessor.offset(VTOFFSET.defaultNan.v); return o == 0 ? .nan : _accessor.readBuffer(of: Double.self, at: o) }
  public var defaultInf: Double { let o = _accessor.offset(VTOFFSET.defaultInf.v); return o == 0 ? .infinity : _accessor.readBuffer(of: Double.self, at: o) }
  public var defaultNinf: Double { let o = _accessor.offset(VTOFFSET.defaultNinf.v); return o == 0 ? -.infinity : _accessor.readBuffer(of: Double.self, at: o) }
  public var valueNan: Double { let o = _accessor.offset(VTOFFSET.valueNan.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
  public var valueInf: Double { let o = _accessor.offset(VTOFFSET.valueInf.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
  public var valueNinf: Double { let o = _accessor.offset(VTOFFSET.valueNinf.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
  public var value: Double { let o = _accessor.offset(VTOFFSET.value.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
  public static func startNanInfTable(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 7) }
  public static func add(defaultNan: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultNan, def: .nan, at: VTOFFSET.defaultNan.p) }
  public static func add(defaultInf: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultInf, def: .infinity, at: VTOFFSET.defaultInf.p) }
  public static func add(defaultNinf: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultNinf, def: -.infinity, at: VTOFFSET.defaultNinf.p) }
  public static func add(valueNan: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: valueNan, def: 0.0, at: VTOFFSET.valueNan.p) }
  public static func add(valueInf: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: valueInf, def: 0.0, at: VTOFFSET.valueInf.p) }
  public static func add(valueNinf: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: valueNinf, def: 0.0, at: VTOFFSET.valueNinf.p) }
  public static func add(value: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: value, def: 0.0, at: VTOFFSET.value.p) }
  public static func endNanInfTable(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
  public static func createNanInfTable(
    _ fbb: inout FlatBufferBuilder,
    defaultNan: Double = .nan,
    defaultInf: Double = .infinity,
    defaultNinf: Double = -.infinity,
    valueNan: Double = 0.0,
    valueInf: Double = 0.0,
    valueNinf: Double = 0.0,
    value: Double = 0.0
  ) -> Offset {
    let __start = Swift_Tests_NanInfTable.startNanInfTable(&fbb)
    Swift_Tests_NanInfTable.add(defaultNan: defaultNan, &fbb)
    Swift_Tests_NanInfTable.add(defaultInf: defaultInf, &fbb)
    Swift_Tests_NanInfTable.add(defaultNinf: defaultNinf, &fbb)
    Swift_Tests_NanInfTable.add(valueNan: valueNan, &fbb)
    Swift_Tests_NanInfTable.add(valueInf: valueInf, &fbb)
    Swift_Tests_NanInfTable.add(valueNinf: valueNinf, &fbb)
    Swift_Tests_NanInfTable.add(value: value, &fbb)
    return Swift_Tests_NanInfTable.endNanInfTable(&fbb, start: __start)
  }

  public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
    var _v = try verifier.visitTable(at: position)
    try _v.visit(field: VTOFFSET.defaultNan.p, fieldName: "defaultNan", required: false, type: Double.self)
    try _v.visit(field: VTOFFSET.defaultInf.p, fieldName: "defaultInf", required: false, type: Double.self)
    try _v.visit(field: VTOFFSET.defaultNinf.p, fieldName: "defaultNinf", required: false, type: Double.self)
    try _v.visit(field: VTOFFSET.valueNan.p, fieldName: "valueNan", required: false, type: Double.self)
    try _v.visit(field: VTOFFSET.valueInf.p, fieldName: "valueInf", required: false, type: Double.self)
    try _v.visit(field: VTOFFSET.valueNinf.p, fieldName: "valueNinf", required: false, type: Double.self)
    try _v.visit(field: VTOFFSET.value.p, fieldName: "value", required: false, type: Double.self)
    _v.finish()
  }
}

extension Swift_Tests_NanInfTable: Encodable {

  enum CodingKeys: String, CodingKey {
    case defaultNan = "default_nan"
    case defaultInf = "default_inf"
    case defaultNinf = "default_ninf"
    case valueNan = "value_nan"
    case valueInf = "value_inf"
    case valueNinf = "value_ninf"
    case value = "value"
  }
  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if !defaultNan.isNaN {
      try container.encodeIfPresent(defaultNan, forKey: .defaultNan)
    }
    if defaultInf != .infinity {
      try container.encodeIfPresent(defaultInf, forKey: .defaultInf)
    }
    if defaultNinf != -.infinity {
      try container.encodeIfPresent(defaultNinf, forKey: .defaultNinf)
    }
    if valueNan != 0.0 {
      try container.encodeIfPresent(valueNan, forKey: .valueNan)
    }
    if valueInf != 0.0 {
      try container.encodeIfPresent(valueInf, forKey: .valueInf)
    }
    if valueNinf != 0.0 {
      try container.encodeIfPresent(valueNinf, forKey: .valueNinf)
    }
    if value != 0.0 {
      try container.encodeIfPresent(value, forKey: .value)
    }
  }
}


// automatically generated by the FlatBuffers compiler, do not modify
// swiftlint:disable all
// swiftformat:disable all

import FlatBuffers

public struct Swift_Tests_Vectors: FlatBufferObject, Verifiable {

  static func validateVersion() { FlatBuffersVersion_23_5_9() }
  public var __buffer: ByteBuffer! { return _accessor.bb }
  private var _accessor: Table

  private init(_ t: Table) { _accessor = t }
  public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }

  private enum VTOFFSET: VOffset {
    case none_ = 4
    case empty = 6
    case array = 8
    var v: Int32 { Int32(self.rawValue) }
    var p: VOffset { self.rawValue }
  }

  public var hasNone: Bool { let o = _accessor.offset(VTOFFSET.none_.v); return o == 0 ? false : true }
  public var none_Count: Int32 { let o = _accessor.offset(VTOFFSET.none_.v); return o == 0 ? 0 : _accessor.vector(count: o) }
  public func none_(at index: Int32) -> UInt64 { let o = _accessor.offset(VTOFFSET.none_.v); return o == 0 ? 0 : _accessor.directRead(of: UInt64.self, offset: _accessor.vector(at: o) + index * 8) }
  public var none_: [UInt64] { return _accessor.getVector(at: VTOFFSET.none_.v) ?? [] }
  public var hasEmpty: Bool { let o = _accessor.offset(VTOFFSET.empty.v); return o == 0 ? false : true }
  public var emptyCount: Int32 { let o = _accessor.offset(VTOFFSET.empty.v); return o == 0 ? 0 : _accessor.vector(count: o) }
  public func empty(at index: Int32) -> UInt64 { let o = _accessor.offset(VTOFFSET.empty.v); return o == 0 ? 0 : _accessor.directRead(of: UInt64.self, offset: _accessor.vector(at: o) + index * 8) }
  public var empty: [UInt64] { return _accessor.getVector(at: VTOFFSET.empty.v) ?? [] }
  public var hasArray: Bool { let o = _accessor.offset(VTOFFSET.array.v); return o == 0 ? false : true }
  public var arrayCount: Int32 { let o = _accessor.offset(VTOFFSET.array.v); return o == 0 ? 0 : _accessor.vector(count: o) }
  public func array(at index: Int32) -> UInt64 { let o = _accessor.offset(VTOFFSET.array.v); return o == 0 ? 0 : _accessor.directRead(of: UInt64.self, offset: _accessor.vector(at: o) + index * 8) }
  public var array: [UInt64] { return _accessor.getVector(at: VTOFFSET.array.v) ?? [] }
  public static func startVectors(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 3) }
  public static func addVectorOf(none_: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: none_, at: VTOFFSET.none_.p) }
  public static func addVectorOf(empty: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: empty, at: VTOFFSET.empty.p) }
  public static func addVectorOf(array: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: array, at: VTOFFSET.array.p) }
  public static func endVectors(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
  public static func createVectors(
    _ fbb: inout FlatBufferBuilder,
    none_VectorOffset none_: Offset = Offset(),
    emptyVectorOffset empty: Offset = Offset(),
    arrayVectorOffset array: Offset = Offset()
  ) -> Offset {
    let __start = Swift_Tests_Vectors.startVectors(&fbb)
    Swift_Tests_Vectors.addVectorOf(none_: none_, &fbb)
    Swift_Tests_Vectors.addVectorOf(empty: empty, &fbb)
    Swift_Tests_Vectors.addVectorOf(array: array, &fbb)
    return Swift_Tests_Vectors.endVectors(&fbb, start: __start)
  }

  public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
    var _v = try verifier.visitTable(at: position)
    try _v.visit(field: VTOFFSET.none_.p, fieldName: "none_", required: false, type: ForwardOffset<Vector<UInt64, UInt64>>.self)
    try _v.visit(field: VTOFFSET.empty.p, fieldName: "empty", required: false, type: ForwardOffset<Vector<UInt64, UInt64>>.self)
    try _v.visit(field: VTOFFSET.array.p, fieldName: "array", required: false, type: ForwardOffset<Vector<UInt64, UInt64>>.self)
    _v.finish()
  }
}

extension Swift_Tests_Vectors: Encodable {

  enum CodingKeys: String, CodingKey {
    case none_ = "none"
    case empty = "empty"
    case array = "array"
  }
  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if none_Count > 0 {
      try container.encodeIfPresent(none_, forKey: .none_)
    }
    if emptyCount > 0 {
      try container.encodeIfPresent(empty, forKey: .empty)
    }
    if arrayCount > 0 {
      try container.encodeIfPresent(array, forKey: .array)
    }
  }
}


FlatbuffersVerifierTests

/*
final class FlatbuffersVerifierTests: XCTestCase {
  lazy var validStorage: ByteBuffer.Storage = ByteBuffer.Storage(
    count: Int(FlatBufferMaxSize) - 1,
    alignment: 1)
  lazy var errorStorage: ByteBuffer.Storage = ByteBuffer.Storage(
    count: Int(FlatBufferMaxSize) + 1,
    alignment: 1)
  var buffer: ByteBuffer!
  var validFlatbuffersObject: ByteBuffer!
  var invalidFlatbuffersObject: ByteBuffer!
  override func setUp() {
    // swiftformat:disable all
    buffer = ByteBuffer(initialSize: 32)
    add(buffer: &buffer, v: 4, p: 16)
    add(buffer: &buffer, v: 4, p: 20)
    validFlatbuffersObject = ByteBuffer(bytes: [48, 0, 0, 0, 77, 79, 78, 83, 0, 0, 0, 0, 36, 0, 72, 0, 40, 0, 0, 0, 38, 0, 32, 0, 0, 0, 28, 0, 0, 0, 27, 0, 20, 0, 16, 0, 12, 0, 4, 0, 0, 0, 0, 0, 0, 0, 11, 0, 36, 0, 0, 0, 164, 0, 0, 0, 0, 0, 0, 1, 60, 0, 0, 0, 68, 0, 0, 0, 76, 0, 0, 0, 0, 0, 0, 1, 88, 0, 0, 0, 120, 0, 0, 0, 0, 0, 80, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 64, 2, 0, 5, 0, 6, 0, 0, 0, 2, 0, 0, 0, 64, 0, 0, 0, 48, 0, 0, 0, 2, 0, 0, 0, 30, 0, 40, 0, 10, 0, 20, 0, 152, 255, 255, 255, 4, 0, 0, 0, 4, 0, 0, 0, 70, 114, 101, 100, 0, 0, 0, 0, 5, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 5, 0, 0, 0, 116, 101, 115, 116, 50, 0, 0, 0, 5, 0, 0, 0, 116, 101, 115, 116, 49, 0, 0, 0, 9, 0, 0, 0, 77, 121, 77, 111, 110, 115, 116, 101, 114, 0, 0, 0, 3, 0, 0, 0, 20, 0, 0, 0, 36, 0, 0, 0, 4, 0, 0, 0, 240, 255, 255, 255, 32, 0, 0, 0, 248, 255, 255, 255, 36, 0, 0, 0, 12, 0, 8, 0, 0, 0, 0, 0, 0, 0, 4, 0, 12, 0, 0, 0, 28, 0, 0, 0, 5, 0, 0, 0, 87, 105, 108, 109, 97, 0, 0, 0, 6, 0, 0, 0, 66, 97, 114, 110, 101, 121, 0, 0, 5, 0, 0, 0, 70, 114, 111, 100, 111, 0, 0, 0])
    invalidFlatbuffersObject = ByteBuffer(bytes: [0, 48, 0, 0, 0, 77, 79, 78, 83, 0, 0, 0, 0, 36, 0, 72, 0, 40, 0, 0, 0, 38, 0, 32, 0, 0, 0, 28, 0, 0, 0, 27, 0, 20, 0, 16, 0, 12, 0, 4, 0, 0, 0, 0, 0, 0, 0, 11, 0, 36, 0, 0, 0, 164, 0, 0, 0, 0, 0, 0, 1, 60, 0, 0, 0, 68, 0, 0, 0, 76, 0, 0, 0, 0, 0, 0, 1, 88, 0, 0, 0, 120, 0, 0, 0, 0, 0, 80, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 64, 2, 0, 5, 0, 6, 0, 0, 0, 2, 0, 0, 0, 64, 0, 0, 0, 48, 0, 0, 0, 2, 0, 0, 0, 30, 0, 40, 0, 10, 0, 20, 0, 152, 255, 255, 255, 4, 0, 0, 0, 4, 0, 0, 0, 70, 114, 101, 100, 0, 0, 0, 0, 5, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 5, 0, 0, 0, 116, 101, 115, 116, 50, 0, 0, 0, 5, 0, 0, 0, 116, 101, 115, 116, 49, 0, 0, 0, 9, 0, 0, 0, 77, 121, 77, 111, 110, 115, 116, 101, 114, 0, 0, 0, 3, 0, 0, 0, 20, 0, 0, 0, 36, 0, 0, 0, 4, 0, 0, 0, 240, 255, 255, 255, 32, 0, 0, 0, 248, 255, 255, 255, 36, 0, 0, 0, 12, 0, 8, 0, 0, 0, 0, 0, 0, 0, 4, 0, 12, 0, 0, 0, 28, 0, 0, 0, 5, 0, 0, 0, 87, 105, 108, 109, 97, 0, 0, 0, 6, 0, 0, 0, 66, 97, 114, 110, 101, 121, 0, 0, 5, 0, 0, 0, 70, 114, 111, 100, 111, 0, 0, 0])
    // swiftformat:enable all
  }
  func testVeriferInitPassing() {
    var buffer = ByteBuffer(initialSize: 0)
    buffer._storage = validStorage
    XCTAssertNoThrow(try Verifier(buffer: &buffer))
  }
  func testVeriferInitFailing() {
    var buffer = ByteBuffer(initialSize: 0)
    buffer._storage = errorStorage
    XCTAssertThrowsError(try Verifier(buffer: &buffer))
  }
  func testVerifierCheckAlignment() {
    var verifier = try! Verifier(buffer: &buffer)
    do {
      try verifier.isAligned(position: 20, type: Int.self)
    } catch {
      XCTAssertEqual(
        error as? FlatbuffersErrors,
        .missAlignedPointer(position: 20, type: "Int"))
    }
    XCTAssertNoThrow(try verifier.isAligned(position: 16, type: Int.self))
    var newVerifer = try! Verifier(buffer: &buffer, checkAlignment: false)
    XCTAssertNoThrow(try newVerifer.isAligned(position: 16, type: Int.self))
  }
  func testRangeInBuffer() {
    var verifier = try! Verifier(buffer: &buffer)
    let size = MemoryLayout<Int64>.size
    XCTAssertNoThrow(try verifier.rangeInBuffer(position: 24, size: size))
    XCTAssertThrowsError(try verifier.rangeInBuffer(position: 26, size: size))
    XCTAssertThrowsError(try verifier.rangeInBuffer(position: 26, size: size))
    XCTAssertThrowsError(try verifier.rangeInBuffer(position: 30, size: size))
    XCTAssertThrowsError(try verifier.rangeInBuffer(position: 32, size: size))
    XCTAssertThrowsError(try verifier.rangeInBuffer(position: 34, size: size))
    verifier = try! Verifier(
      buffer: &buffer,
      options: .init(maxDepth: 0, maxTableCount: 0, maxApparentSize: 4))
    do {
      try verifier.rangeInBuffer(position: 24, size: size)
    } catch {
      XCTAssertEqual(
        error as! FlatbuffersErrors,
        .apparentSizeTooLarge)
    }
  }
  func testPositionInBuffer() {
    var verifier = try! Verifier(buffer: &buffer)
    XCTAssertNoThrow(try verifier.inBuffer(position: 0, of: Int64.self))
    XCTAssertNoThrow(try verifier.inBuffer(position: 24, of: Int64.self))
    XCTAssertThrowsError(try verifier.inBuffer(position: -9, of: Int64.self))
    XCTAssertThrowsError(try verifier.inBuffer(position: 25, of: Int64.self))
    XCTAssertThrowsError(try verifier.inBuffer(position: 26, of: Int32.self))
    XCTAssertThrowsError(try verifier.inBuffer(position: 26, of: Int64.self))
    XCTAssertThrowsError(try verifier.inBuffer(position: 30, of: Int64.self))
    XCTAssertThrowsError(try verifier.inBuffer(position: 32, of: Int64.self))
    XCTAssertThrowsError(try verifier.inBuffer(position: 34, of: Int64.self))
  }
  func testVisitTable() {
    var verifier = try! Verifier(buffer: &validFlatbuffersObject)
    XCTAssertNoThrow(try verifier.visitTable(at: 48))
    verifier.reset()
  }
  func testTableVerifier() {
    var verifier = try! Verifier(buffer: &validFlatbuffersObject)
    var tableVerifer = try! verifier.visitTable(at: 48)
    XCTAssertNoThrow(try tableVerifer.visit(
      field: 4,
      fieldName: "Vec",
      required: false,
      type: Vec3.self))
    XCTAssertNoThrow(try tableVerifer.visit(
      field: 8,
      fieldName: "hp",
      required: false,
      type: Int16.self))
    XCTAssertNoThrow(try tableVerifer.visit(
      field: 10,
      fieldName: "name",
      required: true,
      type: ForwardOffset<String>.self))
    XCTAssertNoThrow(try tableVerifer.visit(
      field: 14,
      fieldName: "inventory",
      required: false,
      type: ForwardOffset<Vector<UInt8, UInt8>>.self))
    XCTAssertNoThrow(try tableVerifer.visit(
      field: 22,
      fieldName: "test4",
      required: false,
      type: ForwardOffset<Vector<MyGame_Example_Test, MyGame_Example_Test>>
        .self))
    XCTAssertNoThrow(try tableVerifer.visit(
      field: 24,
      fieldName: "Vector of strings",
      required: false,
      type: ForwardOffset<Vector<ForwardOffset<String>, String>>.self))
    do {
      try tableVerifer.visit(
        field: 13,
        fieldName: "notvalid",
        required: false,
        type: Int16.self)
    } catch {
      XCTAssertEqual(
        error as! FlatbuffersErrors,
        .missAlignedPointer(position: 25, type: "UInt16"))
    }
    do {
      try tableVerifer.visit(
        unionKey: 18,
        unionField: 20,
        unionKeyName: "testType",
        fieldName: "test",
        required: false,
        completion: { (verifier, key: MyGame_Example_Any_, pos) in
          switch key {
          case .none_:
            break
          case .monster:
            try ForwardOffset<MyGame_Example_Monster>.verify(
              &verifier,
              at: pos,
              of: MyGame_Example_Monster.self)
          case .testsimpletablewithenum:
            break
          case .mygameExample2Monster:
            break
          }
        })
    } catch {
      XCTAssertEqual(
        error as! FlatbuffersErrors,
        .missAlignedPointer(position: 25, type: "UInt16"))
    }
  }
  func testVerifyUnionVectors() {
    // swiftformat:disable all
    var byteBuffer = ByteBuffer(bytes: [20, 0, 0, 0, 77, 79, 86, 73, 12, 0, 12, 0, 0, 0, 0, 0, 8, 0, 4, 0, 12, 0, 0, 0, 8, 0, 0, 0, 20, 0, 0, 0, 3, 0, 0, 0, 24, 0, 0, 0, 32, 0, 0, 0, 12, 0, 0, 0, 3, 0, 0, 0, 3, 1, 4, 0, 2, 0, 0, 0, 7, 0, 0, 0, 0, 0, 6, 0, 8, 0, 4, 0, 6, 0, 0, 0, 8, 0, 0, 0])
    // swiftformat:enable all
    XCTAssertNoThrow(try getCheckedRoot(byteBuffer: &byteBuffer) as Movie)
  }
  func testErrorWrongFileId() {
    // swiftformat:disable all
    var byteBuffer = ByteBuffer(bytes: [20, 0, 0, 0, 77, 79, 86, 73, 12, 0, 12, 0, 0, 0, 0, 0, 8, 0, 4, 0, 12, 0, 0, 0, 8, 0, 0, 0, 20, 0, 0, 0, 3, 0, 0, 0, 24, 0, 0, 0, 32, 0, 0, 0, 12, 0, 0, 0, 3, 0, 0, 0, 3, 1, 4, 0, 2, 0, 0, 0, 7, 0, 0, 0, 0, 0, 6, 0, 8, 0, 4, 0, 6, 0, 0, 0, 8, 0, 0, 0])
    // swiftformat:enable all
    XCTAssertThrowsError(try getCheckedRoot(
      byteBuffer: &byteBuffer,
      fileId: "FLEX") as Movie)
  }
  func testVerifyPrefixedBuffer() {
    // swiftformat:disable all
    var byteBuffer = ByteBuffer(bytes: [0, 0, 0, 1, 20, 0, 0, 0, 77, 79, 86, 73, 12, 0, 12, 0, 0, 0, 0, 0, 8, 0, 4, 0, 12, 0, 0, 0, 8, 0, 0, 0, 20, 0, 0, 0, 3, 0, 0, 0, 24, 0, 0, 0, 32, 0, 0, 0, 12, 0, 0, 0, 3, 0, 0, 0, 3, 1, 4, 0, 2, 0, 0, 0, 7, 0, 0, 0, 0, 0, 6, 0, 8, 0, 4, 0, 6, 0, 0, 0, 8, 0, 0, 0])
    // swiftformat:enable all
    XCTAssertThrowsError(
      try getCheckedPrefixedSizeRoot(byteBuffer: &byteBuffer) as Movie)
  }
  func testFullVerifier() {
    XCTAssertNoThrow(
      try getCheckedRoot(
        byteBuffer: &validFlatbuffersObject) as MyGame_Example_Monster)
  }
  func testFullVerifierWithFileId() {
    XCTAssertNoThrow(
      try getCheckedRoot(
        byteBuffer: &validFlatbuffersObject,
        fileId: MyGame_Example_Monster.id) as MyGame_Example_Monster)
  }
  func testInvalidBuffer() {
    XCTAssertThrowsError(
      try getCheckedRoot(
        byteBuffer: &invalidFlatbuffersObject) as MyGame_Example_Monster)
  }
  func testValidUnionBuffer() {
    let string = "Awesome \\\\t\t\nstring!"
    var fb = FlatBufferBuilder()
    let stringOffset = fb.create(string: string)
    let characterType: [Character] = [.bookfan, .other]
    let characters = [
      fb.create(struct: BookReader(booksRead: 7)),
      stringOffset,
    ]
    let types = fb.createVector(characterType)
    let characterVector = fb.createVector(ofOffsets: characters)
    let end = Movie.createMovie(
      &fb,
      mainCharacterType: .other,
      mainCharacterOffset: Offset(offset: stringOffset.o),
      charactersTypeVectorOffset: types,
      charactersVectorOffset: characterVector)
    Movie.finish(&fb, end: end)
    var buf = fb.sizedBuffer
    XCTAssertNoThrow(try getCheckedRoot(byteBuffer: &buf) as Movie)
  }
  func add(buffer: inout ByteBuffer, v: Int32, p: Int) {
    buffer.write(value: v, index: p)
  }
}


FlatBuffersVectorsTests

/*
final class FlatBuffersVectors: XCTestCase {
  func testCreatingTwoCountries() {
    let norway = "Norway"
    let denmark = "Denmark"
    var b = FlatBufferBuilder(initialSize: 20)
    let noStr = b.create(string: norway)
    let deStr = b.create(string: denmark)
    let n = Country.createCountry(
      builder: &b,
      offset: noStr,
      log: 888,
      lan: 700)
    let d = Country.createCountry(
      builder: &b,
      offset: deStr,
      log: 200,
      lan: 100)
    let vector = [n, d]
    let vectorOffset = b.createVector(ofOffsets: vector)
    b.finish(offset: vectorOffset)
    // swiftformat:disable all
    XCTAssertEqual(b.sizedByteArray, [4, 0, 0, 0, 2, 0, 0, 0, 48, 0, 0, 0, 16, 0, 0, 0, 0, 0, 10, 0, 18, 0, 4, 0, 8, 0, 12, 0, 10, 0, 0, 0, 40, 0, 0, 0, 100, 0, 0, 0, 200, 0, 0, 0, 0, 0, 10, 0, 16, 0, 4, 0, 8, 0, 12, 0, 10, 0, 0, 0, 24, 0, 0, 0, 188, 2, 0, 0, 120, 3, 0, 0, 7, 0, 0, 0, 68, 101, 110, 109, 97, 114, 107, 0, 6, 0, 0, 0, 78, 111, 114, 119, 97, 121, 0, 0])
    // swiftformat:enable all
  }
  func testCreateIntArray() {
    let numbers: [Int32] = [1, 2, 3, 4, 5]
    var b = FlatBufferBuilder(initialSize: 20)
    let o = b.createVector(numbers, size: numbers.count)
    b.finish(offset: o)
    // swiftformat:disable all
    XCTAssertEqual(b.sizedByteArray, [4, 0, 0, 0, 5, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0])
    // swiftformat:enable all
  }
  func testCreateEmptyIntArray() {
    let numbers: [Int32] = []
    var b = FlatBufferBuilder(initialSize: 20)
    let o = b.createVector(numbers, size: numbers.count)
    b.finish(offset: o)
    XCTAssertEqual(b.sizedByteArray, [4, 0, 0, 0, 0, 0, 0, 0])
  }
  func testCreateVectorOfStrings() {
    let strs = ["Denmark", "Norway"]
    var b = FlatBufferBuilder(initialSize: 20)
    let o = b.createVector(ofStrings: strs)
    b.finish(offset: o)
    // swiftformat:disable all
    XCTAssertEqual(b.sizedByteArray, [4, 0, 0, 0, 2, 0, 0, 0, 20, 0, 0, 0, 4, 0, 0, 0, 6, 0, 0, 0, 78, 111, 114, 119, 97, 121, 0, 0, 7, 0, 0, 0, 68, 101, 110, 109, 97, 114, 107, 0])
    // swiftformat:enable all
  }
  func testCreateSharedStringVector() {
    let norway = "Norway"
    let denmark = "Denmark"
    var b = FlatBufferBuilder(initialSize: 20)
    let noStr = b.createShared(string: norway)
    let deStr = b.createShared(string: denmark)
    let _noStr = b.createShared(string: norway)
    let _deStr = b.createShared(string: denmark)
    let v = [noStr, deStr, _noStr, _deStr]
    let end = b.createVector(ofOffsets: v)
    b.finish(offset: end)
    // swiftformat:disable all
    XCTAssertEqual(b.sizedByteArray, [4, 0, 0, 0, 4, 0, 0, 0, 28, 0, 0, 0, 12, 0, 0, 0, 20, 0, 0, 0, 4, 0, 0, 0, 7, 0, 0, 0, 68, 101, 110, 109, 97, 114, 107, 0, 6, 0, 0, 0, 78, 111, 114, 119, 97, 121, 0, 0])
    // swiftformat:enable all
  }
  func testReadInt32Array() {
    let data: [Int32] = [1, 2, 3, 4, 5]
    var b = FlatBufferBuilder(initialSize: 20)
    let v = Numbers.createNumbersVector(b: &b, array: data)
    let end = Numbers.createNumbers(b: &b, o: v)
    b.finish(offset: end)
    let number = Numbers.getRootAsNumbers(ByteBuffer(bytes: b.sizedByteArray))
    XCTAssertEqual(number.vArrayInt32, [1, 2, 3, 4, 5])
  }
  func testReadDoubleArray() {
    let data: [Double] = [1, 2, 3, 4, 5]
    var b = FlatBufferBuilder(initialSize: 20)
    let v = Numbers.createNumbersVector(b: &b, array: data)
    let end = Numbers.createNumbers(b: &b, o: v)
    b.finish(offset: end)
    let number = Numbers.getRootAsNumbers(ByteBuffer(bytes: b.sizedByteArray))
    XCTAssertEqual(number.vArrayDouble, [1, 2, 3, 4, 5])
  }
  func testHasForArray() {
    var builder = FlatBufferBuilder(initialSize: 20)
    let emptyVector = [UInt8]()
    let emptyOffset = builder.createVector(emptyVector)
    let nonEmptyVector = [1, 2, 3]
    let nonEmptyVectorOffest = builder.createVector(nonEmptyVector)
    let start = Swift_Tests_Vectors.startVectors(&builder)
    Swift_Tests_Vectors.addVectorOf(empty: emptyOffset, &builder)
    Swift_Tests_Vectors.addVectorOf(array: nonEmptyVectorOffest, &builder)
    let finish = Swift_Tests_Vectors.endVectors(&builder, start: start)
    builder.finish(offset: finish)
    var byteBuffer = ByteBuffer(bytes: builder.sizedByteArray)
    let msg: Swift_Tests_Vectors = getRoot(byteBuffer: &byteBuffer)
    XCTAssertEqual(msg.hasNone, false)
    XCTAssertEqual(msg.hasEmpty, true)
    XCTAssertEqual(msg.emptyCount, 0)
    XCTAssertEqual(msg.hasArray, true)
    XCTAssertEqual(msg.arrayCount, 3)
    XCTAssertEqual(msg.array, [1, 2, 3])
  }
}
struct Numbers {
  private var __t: Table
  private init(_ t: Table) {
    __t = t
  }
  static func getRootAsNumbers(_ bb: ByteBuffer) -> Numbers {
    Numbers(Table(
      bb: bb,
      position: Int32(bb.read(def: UOffset.self, position: 0))))
  }
  var vArrayInt: [Int]? { __t.getVector(at: 4) }
  var vArrayInt32: [Int32]? { __t.getVector(at: 4) }
  var vArrayDouble: [Double]? { __t.getVector(at: 4) }
  var vArrayFloat: [Float32]? { __t.getVector(at: 4) }
  static func createNumbersVector(
    b: inout FlatBufferBuilder,
    array: [Int]) -> Offset
  {
    b.createVector(array, size: array.count)
  }
  static func createNumbersVector(
    b: inout FlatBufferBuilder,
    array: [Int32]) -> Offset
  {
    b.createVector(array, size: array.count)
  }
  static func createNumbersVector(
    b: inout FlatBufferBuilder,
    array: [Double]) -> Offset
  {
    b.createVector(array, size: array.count)
  }
  static func createNumbersVector(
    b: inout FlatBufferBuilder,
    array: [Float32]) -> Offset
  {
    b.createVector(array, size: array.count)
  }
  static func createNumbers(b: inout FlatBufferBuilder, o: Offset) -> Offset {
    let start = b.startTable(with: 1)
    b.add(offset: o, at: 4)
    return Offset(offset: b.endTable(at: start))
  }
}


FlatBuffersTests

/*
final class FlatBuffersTests: XCTestCase {
  let country = "Norway"
  func testEndian() { XCTAssertEqual(isLitteEndian, true) }
  func testOffset() {
    let o = Offset()
    let b = Offset(offset: 1)
    XCTAssertEqual(o.isEmpty, true)
    XCTAssertEqual(b.isEmpty, false)
  }
  func testCreateString() {
    let helloWorld = "Hello, world!"
    var b = FlatBufferBuilder(initialSize: 16)
    XCTAssertEqual(b.create(string: country).o, 12)
    XCTAssertEqual(b.create(string: helloWorld).o, 32)
    b.clear()
    XCTAssertEqual(b.create(string: helloWorld).o, 20)
    XCTAssertEqual(b.create(string: country).o, 32)
    b.clear()
    XCTAssertEqual(b.create(string: String(repeating: "a", count: 257)).o, 264)
  }
  func testStartTable() {
    var b = FlatBufferBuilder(initialSize: 16)
    XCTAssertNoThrow(b.startTable(with: 0))
    b.clear()
    XCTAssertEqual(b.create(string: country).o, 12)
    XCTAssertEqual(b.startTable(with: 0), 12)
  }
  func testCreateFinish() {
    var b = FlatBufferBuilder(initialSize: 16)
    let countryOff = Country.createCountry(
      builder: &b,
      name: country,
      log: 200,
      lan: 100)
    b.finish(offset: countryOff)
    // swiftformat:disable all
    let v: [UInt8] = [16, 0, 0, 0, 0, 0, 10, 0, 16, 0, 4, 0, 8, 0, 12, 0, 10, 0, 0, 0, 12, 0, 0, 0, 100, 0, 0, 0, 200, 0, 0, 0, 6, 0, 0, 0, 78, 111, 114, 119, 97, 121, 0, 0]
    // swiftformat:enable all
    XCTAssertEqual(b.sizedByteArray, v)
  }
  func testCreateFinishWithPrefix() {
    var b = FlatBufferBuilder(initialSize: 16)
    let countryOff = Country.createCountry(
      builder: &b,
      name: country,
      log: 200,
      lan: 100)
    b.finish(offset: countryOff, addPrefix: true)
    // swiftformat:disable all
    let v: [UInt8] = [44, 0, 0, 0, 16, 0, 0, 0, 0, 0, 10, 0, 16, 0, 4, 0, 8, 0, 12, 0, 10, 0, 0, 0, 12, 0, 0, 0, 100, 0, 0, 0, 200, 0, 0, 0, 6, 0, 0, 0, 78, 111, 114, 119, 97, 121, 0, 0]
    // swiftformat:enable all
    XCTAssertEqual(b.sizedByteArray, v)
  }
  func testReadCountry() {
    // swiftformat:disable all
    let v: [UInt8] = [16, 0, 0, 0, 0, 0, 10, 0, 16, 0, 4, 0, 8, 0, 12, 0, 10, 0, 0, 0, 12, 0, 0, 0, 100, 0, 0, 0, 200, 0, 0, 0, 6, 0, 0, 0, 78, 111, 114, 119, 97, 121, 0, 0]
    // swiftformat:enable all
    let buffer = ByteBuffer(bytes: v)
    let c = Country.getRootAsCountry(buffer)
    XCTAssertEqual(c.lan, 100)
    XCTAssertEqual(c.log, 200)
    XCTAssertEqual(c.nameVector, [78, 111, 114, 119, 97, 121])
    XCTAssertEqual(c.name, country)
  }
  func testWriteNullableStrings() {
    var b = FlatBufferBuilder()
    XCTAssertTrue(b.create(string: nil).isEmpty)
    XCTAssertTrue(b.createShared(string: nil).isEmpty)
  }
  func testWriteOptionalValues() {
    var b = FlatBufferBuilder()
    let root = optional_scalars_ScalarStuff.createScalarStuff(
      &b,
      justI8: 80,
      maybeI8: nil,
      justU8: 100,
      maybeU8: 10,
      maybeBool: true,
      justEnum: .one,
      maybeEnum: nil)
    b.finish(offset: root)
    var buffer = b.sizedBuffer
    let scalarTable: optional_scalars_ScalarStuff = getRoot(byteBuffer: &buffer)
    XCTAssertEqual(scalarTable.justI8, 80)
    XCTAssertNil(scalarTable.maybeI8)
    XCTAssertEqual(scalarTable.maybeBool, true)
    XCTAssertEqual(scalarTable.defaultI8, 42)
    XCTAssertEqual(scalarTable.justU8, 100)
    XCTAssertEqual(scalarTable.maybeU8, 10)
    XCTAssertEqual(scalarTable.justEnum, .one)
    XCTAssertNil(scalarTable.maybeEnum)
  }
}
class Country {
  static let offsets: (name: VOffset, lan: VOffset, lng: VOffset) = (4, 6, 8)
  private var __t: Table
  private init(_ t: Table) {
    __t = t
  }
  var lan: Int32 { let o = __t.offset(6); return o == 0 ? 0 : __t.readBuffer(
    of: Int32.self,
    at: o) }
  var log: Int32 { let o = __t.offset(8); return o == 0 ? 0 : __t.readBuffer(
    of: Int32.self,
    at: o) }
  var nameVector: [UInt8]? { __t.getVector(at: 4) }
  var name: String? {
    let o = __t.offset(4); return o == 0 ? nil : __t.string(at: o) }
  static func createCountry(
    builder: inout FlatBufferBuilder,
    name: String,
    log: Int32,
    lan: Int32) -> Offset
  {
    createCountry(
      builder: &builder,
      offset: builder.create(string: name),
      log: log,
      lan: lan)
  }
  static func end(
    builder: inout FlatBufferBuilder,
    startOffset: UOffset) -> Offset
  {
    Offset(offset: builder.endTable(at: startOffset))
  }
  static func add(builder: inout FlatBufferBuilder, lng: Int32) {
    builder.add(element: lng, def: 0, at: Country.offsets.lng)
  }
}


FlatBuffersStructsTests

/*
final class FlatBuffersStructsTests: XCTestCase {
  func testWritingAndMutatingBools() {
    var fbb = FlatBufferBuilder()
    let start = TestMutatingBool.startTestMutatingBool(&fbb)
    TestMutatingBool.add(b: Property(property: false), &fbb)
    let root = TestMutatingBool.endTestMutatingBool(&fbb, start: start)
    fbb.finish(offset: root)
    var buffer = fbb.sizedBuffer
    let testMutatingBool: TestMutatingBool = getRoot(byteBuffer: &buffer)
    let property = testMutatingBool.mutableB
    XCTAssertEqual(property?.property, false)
    property?.mutate(property: false)
    XCTAssertEqual(property?.property, false)
    property?.mutate(property: true)
    XCTAssertEqual(property?.property, true)
  }
}
struct Vec: NativeStruct {
  var x: Float32
  var y: Float32
  var z: Float32
}


// Generated GRPC code for FlatBuffers swift!
/// The following code is generated by the Flatbuffers library which might not be in sync with grpc-swift
/// in case of an issue please open github issue, though it would be maintained
// swiftlint:disable all
// swiftformat:disable all
import Foundation
import GRPC
import NIO
import NIOHTTP1
import FlatBuffers
public protocol GRPCFlatBufPayload: GRPCPayload, FlatBufferGRPCMessage {}
public extension GRPCFlatBufPayload {
  init(serializedByteBuffer: inout NIO.ByteBuffer) throws {
    self.init(byteBuffer: FlatBuffers.ByteBuffer(contiguousBytes: serializedByteBuffer.readableBytesView, count: serializedByteBuffer.readableBytes))
  }
  func serialize(into buffer: inout NIO.ByteBuffer) throws {
    let buf = UnsafeRawBufferPointer(start: self.rawPointer, count: Int(self.size))
    buffer.writeBytes(buf)
  }
}
extension Message: GRPCFlatBufPayload {}
/// Usage: instantiate MyGame_Example_MonsterStorageServiceClient, then call methods of this protocol to make API calls.
public protocol MyGame_Example_MonsterStorageClientProtocol: GRPCClient {
  var serviceName: String { get }
  var interceptors: MyGame_Example_MonsterStorageClientInterceptorFactoryProtocol? { get }
  func Store(
    _ request: Message<MyGame_Example_Monster>
    , callOptions: CallOptions?
  ) -> UnaryCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>
  func Retrieve(
    _ request: Message<MyGame_Example_Stat>
    , callOptions: CallOptions?,
  ) -> BidirectionalStreamingCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>
}
extension MyGame_Example_MonsterStorageClientProtocol {
  public var serviceName: String { "MyGame.Example.MonsterStorage" }
  public func Store(
    _ request: Message<MyGame_Example_Monster>
    , callOptions: CallOptions? = nil
  ) -> UnaryCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>> {
    return self.makeUnaryCall(
      path: "/MyGame.Example.MonsterStorage/Store",
      request: request,
      callOptions: callOptions ?? self.defaultCallOptions,
      interceptors: self.interceptors?.makeStoreInterceptors() ?? []
    )
  }
  public func Retrieve(
    _ request: Message<MyGame_Example_Stat>
    , callOptions: CallOptions? = nil,
  ) -> ServerStreamingCall<Message<MyGame_Example_Stat>, Message<MyGame_Example_Monster>> {
    return self.makeServerStreamingCall(
      path: "/MyGame.Example.MonsterStorage/Retrieve",
      request: request,
      callOptions: callOptions ?? self.defaultCallOptions,
      interceptors: self.interceptors?.makeRetrieveInterceptors() ?? [],
      handler: handler
    )
  }
  public func GetMaxHitPoint(
    callOptions: CallOptions? = nil
  ) -> ClientStreamingCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>> {
    return self.makeClientStreamingCall(
      path: "/MyGame.Example.MonsterStorage/GetMaxHitPoint",
      callOptions: callOptions ?? self.defaultCallOptions,
      interceptors: self.interceptors?.makeGetMaxHitPointInterceptors() ?? []
    )
  }
  public func GetMinMaxHitPoints(
    callOptions: CallOptions? = nil,
  ) -> BidirectionalStreamingCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>> {
    return self.makeBidirectionalStreamingCall(
      path: "/MyGame.Example.MonsterStorage/GetMinMaxHitPoints",
      callOptions: callOptions ?? self.defaultCallOptions,
      interceptors: self.interceptors?.makeGetMinMaxHitPointsInterceptors() ?? [],
      handler: handler
    )
  }
}
public protocol MyGame_Example_MonsterStorageClientInterceptorFactoryProtocol {
  /// - Returns: Interceptors to use when invoking 'Store'.
  func makeStoreInterceptors() -> [ClientInterceptor<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>]
  /// - Returns: Interceptors to use when invoking 'Retrieve'.
  func makeRetrieveInterceptors() -> [ClientInterceptor<Message<MyGame_Example_Stat>, Message<MyGame_Example_Monster>>]
  /// - Returns: Interceptors to use when invoking 'GetMaxHitPoint'.
  func makeGetMaxHitPointInterceptors() -> [ClientInterceptor<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>]
  /// - Returns: Interceptors to use when invoking 'GetMinMaxHitPoints'.
  func makeGetMinMaxHitPointsInterceptors() -> [ClientInterceptor<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>]
}
public final class MyGame_Example_MonsterStorageServiceClient: MyGame_Example_MonsterStorageClientProtocol {
  public let channel: GRPCChannel
  public var defaultCallOptions: CallOptions
  public var interceptors: MyGame_Example_MonsterStorageClientInterceptorFactoryProtocol?
  public init(
    channel: GRPCChannel,
    defaultCallOptions: CallOptions = CallOptions(),
    interceptors: MyGame_Example_MonsterStorageClientInterceptorFactoryProtocol? = nil
  ) {
    self.channel = channel
    self.defaultCallOptions = defaultCallOptions
    self.interceptors = interceptors
  }
}
public protocol MyGame_Example_MonsterStorageProvider: CallHandlerProvider {
  var interceptors: MyGame_Example_MonsterStorageServerInterceptorFactoryProtocol? { get }
  func Store(request: Message<MyGame_Example_Monster>, context: StatusOnlyCallContext) -> EventLoopFuture<Message<MyGame_Example_Stat>>
  func Retrieve(request: Message<MyGame_Example_Stat>, context: StreamingResponseCallContext<Message<MyGame_Example_Monster>>) -> EventLoopFuture<GRPCStatus>
  func GetMaxHitPoint(context: UnaryResponseCallContext<Message<MyGame_Example_Stat>>) -> EventLoopFuture<(StreamEvent<Message<MyGame_Example_Monster>>) -> Void>
  func GetMinMaxHitPoints(context: StreamingResponseCallContext<Message<MyGame_Example_Stat>>) -> EventLoopFuture<(StreamEvent<Message<MyGame_Example_Monster>>) -> Void>
}
public extension MyGame_Example_MonsterStorageProvider {
  var serviceName: Substring { return "MyGame.Example.MonsterStorage" }
  func handle(method name: Substring, context: CallHandlerContext) -> GRPCServerHandlerProtocol? {
    switch name {
    case "Store":
    return UnaryServerHandler(
      context: context,
      requestDeserializer: GRPCPayloadDeserializer<Message<MyGame_Example_Monster>>(),
      responseSerializer: GRPCPayloadSerializer<Message<MyGame_Example_Stat>>(),
      interceptors: self.interceptors?.makeStoreInterceptors() ?? [],
      userFunction: self.Store(request:context:))
    case "Retrieve":
    return ServerStreamingServerHandler(
      context: context,
      requestDeserializer: GRPCPayloadDeserializer<Message<MyGame_Example_Stat>>(),
      responseSerializer: GRPCPayloadSerializer<Message<MyGame_Example_Monster>>(),
      interceptors: self.interceptors?.makeRetrieveInterceptors() ?? [],
      userFunction: self.Retrieve(request:context:))
    case "GetMaxHitPoint":
    return ClientStreamingServerHandler(
      context: context,
      requestDeserializer: GRPCPayloadDeserializer<Message<MyGame_Example_Monster>>(),
      responseSerializer: GRPCPayloadSerializer<Message<MyGame_Example_Stat>>(),
      interceptors: self.interceptors?.makeGetMaxHitPointInterceptors() ?? [],
      observerFactory: self.GetMaxHitPoint(context:))
    case "GetMinMaxHitPoints":
    return BidirectionalStreamingServerHandler(
      context: context,
      requestDeserializer: GRPCPayloadDeserializer<Message<MyGame_Example_Monster>>(),
      responseSerializer: GRPCPayloadSerializer<Message<MyGame_Example_Stat>>(),
      interceptors: self.interceptors?.makeGetMinMaxHitPointsInterceptors() ?? [],
      observerFactory: self.GetMinMaxHitPoints(context:))
    default: return nil;
    }
  }
}
public protocol MyGame_Example_MonsterStorageServerInterceptorFactoryProtocol {
  /// - Returns: Interceptors to use when handling 'Store'.
  ///   Defaults to calling `self.makeInterceptors()`.
  func makeStoreInterceptors() -> [ServerInterceptor<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>]
  /// - Returns: Interceptors to use when handling 'Retrieve'.
  ///   Defaults to calling `self.makeInterceptors()`.
  func makeRetrieveInterceptors() -> [ServerInterceptor<Message<MyGame_Example_Stat>, Message<MyGame_Example_Monster>>]
  /// - Returns: Interceptors to use when handling 'GetMaxHitPoint'.
  ///   Defaults to calling `self.makeInterceptors()`.
  func makeGetMaxHitPointInterceptors() -> [ServerInterceptor<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>]
  /// - Returns: Interceptors to use when handling 'GetMinMaxHitPoints'.
  ///   Defaults to calling `self.makeInterceptors()`.
  func makeGetMinMaxHitPointsInterceptors() -> [ServerInterceptor<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>]
}


Package

// swift-tools-version:5.1
/*
 */
import PackageDescription
let package = Package(
  name: "FlatBuffers.Test.Swift.Wasm",
  platforms: [
    .macOS(.v10_14),
  ],
  dependencies: [
    .package(path: "../../.."),
  ],
  targets: [
    .target(
      name: "Wasm"),
    .testTarget(
      name: "FlatBuffers.Test.Swift.WasmTests",
      dependencies: ["FlatBuffers"]),
  ])


Wasm

/*
 */
public struct Wasm {}