///
/// MultipeerSessionOptions.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 `MultipeerSessionOptions`, backed by a C++ struct.
 */
public typealias MultipeerSessionOptions = margelo.nitro.munimbluetooth.MultipeerSessionOptions

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

  /**
   * Create a new instance of `MultipeerSessionOptions`.
   */
  init(serviceType: String, displayName: String?, discoveryInfo: [MultipeerDiscoveryInfoEntry]?, autoInvite: Bool?, autoAcceptInvitations: Bool?, inviteTimeout: Double?, encryptionPreference: MultipeerEncryptionPreference?) {
    self.init(std.string(serviceType), { () -> bridge.std__optional_std__string_ in
      if let __unwrappedValue = displayName {
        return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
      } else {
        return .init()
      }
    }(), { () -> 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()
      }
    }(), { () -> bridge.std__optional_bool_ in
      if let __unwrappedValue = autoInvite {
        return bridge.create_std__optional_bool_(__unwrappedValue)
      } else {
        return .init()
      }
    }(), { () -> bridge.std__optional_bool_ in
      if let __unwrappedValue = autoAcceptInvitations {
        return bridge.create_std__optional_bool_(__unwrappedValue)
      } else {
        return .init()
      }
    }(), { () -> bridge.std__optional_double_ in
      if let __unwrappedValue = inviteTimeout {
        return bridge.create_std__optional_double_(__unwrappedValue)
      } else {
        return .init()
      }
    }(), { () -> bridge.std__optional_MultipeerEncryptionPreference_ in
      if let __unwrappedValue = encryptionPreference {
        return bridge.create_std__optional_MultipeerEncryptionPreference_(__unwrappedValue)
      } else {
        return .init()
      }
    }())
  }

  @inline(__always)
  var serviceType: String {
    return String(self.__serviceType)
  }
  
  @inline(__always)
  var displayName: String? {
    return { () -> String? in
      if bridge.has_value_std__optional_std__string_(self.__displayName) {
        let __unwrapped = bridge.get_std__optional_std__string_(self.__displayName)
        return String(__unwrapped)
      } else {
        return nil
      }
    }()
  }
  
  @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
      }
    }()
  }
  
  @inline(__always)
  var autoInvite: Bool? {
    return { () -> Bool? in
      if bridge.has_value_std__optional_bool_(self.__autoInvite) {
        let __unwrapped = bridge.get_std__optional_bool_(self.__autoInvite)
        return __unwrapped
      } else {
        return nil
      }
    }()
  }
  
  @inline(__always)
  var autoAcceptInvitations: Bool? {
    return { () -> Bool? in
      if bridge.has_value_std__optional_bool_(self.__autoAcceptInvitations) {
        let __unwrapped = bridge.get_std__optional_bool_(self.__autoAcceptInvitations)
        return __unwrapped
      } else {
        return nil
      }
    }()
  }
  
  @inline(__always)
  var inviteTimeout: Double? {
    return { () -> Double? in
      if bridge.has_value_std__optional_double_(self.__inviteTimeout) {
        let __unwrapped = bridge.get_std__optional_double_(self.__inviteTimeout)
        return __unwrapped
      } else {
        return nil
      }
    }()
  }
  
  @inline(__always)
  var encryptionPreference: MultipeerEncryptionPreference? {
    return self.__encryptionPreference.value
  }
}
