// 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>>]
}


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

import FlatBuffers

public enum optional_scalars_OptionalByte: Int8, Enum, Verifiable {
  public typealias T = Int8
  public static var byteSize: Int { return MemoryLayout<Int8>.size }
  public var value: Int8 { return self.rawValue }
  case none_ = 0
  case one = 1
  case two = 2

  public static var max: optional_scalars_OptionalByte { return .two }
  public static var min: optional_scalars_OptionalByte { return .none_ }
}

extension optional_scalars_OptionalByte: Encodable {
  public func encode(to encoder: Encoder) throws {
    var container = encoder.singleValueContainer()
    switch self {
    case .none_: try container.encode("None")
    case .one: try container.encode("One")
    case .two: try container.encode("Two")
    }
  }
}

public struct optional_scalars_ScalarStuff: FlatBufferObject, Verifiable {

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

  public static var id: String { "NULL" }
  public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: optional_scalars_ScalarStuff.id, addPrefix: prefix) }
  public static func getRootAsScalarStuff(bb: ByteBuffer) -> optional_scalars_ScalarStuff { return optional_scalars_ScalarStuff(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }

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

  private enum VTOFFSET: VOffset {
    case justI8 = 4
    case maybeI8 = 6
    case defaultI8 = 8
    case justU8 = 10
    case maybeU8 = 12
    case defaultU8 = 14
    case justI16 = 16
    case maybeI16 = 18
    case defaultI16 = 20
    case justU16 = 22
    case maybeU16 = 24
    case defaultU16 = 26
    case justI32 = 28
    case maybeI32 = 30
    case defaultI32 = 32
    case justU32 = 34
    case maybeU32 = 36
    case defaultU32 = 38
    case justI64 = 40
    case maybeI64 = 42
    case defaultI64 = 44
    case justU64 = 46
    case maybeU64 = 48
    case defaultU64 = 50
    case justF32 = 52
    case maybeF32 = 54
    case defaultF32 = 56
    case justF64 = 58
    case maybeF64 = 60
    case defaultF64 = 62
    case justBool = 64
    case maybeBool = 66
    case defaultBool = 68
    case justEnum = 70
    case maybeEnum = 72
    case defaultEnum = 74
    var v: Int32 { Int32(self.rawValue) }
    var p: VOffset { self.rawValue }
  }

  public var justI8: Int8 { let o = _accessor.offset(VTOFFSET.justI8.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int8.self, at: o) }
  public var maybeI8: Int8? { let o = _accessor.offset(VTOFFSET.maybeI8.v); return o == 0 ? nil : _accessor.readBuffer(of: Int8.self, at: o) }
  public var defaultI8: Int8 { let o = _accessor.offset(VTOFFSET.defaultI8.v); return o == 0 ? 42 : _accessor.readBuffer(of: Int8.self, at: o) }
  public var justU8: UInt8 { let o = _accessor.offset(VTOFFSET.justU8.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt8.self, at: o) }
  public var maybeU8: UInt8? { let o = _accessor.offset(VTOFFSET.maybeU8.v); return o == 0 ? nil : _accessor.readBuffer(of: UInt8.self, at: o) }
  public var defaultU8: UInt8 { let o = _accessor.offset(VTOFFSET.defaultU8.v); return o == 0 ? 42 : _accessor.readBuffer(of: UInt8.self, at: o) }
  public var justI16: Int16 { let o = _accessor.offset(VTOFFSET.justI16.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int16.self, at: o) }
  public var maybeI16: Int16? { let o = _accessor.offset(VTOFFSET.maybeI16.v); return o == 0 ? nil : _accessor.readBuffer(of: Int16.self, at: o) }
  public var defaultI16: Int16 { let o = _accessor.offset(VTOFFSET.defaultI16.v); return o == 0 ? 42 : _accessor.readBuffer(of: Int16.self, at: o) }
  public var justU16: UInt16 { let o = _accessor.offset(VTOFFSET.justU16.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt16.self, at: o) }
  public var maybeU16: UInt16? { let o = _accessor.offset(VTOFFSET.maybeU16.v); return o == 0 ? nil : _accessor.readBuffer(of: UInt16.self, at: o) }
  public var defaultU16: UInt16 { let o = _accessor.offset(VTOFFSET.defaultU16.v); return o == 0 ? 42 : _accessor.readBuffer(of: UInt16.self, at: o) }
  public var justI32: Int32 { let o = _accessor.offset(VTOFFSET.justI32.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) }
  public var maybeI32: Int32? { let o = _accessor.offset(VTOFFSET.maybeI32.v); return o == 0 ? nil : _accessor.readBuffer(of: Int32.self, at: o) }
  public var defaultI32: Int32 { let o = _accessor.offset(VTOFFSET.defaultI32.v); return o == 0 ? 42 : _accessor.readBuffer(of: Int32.self, at: o) }
  public var justU32: UInt32 { let o = _accessor.offset(VTOFFSET.justU32.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt32.self, at: o) }
  public var maybeU32: UInt32? { let o = _accessor.offset(VTOFFSET.maybeU32.v); return o == 0 ? nil : _accessor.readBuffer(of: UInt32.self, at: o) }
  public var defaultU32: UInt32 { let o = _accessor.offset(VTOFFSET.defaultU32.v); return o == 0 ? 42 : _accessor.readBuffer(of: UInt32.self, at: o) }
  public var justI64: Int64 { let o = _accessor.offset(VTOFFSET.justI64.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int64.self, at: o) }
  public var maybeI64: Int64? { let o = _accessor.offset(VTOFFSET.maybeI64.v); return o == 0 ? nil : _accessor.readBuffer(of: Int64.self, at: o) }
  public var defaultI64: Int64 { let o = _accessor.offset(VTOFFSET.defaultI64.v); return o == 0 ? 42 : _accessor.readBuffer(of: Int64.self, at: o) }
  public var justU64: UInt64 { let o = _accessor.offset(VTOFFSET.justU64.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt64.self, at: o) }
  public var maybeU64: UInt64? { let o = _accessor.offset(VTOFFSET.maybeU64.v); return o == 0 ? nil : _accessor.readBuffer(of: UInt64.self, at: o) }
  public var defaultU64: UInt64 { let o = _accessor.offset(VTOFFSET.defaultU64.v); return o == 0 ? 42 : _accessor.readBuffer(of: UInt64.self, at: o) }
  public var justF32: Float32 { let o = _accessor.offset(VTOFFSET.justF32.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Float32.self, at: o) }
  public var maybeF32: Float32? { let o = _accessor.offset(VTOFFSET.maybeF32.v); return o == 0 ? nil : _accessor.readBuffer(of: Float32.self, at: o) }
  public var defaultF32: Float32 { let o = _accessor.offset(VTOFFSET.defaultF32.v); return o == 0 ? 42.0 : _accessor.readBuffer(of: Float32.self, at: o) }
  public var justF64: Double { let o = _accessor.offset(VTOFFSET.justF64.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
  public var maybeF64: Double? { let o = _accessor.offset(VTOFFSET.maybeF64.v); return o == 0 ? nil : _accessor.readBuffer(of: Double.self, at: o) }
  public var defaultF64: Double { let o = _accessor.offset(VTOFFSET.defaultF64.v); return o == 0 ? 42.0 : _accessor.readBuffer(of: Double.self, at: o) }
  public var justBool: Bool { let o = _accessor.offset(VTOFFSET.justBool.v); return o == 0 ? false : 0 != _accessor.readBuffer(of: Byte.self, at: o) }
  public var maybeBool: Bool? { let o = _accessor.offset(VTOFFSET.maybeBool.v); return o == 0 ? nil : 0 != _accessor.readBuffer(of: Byte.self, at: o) }
  public var defaultBool: Bool { let o = _accessor.offset(VTOFFSET.defaultBool.v); return o == 0 ? true : 0 != _accessor.readBuffer(of: Byte.self, at: o) }
  public var justEnum: optional_scalars_OptionalByte { let o = _accessor.offset(VTOFFSET.justEnum.v); return o == 0 ? .none_ : optional_scalars_OptionalByte(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? .none_ }
  public var maybeEnum: optional_scalars_OptionalByte? { let o = _accessor.offset(VTOFFSET.maybeEnum.v); return o == 0 ? nil : optional_scalars_OptionalByte(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? nil }
  public var defaultEnum: optional_scalars_OptionalByte { let o = _accessor.offset(VTOFFSET.defaultEnum.v); return o == 0 ? .one : optional_scalars_OptionalByte(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? .one }
  public static func startScalarStuff(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 36) }
  public static func add(justI8: Int8, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justI8, def: 0, at: VTOFFSET.justI8.p) }
  public static func add(maybeI8: Int8?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeI8, at: VTOFFSET.maybeI8.p) }
  public static func add(defaultI8: Int8, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultI8, def: 42, at: VTOFFSET.defaultI8.p) }
  public static func add(justU8: UInt8, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justU8, def: 0, at: VTOFFSET.justU8.p) }
  public static func add(maybeU8: UInt8?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeU8, at: VTOFFSET.maybeU8.p) }
  public static func add(defaultU8: UInt8, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultU8, def: 42, at: VTOFFSET.defaultU8.p) }
  public static func add(justI16: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justI16, def: 0, at: VTOFFSET.justI16.p) }
  public static func add(maybeI16: Int16?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeI16, at: VTOFFSET.maybeI16.p) }
  public static func add(defaultI16: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultI16, def: 42, at: VTOFFSET.defaultI16.p) }
  public static func add(justU16: UInt16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justU16, def: 0, at: VTOFFSET.justU16.p) }
  public static func add(maybeU16: UInt16?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeU16, at: VTOFFSET.maybeU16.p) }
  public static func add(defaultU16: UInt16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultU16, def: 42, at: VTOFFSET.defaultU16.p) }
  public static func add(justI32: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justI32, def: 0, at: VTOFFSET.justI32.p) }
  public static func add(maybeI32: Int32?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeI32, at: VTOFFSET.maybeI32.p) }
  public static func add(defaultI32: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultI32, def: 42, at: VTOFFSET.defaultI32.p) }
  public static func add(justU32: UInt32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justU32, def: 0, at: VTOFFSET.justU32.p) }
  public static func add(maybeU32: UInt32?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeU32, at: VTOFFSET.maybeU32.p) }
  public static func add(defaultU32: UInt32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultU32, def: 42, at: VTOFFSET.defaultU32.p) }
  public static func add(justI64: Int64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justI64, def: 0, at: VTOFFSET.justI64.p) }
  public static func add(maybeI64: Int64?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeI64, at: VTOFFSET.maybeI64.p) }
  public static func add(defaultI64: Int64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultI64, def: 42, at: VTOFFSET.defaultI64.p) }
  public static func add(justU64: UInt64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justU64, def: 0, at: VTOFFSET.justU64.p) }
  public static func add(maybeU64: UInt64?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeU64, at: VTOFFSET.maybeU64.p) }
  public static func add(defaultU64: UInt64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultU64, def: 42, at: VTOFFSET.defaultU64.p) }
  public static func add(justF32: Float32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justF32, def: 0.0, at: VTOFFSET.justF32.p) }
  public static func add(maybeF32: Float32?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeF32, at: VTOFFSET.maybeF32.p) }
  public static func add(defaultF32: Float32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultF32, def: 42.0, at: VTOFFSET.defaultF32.p) }
  public static func add(justF64: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justF64, def: 0.0, at: VTOFFSET.justF64.p) }
  public static func add(maybeF64: Double?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeF64, at: VTOFFSET.maybeF64.p) }
  public static func add(defaultF64: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultF64, def: 42.0, at: VTOFFSET.defaultF64.p) }
  public static func add(justBool: Bool, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justBool, def: false,
   at: VTOFFSET.justBool.p) }
  public static func add(maybeBool: Bool?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeBool, at: VTOFFSET.maybeBool.p) }
  public static func add(defaultBool: Bool, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultBool, def: true,
   at: VTOFFSET.defaultBool.p) }
  public static func add(justEnum: optional_scalars_OptionalByte, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justEnum.rawValue, def: 0, at: VTOFFSET.justEnum.p) }
  public static func add(maybeEnum: optional_scalars_OptionalByte?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeEnum?.rawValue, at: VTOFFSET.maybeEnum.p) }
  public static func add(defaultEnum: optional_scalars_OptionalByte, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultEnum.rawValue, def: 1, at: VTOFFSET.defaultEnum.p) }
  public static func endScalarStuff(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
  public static func createScalarStuff(
    _ fbb: inout FlatBufferBuilder,
    justI8: Int8 = 0,
    maybeI8: Int8? = nil,
    defaultI8: Int8 = 42,
    justU8: UInt8 = 0,
    maybeU8: UInt8? = nil,
    defaultU8: UInt8 = 42,
    justI16: Int16 = 0,
    maybeI16: Int16? = nil,
    defaultI16: Int16 = 42,
    justU16: UInt16 = 0,
    maybeU16: UInt16? = nil,
    defaultU16: UInt16 = 42,
    justI32: Int32 = 0,
    maybeI32: Int32? = nil,
    defaultI32: Int32 = 42,
    justU32: UInt32 = 0,
    maybeU32: UInt32? = nil,
    defaultU32: UInt32 = 42,
    justI64: Int64 = 0,
    maybeI64: Int64? = nil,
    defaultI64: Int64 = 42,
    justU64: UInt64 = 0,
    maybeU64: UInt64? = nil,
    defaultU64: UInt64 = 42,
    justF32: Float32 = 0.0,
    maybeF32: Float32? = nil,
    defaultF32: Float32 = 42.0,
    justF64: Double = 0.0,
    maybeF64: Double? = nil,
    defaultF64: Double = 42.0,
    justBool: Bool = false,
    maybeBool: Bool? = nil,
    defaultBool: Bool = true,
    justEnum: optional_scalars_OptionalByte = .none_,
    maybeEnum: optional_scalars_OptionalByte? = nil,
    defaultEnum: optional_scalars_OptionalByte = .one
  ) -> Offset {
    let __start = optional_scalars_ScalarStuff.startScalarStuff(&fbb)
    optional_scalars_ScalarStuff.add(justI8: justI8, &fbb)
    optional_scalars_ScalarStuff.add(maybeI8: maybeI8, &fbb)
    optional_scalars_ScalarStuff.add(defaultI8: defaultI8, &fbb)
    optional_scalars_ScalarStuff.add(justU8: justU8, &fbb)
    optional_scalars_ScalarStuff.add(maybeU8: maybeU8, &fbb)
    optional_scalars_ScalarStuff.add(defaultU8: defaultU8, &fbb)
    optional_scalars_ScalarStuff.add(justI16: justI16, &fbb)
    optional_scalars_ScalarStuff.add(maybeI16: maybeI16, &fbb)
    optional_scalars_ScalarStuff.add(defaultI16: defaultI16, &fbb)
    optional_scalars_ScalarStuff.add(justU16: justU16, &fbb)
    optional_scalars_ScalarStuff.add(maybeU16: maybeU16, &fbb)
    optional_scalars_ScalarStuff.add(defaultU16: defaultU16, &fbb)
    optional_scalars_ScalarStuff.add(justI32: justI32, &fbb)
    optional_scalars_ScalarStuff.add(maybeI32: maybeI32, &fbb)
    optional_scalars_ScalarStuff.add(defaultI32: defaultI32, &fbb)
    optional_scalars_ScalarStuff.add(justU32: justU32, &fbb)
    optional_scalars_ScalarStuff.add(maybeU32: maybeU32, &fbb)
    optional_scalars_ScalarStuff.add(defaultU32: defaultU32, &fbb)
    optional_scalars_ScalarStuff.add(justI64: justI64, &fbb)
    optional_scalars_ScalarStuff.add(maybeI64: maybeI64, &fbb)
    optional_scalars_ScalarStuff.add(defaultI64: defaultI64, &fbb)
    optional_scalars_ScalarStuff.add(justU64: justU64, &fbb)
    optional_scalars_ScalarStuff.add(maybeU64: maybeU64, &fbb)
    optional_scalars_ScalarStuff.add(defaultU64: defaultU64, &fbb)
    optional_scalars_ScalarStuff.add(justF32: justF32, &fbb)
    optional_scalars_ScalarStuff.add(maybeF32: maybeF32, &fbb)
    optional_scalars_ScalarStuff.add(defaultF32: defaultF32, &fbb)
    optional_scalars_ScalarStuff.add(justF64: justF64, &fbb)
    optional_scalars_ScalarStuff.add(maybeF64: maybeF64, &fbb)
    optional_scalars_ScalarStuff.add(defaultF64: defaultF64, &fbb)
    optional_scalars_ScalarStuff.add(justBool: justBool, &fbb)
    optional_scalars_ScalarStuff.add(maybeBool: maybeBool, &fbb)
    optional_scalars_ScalarStuff.add(defaultBool: defaultBool, &fbb)
    optional_scalars_ScalarStuff.add(justEnum: justEnum, &fbb)
    optional_scalars_ScalarStuff.add(maybeEnum: maybeEnum, &fbb)
    optional_scalars_ScalarStuff.add(defaultEnum: defaultEnum, &fbb)
    return optional_scalars_ScalarStuff.endScalarStuff(&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.justI8.p, fieldName: "justI8", required: false, type: Int8.self)
    try _v.visit(field: VTOFFSET.maybeI8.p, fieldName: "maybeI8", required: false, type: Int8.self)
    try _v.visit(field: VTOFFSET.defaultI8.p, fieldName: "defaultI8", required: false, type: Int8.self)
    try _v.visit(field: VTOFFSET.justU8.p, fieldName: "justU8", required: false, type: UInt8.self)
    try _v.visit(field: VTOFFSET.maybeU8.p, fieldName: "maybeU8", required: false, type: UInt8.self)
    try _v.visit(field: VTOFFSET.defaultU8.p, fieldName: "defaultU8", required: false, type: UInt8.self)
    try _v.visit(field: VTOFFSET.justI16.p, fieldName: "justI16", required: false, type: Int16.self)
    try _v.visit(field: VTOFFSET.maybeI16.p, fieldName: "maybeI16", required: false, type: Int16.self)
    try _v.visit(field: VTOFFSET.defaultI16.p, fieldName: "defaultI16", required: false, type: Int16.self)
    try _v.visit(field: VTOFFSET.justU16.p, fieldName: "justU16", required: false, type: UInt16.self)
    try _v.visit(field: VTOFFSET.maybeU16.p, fieldName: "maybeU16", required: false, type: UInt16.self)
    try _v.visit(field: VTOFFSET.defaultU16.p, fieldName: "defaultU16", required: false, type: UInt16.self)
    try _v.visit(field: VTOFFSET.justI32.p, fieldName: "justI32", required: false, type: Int32.self)
    try _v.visit(field: VTOFFSET.maybeI32.p, fieldName: "maybeI32", required: false, type: Int32.self)
    try _v.visit(field: VTOFFSET.defaultI32.p, fieldName: "defaultI32", required: false, type: Int32.self)
    try _v.visit(field: VTOFFSET.justU32.p, fieldName: "justU32", required: false, type: UInt32.self)
    try _v.visit(field: VTOFFSET.maybeU32.p, fieldName: "maybeU32", required: false, type: UInt32.self)
    try _v.visit(field: VTOFFSET.defaultU32.p, fieldName: "defaultU32", required: false, type: UInt32.self)
    try _v.visit(field: VTOFFSET.justI64.p, fieldName: "justI64", required: false, type: Int64.self)
    try _v.visit(field: VTOFFSET.maybeI64.p, fieldName: "maybeI64", required: false, type: Int64.self)
    try _v.visit(field: VTOFFSET.defaultI64.p, fieldName: "defaultI64", required: false, type: Int64.self)
    try _v.visit(field: VTOFFSET.justU64.p, fieldName: "justU64", required: false, type: UInt64.self)
    try _v.visit(field: VTOFFSET.maybeU64.p, fieldName: "maybeU64", required: false, type: UInt64.self)
    try _v.visit(field: VTOFFSET.defaultU64.p, fieldName: "defaultU64", required: false, type: UInt64.self)
    try _v.visit(field: VTOFFSET.justF32.p, fieldName: "justF32", required: false, type: Float32.self)
    try _v.visit(field: VTOFFSET.maybeF32.p, fieldName: "maybeF32", required: false, type: Float32.self)
    try _v.visit(field: VTOFFSET.defaultF32.p, fieldName: "defaultF32", required: false, type: Float32.self)
    try _v.visit(field: VTOFFSET.justF64.p, fieldName: "justF64", required: false, type: Double.self)
    try _v.visit(field: VTOFFSET.maybeF64.p, fieldName: "maybeF64", required: false, type: Double.self)
    try _v.visit(field: VTOFFSET.defaultF64.p, fieldName: "defaultF64", required: false, type: Double.self)
    try _v.visit(field: VTOFFSET.justBool.p, fieldName: "justBool", required: false, type: Bool.self)
    try _v.visit(field: VTOFFSET.maybeBool.p, fieldName: "maybeBool", required: false, type: Bool.self)
    try _v.visit(field: VTOFFSET.defaultBool.p, fieldName: "defaultBool", required: false, type: Bool.self)
    try _v.visit(field: VTOFFSET.justEnum.p, fieldName: "justEnum", required: false, type: optional_scalars_OptionalByte.self)
    try _v.visit(field: VTOFFSET.maybeEnum.p, fieldName: "maybeEnum", required: false, type: optional_scalars_OptionalByte.self)
    try _v.visit(field: VTOFFSET.defaultEnum.p, fieldName: "defaultEnum", required: false, type: optional_scalars_OptionalByte.self)
    _v.finish()
  }
}

extension optional_scalars_ScalarStuff: Encodable {

  enum CodingKeys: String, CodingKey {
    case justI8 = "just_i8"
    case maybeI8 = "maybe_i8"
    case defaultI8 = "default_i8"
    case justU8 = "just_u8"
    case maybeU8 = "maybe_u8"
    case defaultU8 = "default_u8"
    case justI16 = "just_i16"
    case maybeI16 = "maybe_i16"
    case defaultI16 = "default_i16"
    case justU16 = "just_u16"
    case maybeU16 = "maybe_u16"
    case defaultU16 = "default_u16"
    case justI32 = "just_i32"
    case maybeI32 = "maybe_i32"
    case defaultI32 = "default_i32"
    case justU32 = "just_u32"
    case maybeU32 = "maybe_u32"
    case defaultU32 = "default_u32"
    case justI64 = "just_i64"
    case maybeI64 = "maybe_i64"
    case defaultI64 = "default_i64"
    case justU64 = "just_u64"
    case maybeU64 = "maybe_u64"
    case defaultU64 = "default_u64"
    case justF32 = "just_f32"
    case maybeF32 = "maybe_f32"
    case defaultF32 = "default_f32"
    case justF64 = "just_f64"
    case maybeF64 = "maybe_f64"
    case defaultF64 = "default_f64"
    case justBool = "just_bool"
    case maybeBool = "maybe_bool"
    case defaultBool = "default_bool"
    case justEnum = "just_enum"
    case maybeEnum = "maybe_enum"
    case defaultEnum = "default_enum"
  }
  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if justI8 != 0 {
      try container.encodeIfPresent(justI8, forKey: .justI8)
    }
    try container.encodeIfPresent(maybeI8, forKey: .maybeI8)
    if defaultI8 != 42 {
      try container.encodeIfPresent(defaultI8, forKey: .defaultI8)
    }
    if justU8 != 0 {
      try container.encodeIfPresent(justU8, forKey: .justU8)
    }
    try container.encodeIfPresent(maybeU8, forKey: .maybeU8)
    if defaultU8 != 42 {
      try container.encodeIfPresent(defaultU8, forKey: .defaultU8)
    }
    if justI16 != 0 {
      try container.encodeIfPresent(justI16, forKey: .justI16)
    }
    try container.encodeIfPresent(maybeI16, forKey: .maybeI16)
    if defaultI16 != 42 {
      try container.encodeIfPresent(defaultI16, forKey: .defaultI16)
    }
    if justU16 != 0 {
      try container.encodeIfPresent(justU16, forKey: .justU16)
    }
    try container.encodeIfPresent(maybeU16, forKey: .maybeU16)
    if defaultU16 != 42 {
      try container.encodeIfPresent(defaultU16, forKey: .defaultU16)
    }
    if justI32 != 0 {
      try container.encodeIfPresent(justI32, forKey: .justI32)
    }
    try container.encodeIfPresent(maybeI32, forKey: .maybeI32)
    if defaultI32 != 42 {
      try container.encodeIfPresent(defaultI32, forKey: .defaultI32)
    }
    if justU32 != 0 {
      try container.encodeIfPresent(justU32, forKey: .justU32)
    }
    try container.encodeIfPresent(maybeU32, forKey: .maybeU32)
    if defaultU32 != 42 {
      try container.encodeIfPresent(defaultU32, forKey: .defaultU32)
    }
    if justI64 != 0 {
      try container.encodeIfPresent(justI64, forKey: .justI64)
    }
    try container.encodeIfPresent(maybeI64, forKey: .maybeI64)
    if defaultI64 != 42 {
      try container.encodeIfPresent(defaultI64, forKey: .defaultI64)
    }
    if justU64 != 0 {
      try container.encodeIfPresent(justU64, forKey: .justU64)
    }
    try container.encodeIfPresent(maybeU64, forKey: .maybeU64)
    if defaultU64 != 42 {
      try container.encodeIfPresent(defaultU64, forKey: .defaultU64)
    }
    if justF32 != 0.0 {
      try container.encodeIfPresent(justF32, forKey: .justF32)
    }
    try container.encodeIfPresent(maybeF32, forKey: .maybeF32)
    if defaultF32 != 42.0 {
      try container.encodeIfPresent(defaultF32, forKey: .defaultF32)
    }
    if justF64 != 0.0 {
      try container.encodeIfPresent(justF64, forKey: .justF64)
    }
    try container.encodeIfPresent(maybeF64, forKey: .maybeF64)
    if defaultF64 != 42.0 {
      try container.encodeIfPresent(defaultF64, forKey: .defaultF64)
    }
    if justBool != false {
      try container.encodeIfPresent(justBool, forKey: .justBool)
    }
    try container.encodeIfPresent(maybeBool, forKey: .maybeBool)
    if defaultBool != true {
      try container.encodeIfPresent(defaultBool, forKey: .defaultBool)
    }
    if justEnum != .none_ {
      try container.encodeIfPresent(justEnum, forKey: .justEnum)
    }
    try container.encodeIfPresent(maybeEnum, forKey: .maybeEnum)
    if defaultEnum != .one {
      try container.encodeIfPresent(defaultEnum, forKey: .defaultEnum)
    }
  }
}


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

import FlatBuffers

public enum ABC: Int32, Enum, Verifiable {
  public typealias T = Int32
  public static var byteSize: Int { return MemoryLayout<Int32>.size }
  public var value: Int32 { return self.rawValue }
  case a = 0
  case b = 1
  case c = 2

  public static var max: ABC { return .c }
  public static var min: ABC { return .a }
}

extension ABC: Encodable {
  public func encode(to encoder: Encoder) throws {
    var container = encoder.singleValueContainer()
    switch self {
    case .a: try container.encode("A")
    case .b: try container.encode("B")
    case .c: try container.encode("C")
    }
  }
}

public struct MoreDefaults: FlatBufferObject, Verifiable, ObjectAPIPacker {

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

  public static func getRootAsMoreDefaults(bb: ByteBuffer) -> MoreDefaults { return MoreDefaults(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }

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

  private enum VTOFFSET: VOffset {
    case ints = 4
    case floats = 6
    case emptyString = 8
    case someString = 10
    case abcs = 12
    case bools = 14
    var v: Int32 { Int32(self.rawValue) }
    var p: VOffset { self.rawValue }
  }

  public var hasInts: Bool { let o = _accessor.offset(VTOFFSET.ints.v); return o == 0 ? false : true }
  public var intsCount: Int32 { let o = _accessor.offset(VTOFFSET.ints.v); return o == 0 ? 0 : _accessor.vector(count: o) }
  public func ints(at index: Int32) -> Int32 { let o = _accessor.offset(VTOFFSET.ints.v); return o == 0 ? 0 : _accessor.directRead(of: Int32.self, offset: _accessor.vector(at: o) + index * 4) }
  public var ints: [Int32] { return _accessor.getVector(at: VTOFFSET.ints.v) ?? [] }
  public var hasFloats: Bool { let o = _accessor.offset(VTOFFSET.floats.v); return o == 0 ? false : true }
  public var floatsCount: Int32 { let o = _accessor.offset(VTOFFSET.floats.v); return o == 0 ? 0 : _accessor.vector(count: o) }
  public func floats(at index: Int32) -> Float32 { let o = _accessor.offset(VTOFFSET.floats.v); return o == 0 ? 0 : _accessor.directRead(of: Float32.self, offset: _accessor.vector(at: o) + index * 4) }
  public var floats: [Float32] { return _accessor.getVector(at: VTOFFSET.floats.v) ?? [] }
  public var emptyString: String? { let o = _accessor.offset(VTOFFSET.emptyString.v); return o == 0 ? "" : _accessor.string(at: o) }
  public var emptyStringSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.emptyString.v) }
  public var someString: String? { let o = _accessor.offset(VTOFFSET.someString.v); return o == 0 ? "some" : _accessor.string(at: o) }
  public var someStringSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.someString.v) }
  public var hasAbcs: Bool { let o = _accessor.offset(VTOFFSET.abcs.v); return o == 0 ? false : true }
  public var abcsCount: Int32 { let o = _accessor.offset(VTOFFSET.abcs.v); return o == 0 ? 0 : _accessor.vector(count: o) }
  public func abcs(at index: Int32) -> ABC? { let o = _accessor.offset(VTOFFSET.abcs.v); return o == 0 ? ABC.a : ABC(rawValue: _accessor.directRead(of: Int32.self, offset: _accessor.vector(at: o) + index * 4)) }
  public var hasBools: Bool { let o = _accessor.offset(VTOFFSET.bools.v); return o == 0 ? false : true }
  public var boolsCount: Int32 { let o = _accessor.offset(VTOFFSET.bools.v); return o == 0 ? 0 : _accessor.vector(count: o) }
  public func bools(at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.bools.v); return o == 0 ? true : _accessor.directRead(of: Bool.self, offset: _accessor.vector(at: o) + index * 1) }
  public var bools: [Bool] { return _accessor.getVector(at: VTOFFSET.bools.v) ?? [] }
  public static func startMoreDefaults(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 6) }
  public static func addVectorOf(ints: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: ints, at: VTOFFSET.ints.p) }
  public static func addVectorOf(floats: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: floats, at: VTOFFSET.floats.p) }
  public static func add(emptyString: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: emptyString, at: VTOFFSET.emptyString.p) }
  public static func add(someString: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: someString, at: VTOFFSET.someString.p) }
  public static func addVectorOf(abcs: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: abcs, at: VTOFFSET.abcs.p) }
  public static func addVectorOf(bools: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: bools, at: VTOFFSET.bools.p) }
  public static func endMoreDefaults(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
  public static func createMoreDefaults(
    _ fbb: inout FlatBufferBuilder,
    intsVectorOffset ints: Offset = Offset(),
    floatsVectorOffset floats: Offset = Offset(),
    emptyStringOffset emptyString: Offset = Offset(),
    someStringOffset someString: Offset = Offset(),
    abcsVectorOffset abcs: Offset = Offset(),
    boolsVectorOffset bools: Offset = Offset()
  ) -> Offset {
    let __start = MoreDefaults.startMoreDefaults(&fbb)
    MoreDefaults.addVectorOf(ints: ints, &fbb)
    MoreDefaults.addVectorOf(floats: floats, &fbb)
    MoreDefaults.add(emptyString: emptyString, &fbb)
    MoreDefaults.add(someString: someString, &fbb)
    MoreDefaults.addVectorOf(abcs: abcs, &fbb)
    MoreDefaults.addVectorOf(bools: bools, &fbb)
    return MoreDefaults.endMoreDefaults(&fbb, start: __start)
  }

  public mutating func unpack() -> MoreDefaultsT {
    return MoreDefaultsT(&self)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MoreDefaultsT?) -> Offset {
    guard var obj = obj else { return Offset() }
    return pack(&builder, obj: &obj)
  }

  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MoreDefaultsT) -> Offset {
    let __ints = builder.createVector(obj.ints)
    let __floats = builder.createVector(obj.floats)
    let __emptyString: Offset
    if let s = obj.emptyString {
      __emptyString = builder.create(string: s)
    } else {
      __emptyString = Offset()
    }

    let __someString: Offset
    if let s = obj.someString {
      __someString = builder.create(string: s)
    } else {
      __someString = Offset()
    }

    let __abcs = builder.createVector(obj.abcs)
    let __bools = builder.createVector(obj.bools)
    let __root = MoreDefaults.startMoreDefaults(&builder)
    MoreDefaults.addVectorOf(ints: __ints, &builder)
    MoreDefaults.addVectorOf(floats: __floats, &builder)
    MoreDefaults.add(emptyString: __emptyString, &builder)
    MoreDefaults.add(someString: __someString, &builder)
    MoreDefaults.addVectorOf(abcs: __abcs, &builder)
    MoreDefaults.addVectorOf(bools: __bools, &builder)
    return MoreDefaults.endMoreDefaults(&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.ints.p, fieldName: "ints", required: false, type: ForwardOffset<Vector<Int32, Int32>>.self)
    try _v.visit(field: VTOFFSET.floats.p, fieldName: "floats", required: false, type: ForwardOffset<Vector<Float32, Float32>>.self)
    try _v.visit(field: VTOFFSET.emptyString.p, fieldName: "emptyString", required: false, type: ForwardOffset<String>.self)
    try _v.visit(field: VTOFFSET.someString.p, fieldName: "someString", required: false, type: ForwardOffset<String>.self)
    try _v.visit(field: VTOFFSET.abcs.p, fieldName: "abcs", required: false, type: ForwardOffset<Vector<ABC, ABC>>.self)
    try _v.visit(field: VTOFFSET.bools.p, fieldName: "bools", required: false, type: ForwardOffset<Vector<Bool, Bool>>.self)
    _v.finish()
  }
}

extension MoreDefaults: Encodable {

  enum CodingKeys: String, CodingKey {
    case ints = "ints"
    case floats = "floats"
    case emptyString = "empty_string"
    case someString = "some_string"
    case abcs = "abcs"
    case bools = "bools"
  }
  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if intsCount > 0 {
      try container.encodeIfPresent(ints, forKey: .ints)
    }
    if floatsCount > 0 {
      try container.encodeIfPresent(floats, forKey: .floats)
    }
    try container.encodeIfPresent(emptyString, forKey: .emptyString)
    try container.encodeIfPresent(someString, forKey: .someString)
    if abcsCount > 0 {
      var contentEncoder = container.nestedUnkeyedContainer(forKey: .abcs)
      for index in 0..<abcsCount {
        guard let type = abcs(at: index) else { continue }
        try contentEncoder.encode(type)
      }
    }
    if boolsCount > 0 {
      try container.encodeIfPresent(bools, forKey: .bools)
    }
  }
}

public class MoreDefaultsT: NativeObject {

  public var ints: [Int32]
  public var floats: [Float32]
  public var emptyString: String?
  public var someString: String?
  public var abcs: [ABC]
  public var bools: [Bool]

  public init(_ _t: inout MoreDefaults) {
    ints = []
    for index in 0..<_t.intsCount {
        ints.append(_t.ints(at: index))
    }
    floats = []
    for index in 0..<_t.floatsCount {
        floats.append(_t.floats(at: index))
    }
    emptyString = _t.emptyString
    someString = _t.someString
    abcs = []
    for index in 0..<_t.abcsCount {
        abcs.append(_t.abcs(at: index)!)
    }
    bools = []
    for index in 0..<_t.boolsCount {
        bools.append(_t.bools(at: index))
    }
  }

  public init() {
    ints = []
    floats = []
    emptyString = ""
    someString = "some"
    abcs = []
    bools = []
  }

  public func serialize() -> ByteBuffer { return serialize(type: MoreDefaults.self) }

}


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)
    let msg = Swift_Tests_Vectors.getRootAsVectors(bb: ByteBuffer(bytes: builder.sizedByteArray))
    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))
  }
}


// automatically generated by the FlatBuffers compiler, do not modify
// swiftlint:disable all
// swiftformat:disable all
internal struct Message: FlatBufferObject, Verifiable, ObjectAPIPacker {
  static func validateVersion() { FlatBuffersVersion_2_0_0() }
  internal var __buffer: ByteBuffer! { return _accessor.bb }
  private var _accessor: Table
  internal static func getRootAsMessage(bb: ByteBuffer) -> Message { return Message(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
  private init(_ t: Table) { _accessor = t }
  internal init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
  private enum VTOFFSET: VOffset {
    case internalMessage = 4
    var v: Int32 { Int32(self.rawValue) }
    var p: VOffset { self.rawValue }
  }
  internal var internalMessage: String? { let o = _accessor.offset(VTOFFSET.internalMessage.v); return o == 0 ? nil : _accessor.string(at: o) }
  internal var internalMessageSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.internalMessage.v) }
  internal static func startMessage(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
  internal static func add(internalMessage: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: internalMessage, at: VTOFFSET.internalMessage.p) }
  internal static func endMessage(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
  internal static func createMessage(
    _ fbb: inout FlatBufferBuilder,
    internalMessageOffset internalMessage: Offset = Offset()
  ) -> Offset {
    let __start = Message.startMessage(&fbb)
    Message.add(internalMessage: internalMessage, &fbb)
    return Message.endMessage(&fbb, start: __start)
  }

  internal mutating func unpack() -> MessageT {
    return MessageT(&self)
  }
  internal static func pack(_ builder: inout FlatBufferBuilder, obj: inout MessageT?) -> Offset {
    guard var obj = obj else { return Offset() }
    return pack(&builder, obj: &obj)
  }
  internal static func pack(_ builder: inout FlatBufferBuilder, obj: inout MessageT) -> Offset {
    let __internalMessage: Offset
    if let s = obj.internalMessage {
      __internalMessage = builder.create(string: s)
    } else {
      __internalMessage = Offset()
    }
    let __root = Message.startMessage(&builder)
    Message.add(internalMessage: __internalMessage, &builder)
    return Message.endMessage(&builder, start: __root)
  }
  internal 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.internalMessage.p, fieldName: "internalMessage", required: false, type: ForwardOffset<String>.self)
    _v.finish()
  }
}
extension Message: Encodable {
  enum CodingKeys: String, CodingKey {
    case internalMessage = "internal_message"
  }
  internal func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    try container.encodeIfPresent(internalMessage, forKey: .internalMessage)
  }
}
internal class MessageT: NativeObject {
  internal var internalMessage: String?
  internal init(_ _t: inout Message) {
    internalMessage = _t.internalMessage
  }
  internal init() {
  }
  internal func serialize() -> ByteBuffer { return serialize(type: Message.self) }
}


// automatically generated by the FlatBuffers compiler, do not modify
// swiftlint:disable all
// swiftformat:disable all
public struct BytesCount: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
  static func validateVersion() { FlatBuffersVersion_2_0_0() }
  private var _x: Int64
  public init(_ bb: ByteBuffer, o: Int32) {
    let _accessor = Struct(bb: bb, position: o)
    _x = _accessor.readBuffer(of: Int64.self, at: 0)
  }
  public init(x: Int64) {
    _x = x
  }
  public init() {
    _x = 0
  }
  public init(_ _t: inout BytesCount_Mutable) {
    _x = _t.x
  }
  public var x: Int64 { _x }
  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: BytesCount.self)
  }
}
extension BytesCount: Encodable {
  enum CodingKeys: String, CodingKey {
    case x = "x"
  }
  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if x != 0 {
      try container.encodeIfPresent(x, forKey: .x)
    }
  }
}
public struct BytesCount_Mutable: FlatBufferObject {
  static func validateVersion() { FlatBuffersVersion_2_0_0() }
  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 x: Int64 { return _accessor.readBuffer(of: Int64.self, at: 0) }

  public mutating func unpack() -> BytesCount {
    return BytesCount(&self)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout BytesCount?) -> Offset {
    guard var obj = obj else { return Offset() }
    return pack(&builder, obj: &obj)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout BytesCount) -> Offset {
    return builder.create(struct: obj)
  }
}
public struct InternalMessage: FlatBufferObject, Verifiable, ObjectAPIPacker {
  static func validateVersion() { FlatBuffersVersion_2_0_0() }
  public var __buffer: ByteBuffer! { return _accessor.bb }
  private var _accessor: Table
  public static func getRootAsInternalMessage(bb: ByteBuffer) -> InternalMessage { return InternalMessage(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
  private init(_ t: Table) { _accessor = t }
  public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
  private enum VTOFFSET: VOffset {
    case str = 4
    var v: Int32 { Int32(self.rawValue) }
    var p: VOffset { self.rawValue }
  }
  public var str: String? { let o = _accessor.offset(VTOFFSET.str.v); return o == 0 ? nil : _accessor.string(at: o) }
  public var strSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.str.v) }
  public static func startInternalMessage(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
  public static func add(str: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: str, at: VTOFFSET.str.p) }
  public static func endInternalMessage(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
  public static func createInternalMessage(
    _ fbb: inout FlatBufferBuilder,
    strOffset str: Offset = Offset()
  ) -> Offset {
    let __start = InternalMessage.startInternalMessage(&fbb)
    InternalMessage.add(str: str, &fbb)
    return InternalMessage.endInternalMessage(&fbb, start: __start)
  }

  public mutating func unpack() -> InternalMessageT {
    return InternalMessageT(&self)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout InternalMessageT?) -> Offset {
    guard var obj = obj else { return Offset() }
    return pack(&builder, obj: &obj)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout InternalMessageT) -> Offset {
    let __str: Offset
    if let s = obj.str {
      __str = builder.create(string: s)
    } else {
      __str = Offset()
    }
    let __root = InternalMessage.startInternalMessage(&builder)
    InternalMessage.add(str: __str, &builder)
    return InternalMessage.endInternalMessage(&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.str.p, fieldName: "str", required: false, type: ForwardOffset<String>.self)
    _v.finish()
  }
}
extension InternalMessage: Encodable {
  enum CodingKeys: String, CodingKey {
    case str = "str"
  }
  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    try container.encodeIfPresent(str, forKey: .str)
  }
}
public class InternalMessageT: NativeObject {
  public var str: String?
  public init(_ _t: inout InternalMessage) {
    str = _t.str
  }
  public init() {
  }
  public func serialize() -> ByteBuffer { return serialize(type: InternalMessage.self) }
}
public struct Message: FlatBufferObject, Verifiable, ObjectAPIPacker {
  static func validateVersion() { FlatBuffersVersion_2_0_0() }
  public var __buffer: ByteBuffer! { return _accessor.bb }
  private var _accessor: Table
  public static func getRootAsMessage(bb: ByteBuffer) -> Message { return Message(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
  private init(_ t: Table) { _accessor = t }
  public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
  private enum VTOFFSET: VOffset {
    case id = 4
    case position = 6
    case pointer = 8
    var v: Int32 { Int32(self.rawValue) }
    var p: VOffset { self.rawValue }
  }
  public var id: Int64 { let o = _accessor.offset(VTOFFSET.id.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int64.self, at: o) }
  public var position: BytesCount! { let o = _accessor.offset(VTOFFSET.position.v); return _accessor.readBuffer(of: BytesCount.self, at: o) }
  public var mutablePosition: BytesCount_Mutable! { let o = _accessor.offset(VTOFFSET.position.v); return BytesCount_Mutable(_accessor.bb, o: o + _accessor.postion) }
  public var pointer: InternalMessage! { let o = _accessor.offset(VTOFFSET.pointer.v); return InternalMessage(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) }
  public static func startMessage(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 3) }
  public static func add(id: Int64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: id, def: 0, at: VTOFFSET.id.p) }
  public static func add(position: BytesCount?, _ fbb: inout FlatBufferBuilder) { guard let position = position else { return }; fbb.create(struct: position, position: VTOFFSET.position.p) }
  public static func add(pointer: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: pointer, at: VTOFFSET.pointer.p) }
  public static func endMessage(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); fbb.require(table: end, fields: [6, 8]); return end }
  public static func createMessage(
    _ fbb: inout FlatBufferBuilder,
    id: Int64 = 0,
    position: BytesCount,
    pointerOffset pointer: Offset
  ) -> Offset {
    let __start = Message.startMessage(&fbb)
    Message.add(id: id, &fbb)
    Message.add(position: position, &fbb)
    Message.add(pointer: pointer, &fbb)
    return Message.endMessage(&fbb, start: __start)
  }

  public mutating func unpack() -> MessageT {
    return MessageT(&self)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MessageT?) -> Offset {
    guard var obj = obj else { return Offset() }
    return pack(&builder, obj: &obj)
  }
  public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MessageT) -> Offset {
    let __pointer = InternalMessage.pack(&builder, obj: &obj.pointer)
    let __root = Message.startMessage(&builder)
    Message.add(id: obj.id, &builder)
    Message.add(position: obj.position, &builder)
    Message.add(pointer: __pointer, &builder)
    return Message.endMessage(&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.id.p, fieldName: "id", required: false, type: Int64.self)
    try _v.visit(field: VTOFFSET.position.p, fieldName: "position", required: true, type: BytesCount.self)
    try _v.visit(field: VTOFFSET.pointer.p, fieldName: "pointer", required: true, type: ForwardOffset<InternalMessage>.self)
    _v.finish()
  }
}
extension Message: Encodable {
  enum CodingKeys: String, CodingKey {
    case id = "id"
    case position = "position"
    case pointer = "pointer"
  }
  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if id != 0 {
      try container.encodeIfPresent(id, forKey: .id)
    }
    try container.encodeIfPresent(position, forKey: .position)
    try container.encodeIfPresent(pointer, forKey: .pointer)
  }
}
public class MessageT: NativeObject {
  public var id: Int64
  public var position: BytesCount
  public var pointer: InternalMessageT
  public init(_ _t: inout Message) {
    id = _t.id
    position = _t.position
    var __pointer = _t.pointer
    pointer = __pointer!.unpack()
  }
  public init() {
    id = 0
    position = BytesCount()
    pointer = InternalMessageT()
  }
  public func serialize() -> ByteBuffer { return serialize(type: Message.self) }
}


Package

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


Wasm

public struct Wasm {}