///
/// MultipeerPeer.swift
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

import NitroModules

/**
 * Represents an instance of `MultipeerPeer`, backed by a C++ struct.
 */
public typealias MultipeerPeer = margelo.nitro.munimbluetooth.MultipeerPeer

public extension MultipeerPeer {
  private typealias bridge = margelo.nitro.munimbluetooth.bridge.swift

  /**
   * Create a new instance of `MultipeerPeer`.
   */
  init(id: String, displayName: String, state: MultipeerPeerState, discoveryInfo: [MultipeerDiscoveryInfoEntry]?) {
    self.init(std.string(id), std.string(displayName), state, { () -> bridge.std__optional_std__vector_MultipeerDiscoveryInfoEntry__ in
      if let __unwrappedValue = discoveryInfo {
        return bridge.create_std__optional_std__vector_MultipeerDiscoveryInfoEntry__({ () -> bridge.std__vector_MultipeerDiscoveryInfoEntry_ in
          var __vector = bridge.create_std__vector_MultipeerDiscoveryInfoEntry_(__unwrappedValue.count)
          for __item in __unwrappedValue {
            __vector.push_back(__item)
          }
          return __vector
        }())
      } else {
        return .init()
      }
    }())
  }

  @inline(__always)
  var id: String {
    return String(self.__id)
  }
  
  @inline(__always)
  var displayName: String {
    return String(self.__displayName)
  }
  
  @inline(__always)
  var state: MultipeerPeerState {
    return self.__state
  }
  
  @inline(__always)
  var discoveryInfo: [MultipeerDiscoveryInfoEntry]? {
    return { () -> [MultipeerDiscoveryInfoEntry]? in
      if bridge.has_value_std__optional_std__vector_MultipeerDiscoveryInfoEntry__(self.__discoveryInfo) {
        let __unwrapped = bridge.get_std__optional_std__vector_MultipeerDiscoveryInfoEntry__(self.__discoveryInfo)
        return __unwrapped.map({ __item in __item })
      } else {
        return nil
      }
    }()
  }
}
