#ifndef TEMPORAL_RS_PartialDate_HPP
#define TEMPORAL_RS_PartialDate_HPP
#include "PartialDate.d.hpp"
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <memory>
#include <functional>
#include <optional>
#include <cstdlib>
#include "AnyCalendarKind.hpp"
#include "diplomat_runtime.hpp"
namespace temporal_rs {
namespace capi {
} }
inline temporal_rs::capi::PartialDate temporal_rs::PartialDate::AsFFI() const {
return temporal_rs::capi::PartialDate {
year.has_value() ? (temporal_rs::diplomat::capi::OptionI32{ { year.value() }, true }) : (temporal_rs::diplomat::capi::OptionI32{ {}, false }),
month.has_value() ? (temporal_rs::diplomat::capi::OptionU8{ { month.value() }, true }) : (temporal_rs::diplomat::capi::OptionU8{ {}, false }),
{month_code.data(), month_code.size()},
day.has_value() ? (temporal_rs::diplomat::capi::OptionU8{ { day.value() }, true }) : (temporal_rs::diplomat::capi::OptionU8{ {}, false }),
{era.data(), era.size()},
era_year.has_value() ? (temporal_rs::diplomat::capi::OptionI32{ { era_year.value() }, true }) : (temporal_rs::diplomat::capi::OptionI32{ {}, false }),
calendar.AsFFI(),
};
}
inline temporal_rs::PartialDate temporal_rs::PartialDate::FromFFI(temporal_rs::capi::PartialDate c_struct) {
return temporal_rs::PartialDate {
c_struct.year.is_ok ? std::optional(c_struct.year.ok) : std::nullopt,
c_struct.month.is_ok ? std::optional(c_struct.month.ok) : std::nullopt,
std::string_view(c_struct.month_code.data, c_struct.month_code.len),
c_struct.day.is_ok ? std::optional(c_struct.day.ok) : std::nullopt,
std::string_view(c_struct.era.data, c_struct.era.len),
c_struct.era_year.is_ok ? std::optional(c_struct.era_year.ok) : std::nullopt,
temporal_rs::AnyCalendarKind::FromFFI(c_struct.calendar),
};
}
#endif