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

#pragma once

#include "HybridNitroResolverSpec.hpp"

// Forward declaration of `HybridNitroResolverSpec_cxx` to properly resolve imports.
namespace RNDns { class HybridNitroResolverSpec_cxx; }



#include <string>
#include <NitroModules/Promise.hpp>

#include "RNDns-Swift-Cxx-Umbrella.hpp"

namespace margelo::nitro::nitro_dns {

  /**
   * The C++ part of HybridNitroResolverSpec_cxx.swift.
   *
   * HybridNitroResolverSpecSwift (C++) accesses HybridNitroResolverSpec_cxx (Swift), and might
   * contain some additional bridging code for C++ <> Swift interop.
   *
   * Since this obviously introduces an overhead, I hope at some point in
   * the future, HybridNitroResolverSpec_cxx can directly inherit from the C++ class HybridNitroResolverSpec
   * to simplify the whole structure and memory management.
   */
  class HybridNitroResolverSpecSwift: public virtual HybridNitroResolverSpec {
  public:
    // Constructor from a Swift instance
    explicit HybridNitroResolverSpecSwift(const RNDns::HybridNitroResolverSpec_cxx& swiftPart):
      HybridObject(HybridNitroResolverSpec::TAG),
      _swiftPart(swiftPart) { }

  public:
    // Get the Swift part
    inline RNDns::HybridNitroResolverSpec_cxx& getSwiftPart() noexcept {
      return _swiftPart;
    }

  public:
    inline size_t getExternalMemorySize() noexcept override {
      return _swiftPart.getMemorySize();
    }
    bool equals(const std::shared_ptr<HybridObject>& other) override {
      if (auto otherCast = std::dynamic_pointer_cast<HybridNitroResolverSpecSwift>(other)) {
        return _swiftPart.equals(otherCast->_swiftPart);
      }
      return false;
    }
    void dispose() noexcept override {
      _swiftPart.dispose();
    }
    std::string toString() override {
      return _swiftPart.toString();
    }

  public:
    // Properties
    

  public:
    // Methods
    inline void cancel() override {
      auto __result = _swiftPart.cancel();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline std::string getServers() override {
      auto __result = _swiftPart.getServers();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void setServers(const std::string& servers) override {
      auto __result = _swiftPart.setServers(servers);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline std::shared_ptr<Promise<std::string>> resolveipv4(const std::string& hostname) override {
      auto __result = _swiftPart.resolveipv4(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveipv6(const std::string& hostname) override {
      auto __result = _swiftPart.resolveipv6(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveMx(const std::string& hostname) override {
      auto __result = _swiftPart.resolveMx(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveTxt(const std::string& hostname) override {
      auto __result = _swiftPart.resolveTxt(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveBase64Txt(const std::string& hostname) override {
      auto __result = _swiftPart.resolveBase64Txt(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveCname(const std::string& hostname) override {
      auto __result = _swiftPart.resolveCname(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveNs(const std::string& hostname) override {
      auto __result = _swiftPart.resolveNs(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveSoa(const std::string& hostname) override {
      auto __result = _swiftPart.resolveSoa(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveSrv(const std::string& hostname) override {
      auto __result = _swiftPart.resolveSrv(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveCaa(const std::string& hostname) override {
      auto __result = _swiftPart.resolveCaa(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveNaptr(const std::string& hostname) override {
      auto __result = _swiftPart.resolveNaptr(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolvePtr(const std::string& hostname) override {
      auto __result = _swiftPart.resolvePtr(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveTlsa(const std::string& hostname) override {
      auto __result = _swiftPart.resolveTlsa(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveAny(const std::string& hostname) override {
      auto __result = _swiftPart.resolveAny(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> reverse(const std::string& ip) override {
      auto __result = _swiftPart.reverse(ip);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void setLocalAddress(const std::string& v4, const std::string& v6) override {
      auto __result = _swiftPart.setLocalAddress(v4, v6);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void clearCache() override {
      auto __result = _swiftPart.clearCache();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }

  private:
    RNDns::HybridNitroResolverSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::nitro_dns
