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

import Foundation
import NitroModules

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

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

  /**
   * Create a new instance of `ScanOptions`.
   */
  init(serviceUUIDs: [String]?, allowDuplicates: Bool?, scanMode: ScanMode?) {
    self.init({ () -> bridge.std__optional_std__vector_std__string__ in
      if let __unwrappedValue = serviceUUIDs {
        return bridge.create_std__optional_std__vector_std__string__({ () -> bridge.std__vector_std__string_ in
          var __vector = bridge.create_std__vector_std__string_(__unwrappedValue.count)
          for __item in __unwrappedValue {
            __vector.push_back(std.string(__item))
          }
          return __vector
        }())
      } else {
        return .init()
      }
    }(), { () -> bridge.std__optional_bool_ in
      if let __unwrappedValue = allowDuplicates {
        return bridge.create_std__optional_bool_(__unwrappedValue)
      } else {
        return .init()
      }
    }(), { () -> bridge.std__optional_ScanMode_ in
      if let __unwrappedValue = scanMode {
        return bridge.create_std__optional_ScanMode_(__unwrappedValue)
      } else {
        return .init()
      }
    }())
  }

  @inline(__always)
  var serviceUUIDs: [String]? {
    return { () -> [String]? in
      if bridge.has_value_std__optional_std__vector_std__string__(self.__serviceUUIDs) {
        let __unwrapped = bridge.get_std__optional_std__vector_std__string__(self.__serviceUUIDs)
        return __unwrapped.map({ __item in String(__item) })
      } else {
        return nil
      }
    }()
  }
  
  @inline(__always)
  var allowDuplicates: Bool? {
    return { () -> Bool? in
      if bridge.has_value_std__optional_bool_(self.__allowDuplicates) {
        let __unwrapped = bridge.get_std__optional_bool_(self.__allowDuplicates)
        return __unwrapped
      } else {
        return nil
      }
    }()
  }
  
  @inline(__always)
  var scanMode: ScanMode? {
    return self.__scanMode.value
  }
}
