// services/network/public/mojom/fetch_retry_options.mojom-data-view.h is auto generated by mojom_bindings_generator.py, do not edit

// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This file defines XDataView for type traits and can be included in
// _mojom_traits.h definitions but otherwise please use .mojom-forward.h,
// .mojom-shared.h or .mojom.h.

// IWYU pragma: private
// IWYU pragma: friend "traits"

#ifndef SERVICES_NETWORK_PUBLIC_MOJOM_FETCH_RETRY_OPTIONS_MOJOM_DATA_VIEW_H_
#define SERVICES_NETWORK_PUBLIC_MOJOM_FETCH_RETRY_OPTIONS_MOJOM_DATA_VIEW_H_

#include <stdint.h>

#include <functional>
#include <iosfwd>
#include <type_traits>
#include <utility>
#include "mojo/public/cpp/bindings/array_data_view.h"
#include "mojo/public/cpp/bindings/string_data_view.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"

#include "services/network/public/mojom/fetch_retry_options.mojom-shared-internal.h"
#include "mojo/public/mojom/base/time.mojom-shared.h"


namespace network::mojom {
class FetchRetryOptionsDataView;



}  // network::mojom


namespace mojo {
namespace internal {

template <>
struct MojomTypeTraits<::network::mojom::FetchRetryOptionsDataView> {
  using Data = ::network::mojom::internal::FetchRetryOptions_Data;
  using DataAsArrayElement = Pointer<Data>;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};

}  // namespace internal
}  // namespace mojo


namespace network::mojom {


class FetchRetryOptionsDataView {
 public:
  FetchRetryOptionsDataView() = default;

  FetchRetryOptionsDataView(
      internal::FetchRetryOptions_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

  bool is_null() const { return !data_; }
  uint32_t max_attempts() const {
    return data_->max_attempts;
  }
  inline void GetInitialDelayDataView(
      ::mojo_base::mojom::TimeDeltaDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadInitialDelay(UserType* output) {
    
static_assert(
    mojo::internal::IsValidUserTypeForOptionalValue<
        ::mojo_base::mojom::TimeDeltaDataView, UserType>(),
    "Attempting to read the optional `initial_delay` field into a type which "
    "cannot represent a null value. Either wrap the destination object "
    "with std::optional, ensure that any corresponding "
    "{Struct/Union/Array/String}Traits define the necessary IsNull and "
    "SetToNull methods, or use `MaybeReadInitialDelay` instead "
    "of `ReadInitialDelay if you're fine with null values being "
    "silently ignored in this case.");
    auto* pointer = data_->initial_delay.Get();
    return mojo::internal::Deserialize<::mojo_base::mojom::TimeDeltaDataView>(
        pointer, output, message_);
  }
  std::optional<double> backoff_factor() const {

    return data_->backoff_factor_$flag
        ? std::make_optional(data_->backoff_factor_$value)
        : std::nullopt;
  }
  inline void GetMaxAgeDataView(
      ::mojo_base::mojom::TimeDeltaDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadMaxAge(UserType* output) {
    
static_assert(
    mojo::internal::IsValidUserTypeForOptionalValue<
        ::mojo_base::mojom::TimeDeltaDataView, UserType>(),
    "Attempting to read the optional `max_age` field into a type which "
    "cannot represent a null value. Either wrap the destination object "
    "with std::optional, ensure that any corresponding "
    "{Struct/Union/Array/String}Traits define the necessary IsNull and "
    "SetToNull methods, or use `MaybeReadMaxAge` instead "
    "of `ReadMaxAge if you're fine with null values being "
    "silently ignored in this case.");
    auto* pointer = data_->max_age.Get();
    return mojo::internal::Deserialize<::mojo_base::mojom::TimeDeltaDataView>(
        pointer, output, message_);
  }
  bool retry_after_unload() const {
    return data_->retry_after_unload;
  }
  bool retry_non_idempotent() const {
    return data_->retry_non_idempotent;
  }
  bool retry_only_if_server_unreached() const {
    return data_->retry_only_if_server_unreached;
  }
 private:
  internal::FetchRetryOptions_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};


}  // network::mojom

#endif  // SERVICES_NETWORK_PUBLIC_MOJOM_FETCH_RETRY_OPTIONS_MOJOM_DATA_VIEW_H_