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

#pragma once

#include "HybridMailEngineSpec.hpp"

// Forward declaration of `HybridMailEngineSpec_cxx` to properly resolve imports.
namespace MailEngine { class HybridMailEngineSpec_cxx; }

// Forward declaration of `HybridMailAccountSpec` to properly resolve imports.
namespace margelo::nitro::mailengine { class HybridMailAccountSpec; }
// Forward declaration of `MailAccountConfig` to properly resolve imports.
namespace margelo::nitro::mailengine { struct MailAccountConfig; }
// Forward declaration of `MailServerConfig` to properly resolve imports.
namespace margelo::nitro::mailengine { struct MailServerConfig; }
// Forward declaration of `MailSecurity` to properly resolve imports.
namespace margelo::nitro::mailengine { enum class MailSecurity; }
// Forward declaration of `MailAuthConfig` to properly resolve imports.
namespace margelo::nitro::mailengine { struct MailAuthConfig; }
// Forward declaration of `MailAuthType` to properly resolve imports.
namespace margelo::nitro::mailengine { enum class MailAuthType; }

#include <memory>
#include "HybridMailAccountSpec.hpp"
#include <NitroModules/Promise.hpp>
#include "MailAccountConfig.hpp"
#include "MailServerConfig.hpp"
#include <string>
#include "MailSecurity.hpp"
#include <optional>
#include "MailAuthConfig.hpp"
#include "MailAuthType.hpp"

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

namespace margelo::nitro::mailengine {

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

  public:
    // Get the Swift part
    inline MailEngine::HybridMailEngineSpec_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<HybridMailEngineSpecSwift>(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<Promise<std::shared_ptr<HybridMailAccountSpec>>> connect(const MailAccountConfig& config) override {
      auto __result = _swiftPart.connect(std::forward<decltype(config)>(config));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }

  private:
    MailEngine::HybridMailEngineSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::mailengine
