// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/cpp/mod.rs
// Based on "crates/re_types/definitions/rerun/archetypes/time_series_scalar.fbs".

#include "time_series_scalar.hpp"

#include "../collection_adapter_builtins.hpp"

namespace rerun::archetypes {}

namespace rerun {

    Result<std::vector<DataCell>> AsComponents<archetypes::TimeSeriesScalar>::serialize(
        const archetypes::TimeSeriesScalar& archetype
    ) {
        using namespace archetypes;
        std::vector<DataCell> cells;
        cells.reserve(6);

        {
            auto result = DataCell::from_loggable(archetype.scalar);
            RR_RETURN_NOT_OK(result.error);
            cells.push_back(std::move(result.value));
        }
        if (archetype.radius.has_value()) {
            auto result = DataCell::from_loggable(archetype.radius.value());
            RR_RETURN_NOT_OK(result.error);
            cells.push_back(std::move(result.value));
        }
        if (archetype.color.has_value()) {
            auto result = DataCell::from_loggable(archetype.color.value());
            RR_RETURN_NOT_OK(result.error);
            cells.push_back(std::move(result.value));
        }
        if (archetype.label.has_value()) {
            auto result = DataCell::from_loggable(archetype.label.value());
            RR_RETURN_NOT_OK(result.error);
            cells.push_back(std::move(result.value));
        }
        if (archetype.scattered.has_value()) {
            auto result = DataCell::from_loggable(archetype.scattered.value());
            RR_RETURN_NOT_OK(result.error);
            cells.push_back(std::move(result.value));
        }
        {
            auto indicator = TimeSeriesScalar::IndicatorComponent();
            auto result = DataCell::from_loggable(indicator);
            RR_RETURN_NOT_OK(result.error);
            cells.emplace_back(std::move(result.value));
        }

        return cells;
    }
} // namespace rerun
