///
/// BleNitro-Swift-Cxx-Bridge.cpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

#include "BleNitro-Swift-Cxx-Bridge.hpp"

// Include C++ implementation defined types
#include "BleNitro-Swift-Cxx-Umbrella.hpp"
#include "HybridNativeBleNitroFactorySpecSwift.hpp"
#include "HybridNativeBleNitroSpecSwift.hpp"
#include <NitroModules/NitroDefines.hpp>

namespace margelo::nitro::co::zyke::ble::bridge::swift {

  // pragma MARK: std::function<void(const std::vector<BLEDevice>& /* restoredPeripherals */)>
  Func_void_std__vector_BLEDevice_ create_Func_void_std__vector_BLEDevice_(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = BleNitro::Func_void_std__vector_BLEDevice_::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::vector<BLEDevice>& restoredPeripherals) mutable -> void {
      swiftClosure.call(restoredPeripherals);
    };
  }
  
  // pragma MARK: std::function<void(const std::optional<std::variant<nitro::NullType, BLEDevice>>& /* device */, const std::optional<std::variant<nitro::NullType, std::string>>& /* error */)>
  Func_void_std__optional_std__variant_nitro__NullType__BLEDevice___std__optional_std__variant_nitro__NullType__std__string__ create_Func_void_std__optional_std__variant_nitro__NullType__BLEDevice___std__optional_std__variant_nitro__NullType__std__string__(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = BleNitro::Func_void_std__optional_std__variant_nitro__NullType__BLEDevice___std__optional_std__variant_nitro__NullType__std__string__::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::optional<std::variant<nitro::NullType, BLEDevice>>& device, const std::optional<std::variant<nitro::NullType, std::string>>& error) mutable -> void {
      swiftClosure.call(device, error);
    };
  }
  
  // pragma MARK: std::function<void(bool /* success */, const std::string& /* deviceId */, const std::string& /* error */)>
  Func_void_bool_std__string_std__string create_Func_void_bool_std__string_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = BleNitro::Func_void_bool_std__string_std__string::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](bool success, const std::string& deviceId, const std::string& error) mutable -> void {
      swiftClosure.call(success, deviceId, error);
    };
  }
  
  // pragma MARK: std::function<void(const std::string& /* deviceId */, bool /* interrupted */, const std::string& /* error */)>
  Func_void_std__string_bool_std__string create_Func_void_std__string_bool_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = BleNitro::Func_void_std__string_bool_std__string::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::string& deviceId, bool interrupted, const std::string& error) mutable -> void {
      swiftClosure.call(deviceId, interrupted, error);
    };
  }
  
  // pragma MARK: std::function<void(bool /* success */, const std::string& /* error */)>
  Func_void_bool_std__string create_Func_void_bool_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = BleNitro::Func_void_bool_std__string::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](bool success, const std::string& error) mutable -> void {
      swiftClosure.call(success, error);
    };
  }
  
  // pragma MARK: std::function<void(bool /* success */, double /* rssi */, const std::string& /* error */)>
  Func_void_bool_double_std__string create_Func_void_bool_double_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = BleNitro::Func_void_bool_double_std__string::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](bool success, double rssi, const std::string& error) mutable -> void {
      swiftClosure.call(success, rssi, error);
    };
  }
  
  // pragma MARK: std::function<void(bool /* success */, const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* error */)>
  Func_void_bool_std__shared_ptr_ArrayBuffer__std__string create_Func_void_bool_std__shared_ptr_ArrayBuffer__std__string(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = BleNitro::Func_void_bool_std__shared_ptr_ArrayBuffer__std__string::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](bool success, const std::shared_ptr<ArrayBuffer>& data, const std::string& error) mutable -> void {
      swiftClosure.call(success, ArrayBufferHolder(data), error);
    };
  }
  
  // pragma MARK: std::function<void(const std::string& /* characteristicId */, const std::shared_ptr<ArrayBuffer>& /* data */)>
  Func_void_std__string_std__shared_ptr_ArrayBuffer_ create_Func_void_std__string_std__shared_ptr_ArrayBuffer_(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = BleNitro::Func_void_std__string_std__shared_ptr_ArrayBuffer_::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::string& characteristicId, const std::shared_ptr<ArrayBuffer>& data) mutable -> void {
      swiftClosure.call(characteristicId, ArrayBufferHolder(data));
    };
  }
  
  // pragma MARK: std::function<void(BLEState /* state */)>
  Func_void_BLEState create_Func_void_BLEState(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = BleNitro::Func_void_BLEState::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](BLEState state) mutable -> void {
      swiftClosure.call(static_cast<int>(state));
    };
  }
  
  // pragma MARK: std::function<void()>
  Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = BleNitro::Func_void::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
      swiftClosure.call();
    };
  }
  
  // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
  Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = BleNitro::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
      swiftClosure.call(error);
    };
  }
  
  // pragma MARK: std::shared_ptr<HybridNativeBleNitroSpec>
  std::shared_ptr<HybridNativeBleNitroSpec> create_std__shared_ptr_HybridNativeBleNitroSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
    BleNitro::HybridNativeBleNitroSpec_cxx swiftPart = BleNitro::HybridNativeBleNitroSpec_cxx::fromUnsafe(swiftUnsafePointer);
    return std::make_shared<margelo::nitro::co::zyke::ble::HybridNativeBleNitroSpecSwift>(swiftPart);
  }
  void* NON_NULL get_std__shared_ptr_HybridNativeBleNitroSpec_(std__shared_ptr_HybridNativeBleNitroSpec_ cppType) {
    std::shared_ptr<margelo::nitro::co::zyke::ble::HybridNativeBleNitroSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::co::zyke::ble::HybridNativeBleNitroSpecSwift>(cppType);
    #ifdef NITRO_DEBUG
    if (swiftWrapper == nullptr) [[unlikely]] {
      throw std::runtime_error("Class \"HybridNativeBleNitroSpec\" is not implemented in Swift!");
    }
    #endif
    BleNitro::HybridNativeBleNitroSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
    return swiftPart.toUnsafe();
  }
  
  // pragma MARK: std::shared_ptr<HybridNativeBleNitroFactorySpec>
  std::shared_ptr<HybridNativeBleNitroFactorySpec> create_std__shared_ptr_HybridNativeBleNitroFactorySpec_(void* NON_NULL swiftUnsafePointer) noexcept {
    BleNitro::HybridNativeBleNitroFactorySpec_cxx swiftPart = BleNitro::HybridNativeBleNitroFactorySpec_cxx::fromUnsafe(swiftUnsafePointer);
    return std::make_shared<margelo::nitro::co::zyke::ble::HybridNativeBleNitroFactorySpecSwift>(swiftPart);
  }
  void* NON_NULL get_std__shared_ptr_HybridNativeBleNitroFactorySpec_(std__shared_ptr_HybridNativeBleNitroFactorySpec_ cppType) {
    std::shared_ptr<margelo::nitro::co::zyke::ble::HybridNativeBleNitroFactorySpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::co::zyke::ble::HybridNativeBleNitroFactorySpecSwift>(cppType);
    #ifdef NITRO_DEBUG
    if (swiftWrapper == nullptr) [[unlikely]] {
      throw std::runtime_error("Class \"HybridNativeBleNitroFactorySpec\" is not implemented in Swift!");
    }
    #endif
    BleNitro::HybridNativeBleNitroFactorySpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
    return swiftPart.toUnsafe();
  }

} // namespace margelo::nitro::co::zyke::ble::bridge::swift
