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

#pragma once

#include "HybridNetDriverSpec.hpp"

// Forward declaration of `HybridNetDriverSpec_cxx` to properly resolve imports.
namespace RustCNet { class HybridNetDriverSpec_cxx; }

// Forward declaration of `HybridNetSocketDriverSpec` to properly resolve imports.
namespace margelo::nitro::net { class HybridNetSocketDriverSpec; }
// Forward declaration of `HybridNetServerDriverSpec` to properly resolve imports.
namespace margelo::nitro::net { class HybridNetServerDriverSpec; }
// Forward declaration of `HybridHttpParserSpec` to properly resolve imports.
namespace margelo::nitro::net { class HybridHttpParserSpec; }
// Forward declaration of `ArrayBufferHolder` to properly resolve imports.
namespace NitroModules { class ArrayBufferHolder; }
// Forward declaration of `NetConfig` to properly resolve imports.
namespace margelo::nitro::net { struct NetConfig; }

#include <memory>
#include "HybridNetSocketDriverSpec.hpp"
#include <string>
#include <optional>
#include "HybridNetServerDriverSpec.hpp"
#include "HybridHttpParserSpec.hpp"
#include <NitroModules/ArrayBuffer.hpp>
#include <NitroModules/ArrayBufferHolder.hpp>
#include "NetConfig.hpp"

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

namespace margelo::nitro::net {

  /**
   * The C++ part of HybridNetDriverSpec_cxx.swift.
   *
   * HybridNetDriverSpecSwift (C++) accesses HybridNetDriverSpec_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, HybridNetDriverSpec_cxx can directly inherit from the C++ class HybridNetDriverSpec
   * to simplify the whole structure and memory management.
   */
  class HybridNetDriverSpecSwift: public virtual HybridNetDriverSpec {
  public:
    // Constructor from a Swift instance
    explicit HybridNetDriverSpecSwift(const RustCNet::HybridNetDriverSpec_cxx& swiftPart):
      HybridObject(HybridNetDriverSpec::TAG),
      _swiftPart(swiftPart) { }

  public:
    // Get the Swift part
    inline RustCNet::HybridNetDriverSpec_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<HybridNetDriverSpecSwift>(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 std::shared_ptr<HybridNetSocketDriverSpec> createSocket(const std::optional<std::string>& id) override {
      auto __result = _swiftPart.createSocket(id);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<HybridNetServerDriverSpec> createServer() override {
      auto __result = _swiftPart.createServer();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<HybridHttpParserSpec> createHttpParser(double mode) override {
      auto __result = _swiftPart.createHttpParser(std::forward<decltype(mode)>(mode));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline double createSecureContext(const std::string& cert, const std::string& key, const std::optional<std::string>& passphrase) override {
      auto __result = _swiftPart.createSecureContext(cert, key, passphrase);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline double createEmptySecureContext() override {
      auto __result = _swiftPart.createEmptySecureContext();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void addCACertToSecureContext(double scId, const std::string& ca) override {
      auto __result = _swiftPart.addCACertToSecureContext(std::forward<decltype(scId)>(scId), ca);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void addContextToSecureContext(double scId, const std::string& hostname, const std::string& cert, const std::string& key, const std::optional<std::string>& passphrase) override {
      auto __result = _swiftPart.addContextToSecureContext(std::forward<decltype(scId)>(scId), hostname, cert, key, passphrase);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void setPFXToSecureContext(double scId, const std::shared_ptr<ArrayBuffer>& pfx, const std::optional<std::string>& passphrase) override {
      auto __result = _swiftPart.setPFXToSecureContext(std::forward<decltype(scId)>(scId), ArrayBufferHolder(pfx), passphrase);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void setOCSPResponseToSecureContext(double scId, const std::shared_ptr<ArrayBuffer>& ocsp) override {
      auto __result = _swiftPart.setOCSPResponseToSecureContext(std::forward<decltype(scId)>(scId), ArrayBufferHolder(ocsp));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline std::optional<std::shared_ptr<ArrayBuffer>> getTicketKeys(double scId) override {
      auto __result = _swiftPart.getTicketKeys(std::forward<decltype(scId)>(scId));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void setTicketKeys(double scId, const std::shared_ptr<ArrayBuffer>& keys) override {
      auto __result = _swiftPart.setTicketKeys(std::forward<decltype(scId)>(scId), ArrayBufferHolder(keys));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void initWithConfig(const NetConfig& config) override {
      auto __result = _swiftPart.initWithConfig(std::forward<decltype(config)>(config));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }

  private:
    RustCNet::HybridNetDriverSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::net
