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

import NitroModules

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

public extension PTStringResult {
  private typealias bridge = margelo.nitro.espprovtoolkit.bridge.swift

  /**
   * Create a new instance of `PTStringResult`.
   */
  init(success: Bool, str: String?, error: Double?) {
    self.init(success, { () -> bridge.std__optional_std__string_ in
      if let __unwrappedValue = str {
        return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
      } else {
        return .init()
      }
    }(), { () -> bridge.std__optional_double_ in
      if let __unwrappedValue = error {
        return bridge.create_std__optional_double_(__unwrappedValue)
      } else {
        return .init()
      }
    }())
  }

  @inline(__always)
  var success: Bool {
    return self.__success
  }
  
  @inline(__always)
  var str: String? {
    return { () -> String? in
      if bridge.has_value_std__optional_std__string_(self.__str) {
        let __unwrapped = bridge.get_std__optional_std__string_(self.__str)
        return String(__unwrapped)
      } else {
        return nil
      }
    }()
  }
  
  @inline(__always)
  var error: Double? {
    return { () -> Double? in
      if bridge.has_value_std__optional_double_(self.__error) {
        let __unwrapped = bridge.get_std__optional_double_(self.__error)
        return __unwrapped
      } else {
        return nil
      }
    }()
  }
}
