// services/network/public/mojom/signed_certificate_timestamp.mojom.h is auto generated by mojom_bindings_generator.py, do not edit

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

#ifndef SERVICES_NETWORK_PUBLIC_MOJOM_SIGNED_CERTIFICATE_TIMESTAMP_MOJOM_H_
#define SERVICES_NETWORK_PUBLIC_MOJOM_SIGNED_CERTIFICATE_TIMESTAMP_MOJOM_H_

#include <stdint.h>

#include <limits>
#include <optional>
#include <type_traits>
#include <utility>
#include "mojo/public/cpp/bindings/clone_traits.h"
#include "mojo/public/cpp/bindings/equals_traits.h"
#include "mojo/public/cpp/bindings/struct_ptr.h"
#include "mojo/public/cpp/bindings/struct_traits.h"
#include "mojo/public/cpp/bindings/union_traits.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"

#include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h"

#include "services/network/public/mojom/signed_certificate_timestamp.mojom-features.h"  // IWYU pragma: export
#include "services/network/public/mojom/signed_certificate_timestamp.mojom-shared.h"  // IWYU pragma: export
#include "services/network/public/mojom/signed_certificate_timestamp.mojom-forward.h"  // IWYU pragma: export
#include "mojo/public/mojom/base/time.mojom.h"
#include <string>
#include <vector>




#include "services/network/public/cpp/signed_certificate_timestamp_mojom_traits.h"




namespace network::mojom {









class  DigitallySigned {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<DigitallySigned, T>::value>;
  using DataView = DigitallySignedDataView;
  using Data_ = internal::DigitallySigned_Data;

  template <typename... Args>
  static DigitallySignedPtr New(Args&&... args) {
    return DigitallySignedPtr(
        std::in_place, std::forward<Args>(args)...);
  }

  template <typename U>
  static DigitallySignedPtr From(const U& u) {
    return mojo::TypeConverter<DigitallySignedPtr, U>::Convert(u);
  }

  template <typename U>
  U To() const {
    return mojo::TypeConverter<U, DigitallySigned>::Convert(*this);
  }


  DigitallySigned();

  DigitallySigned(
      ::net::ct::DigitallySigned::HashAlgorithm hash_algorithm,
      ::net::ct::DigitallySigned::SignatureAlgorithm signature_algorithm,
      std::vector<uint8_t> signature);


  ~DigitallySigned();

  // Clone() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Clone() or copy
  // constructor/assignment are available for members.
  template <typename StructPtrType = DigitallySignedPtr>
  DigitallySignedPtr Clone() const;

  // Equals() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Equals() or == operator
  // are available for members.
  template <typename T, DigitallySigned::EnableIfSame<T>* = nullptr>
  bool Equals(const T& other) const;

  template <typename T, DigitallySigned::EnableIfSame<T>* = nullptr>
  bool operator==(const T& rhs) const { return Equals(rhs); }

  template <typename T, DigitallySigned::EnableIfSame<T>* = nullptr>
  bool operator!=(const T& rhs) const { return !operator==(rhs); }

  template <mojo::internal::SendValidation send_validation, typename UserType>
  static std::vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        DigitallySigned::DataView, std::vector<uint8_t>, send_validation>(input);
  }

  template <typename UserType>
  static std::vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        DigitallySigned::DataView, std::vector<uint8_t>>(input);
  }

  template <typename UserType>
  static mojo::Message SerializeAsMessage(UserType* input) {
    return mojo::internal::SerializeAsMessageImpl<
        DigitallySigned::DataView>(input);
  }

  // The returned Message is serialized only if the message is moved
  // cross-process or cross-language. Otherwise if the message is Deserialized
  // as the same UserType |input| will just be moved to |output| in
  // DeserializeFromMessage.
  template <typename UserType>
  static mojo::Message WrapAsMessage(UserType input) {
    return mojo::Message(std::make_unique<
        internal::DigitallySigned_UnserializedMessageContext<
            UserType, DigitallySigned::DataView>>(0, 0, std::move(input)),
        MOJO_CREATE_MESSAGE_FLAG_NONE);
  }

  template <typename UserType>
  static bool Deserialize(const void* data,
                          size_t data_num_bytes,
                          UserType* output) {
    mojo::Message message;
    return mojo::internal::DeserializeImpl<DigitallySigned::DataView>(
        message, data, data_num_bytes, output, Validate);
  }

  template <typename UserType>
  static bool Deserialize(base::span<const uint8_t> input,
                          UserType* output) {
    return DigitallySigned::Deserialize(
        input.empty() ? nullptr : input.data(), input.size(), output);
  }

  template <typename UserType>
  static bool DeserializeFromMessage(mojo::Message input,
                                     UserType* output) {
    auto context = input.TakeUnserializedContext<
        internal::DigitallySigned_UnserializedMessageContext<
            UserType, DigitallySigned::DataView>>();
    if (context) {
      *output = std::move(context->TakeData());
      return true;
    }
    input.SerializeIfNecessary();
    return mojo::internal::DeserializeImpl<DigitallySigned::DataView>(
        input, input.payload(), input.payload_num_bytes(), output, Validate);
  }

  
  ::net::ct::DigitallySigned::HashAlgorithm hash_algorithm;
  
  ::net::ct::DigitallySigned::SignatureAlgorithm signature_algorithm;
  
  std::vector<uint8_t> signature;

  // Serialise this struct into a trace.
  void WriteIntoTrace(perfetto::TracedValue traced_context) const;

 private:
  static bool Validate(const void* data,
                       mojo::internal::ValidationContext* validation_context);
};

// The comparison operators are templates, so they are only instantiated if they
// are used. Thus, the bindings generator does not need to know whether
// comparison operators are available for members.
template <typename T, DigitallySigned::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);

template <typename T, DigitallySigned::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
  return !(rhs < lhs);
}

template <typename T, DigitallySigned::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
  return rhs < lhs;
}

template <typename T, DigitallySigned::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
  return !(lhs < rhs);
}





class  SignedCertificateTimestamp {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<SignedCertificateTimestamp, T>::value>;
  using DataView = SignedCertificateTimestampDataView;
  using Data_ = internal::SignedCertificateTimestamp_Data;

  template <typename... Args>
  static SignedCertificateTimestampPtr New(Args&&... args) {
    return SignedCertificateTimestampPtr(
        std::in_place, std::forward<Args>(args)...);
  }

  template <typename U>
  static SignedCertificateTimestampPtr From(const U& u) {
    return mojo::TypeConverter<SignedCertificateTimestampPtr, U>::Convert(u);
  }

  template <typename U>
  U To() const {
    return mojo::TypeConverter<U, SignedCertificateTimestamp>::Convert(*this);
  }


  SignedCertificateTimestamp();

  SignedCertificateTimestamp(
      ::net::ct::SignedCertificateTimestamp::Version version,
      const std::string& log_id,
      ::base::Time timestamp,
      std::vector<uint8_t> extensions,
      const ::net::ct::DigitallySigned& signature,
      ::net::ct::SignedCertificateTimestamp::Origin origin,
      const std::string& log_description);


  ~SignedCertificateTimestamp();

  // Clone() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Clone() or copy
  // constructor/assignment are available for members.
  template <typename StructPtrType = SignedCertificateTimestampPtr>
  SignedCertificateTimestampPtr Clone() const;

  // Equals() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Equals() or == operator
  // are available for members.
  template <typename T, SignedCertificateTimestamp::EnableIfSame<T>* = nullptr>
  bool Equals(const T& other) const;

  template <typename T, SignedCertificateTimestamp::EnableIfSame<T>* = nullptr>
  bool operator==(const T& rhs) const { return Equals(rhs); }

  template <typename T, SignedCertificateTimestamp::EnableIfSame<T>* = nullptr>
  bool operator!=(const T& rhs) const { return !operator==(rhs); }

  template <mojo::internal::SendValidation send_validation, typename UserType>
  static std::vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        SignedCertificateTimestamp::DataView, std::vector<uint8_t>, send_validation>(input);
  }

  template <typename UserType>
  static std::vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        SignedCertificateTimestamp::DataView, std::vector<uint8_t>>(input);
  }

  template <typename UserType>
  static mojo::Message SerializeAsMessage(UserType* input) {
    return mojo::internal::SerializeAsMessageImpl<
        SignedCertificateTimestamp::DataView>(input);
  }

  // The returned Message is serialized only if the message is moved
  // cross-process or cross-language. Otherwise if the message is Deserialized
  // as the same UserType |input| will just be moved to |output| in
  // DeserializeFromMessage.
  template <typename UserType>
  static mojo::Message WrapAsMessage(UserType input) {
    return mojo::Message(std::make_unique<
        internal::SignedCertificateTimestamp_UnserializedMessageContext<
            UserType, SignedCertificateTimestamp::DataView>>(0, 0, std::move(input)),
        MOJO_CREATE_MESSAGE_FLAG_NONE);
  }

  template <typename UserType>
  static bool Deserialize(const void* data,
                          size_t data_num_bytes,
                          UserType* output) {
    mojo::Message message;
    return mojo::internal::DeserializeImpl<SignedCertificateTimestamp::DataView>(
        message, data, data_num_bytes, output, Validate);
  }

  template <typename UserType>
  static bool Deserialize(base::span<const uint8_t> input,
                          UserType* output) {
    return SignedCertificateTimestamp::Deserialize(
        input.empty() ? nullptr : input.data(), input.size(), output);
  }

  template <typename UserType>
  static bool DeserializeFromMessage(mojo::Message input,
                                     UserType* output) {
    auto context = input.TakeUnserializedContext<
        internal::SignedCertificateTimestamp_UnserializedMessageContext<
            UserType, SignedCertificateTimestamp::DataView>>();
    if (context) {
      *output = std::move(context->TakeData());
      return true;
    }
    input.SerializeIfNecessary();
    return mojo::internal::DeserializeImpl<SignedCertificateTimestamp::DataView>(
        input, input.payload(), input.payload_num_bytes(), output, Validate);
  }

  
  ::net::ct::SignedCertificateTimestamp::Version version;
  
  std::string log_id;
  
  ::base::Time timestamp;
  
  std::vector<uint8_t> extensions;
  
  ::net::ct::DigitallySigned signature;
  
  ::net::ct::SignedCertificateTimestamp::Origin origin;
  
  std::string log_description;

  // Serialise this struct into a trace.
  void WriteIntoTrace(perfetto::TracedValue traced_context) const;

 private:
  static bool Validate(const void* data,
                       mojo::internal::ValidationContext* validation_context);
};

// The comparison operators are templates, so they are only instantiated if they
// are used. Thus, the bindings generator does not need to know whether
// comparison operators are available for members.
template <typename T, SignedCertificateTimestamp::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);

template <typename T, SignedCertificateTimestamp::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
  return !(rhs < lhs);
}

template <typename T, SignedCertificateTimestamp::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
  return rhs < lhs;
}

template <typename T, SignedCertificateTimestamp::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
  return !(lhs < rhs);
}

template <typename StructPtrType>
DigitallySignedPtr DigitallySigned::Clone() const {
  return New(
      mojo::Clone(hash_algorithm),
      mojo::Clone(signature_algorithm),
      mojo::Clone(signature)
  );
}

template <typename T, DigitallySigned::EnableIfSame<T>*>
bool DigitallySigned::Equals(const T& other_struct) const {
  if (!mojo::Equals(this->hash_algorithm, other_struct.hash_algorithm))
    return false;
  if (!mojo::Equals(this->signature_algorithm, other_struct.signature_algorithm))
    return false;
  if (!mojo::Equals(this->signature, other_struct.signature))
    return false;
  return true;
}

template <typename T, DigitallySigned::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.hash_algorithm < rhs.hash_algorithm)
    return true;
  if (rhs.hash_algorithm < lhs.hash_algorithm)
    return false;
  if (lhs.signature_algorithm < rhs.signature_algorithm)
    return true;
  if (rhs.signature_algorithm < lhs.signature_algorithm)
    return false;
  if (lhs.signature < rhs.signature)
    return true;
  if (rhs.signature < lhs.signature)
    return false;
  return false;
}
template <typename StructPtrType>
SignedCertificateTimestampPtr SignedCertificateTimestamp::Clone() const {
  return New(
      mojo::Clone(version),
      mojo::Clone(log_id),
      mojo::Clone(timestamp),
      mojo::Clone(extensions),
      mojo::Clone(signature),
      mojo::Clone(origin),
      mojo::Clone(log_description)
  );
}

template <typename T, SignedCertificateTimestamp::EnableIfSame<T>*>
bool SignedCertificateTimestamp::Equals(const T& other_struct) const {
  if (!mojo::Equals(this->version, other_struct.version))
    return false;
  if (!mojo::Equals(this->log_id, other_struct.log_id))
    return false;
  if (!mojo::Equals(this->timestamp, other_struct.timestamp))
    return false;
  if (!mojo::Equals(this->extensions, other_struct.extensions))
    return false;
  if (!mojo::Equals(this->signature, other_struct.signature))
    return false;
  if (!mojo::Equals(this->origin, other_struct.origin))
    return false;
  if (!mojo::Equals(this->log_description, other_struct.log_description))
    return false;
  return true;
}

template <typename T, SignedCertificateTimestamp::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.version < rhs.version)
    return true;
  if (rhs.version < lhs.version)
    return false;
  if (lhs.log_id < rhs.log_id)
    return true;
  if (rhs.log_id < lhs.log_id)
    return false;
  if (lhs.timestamp < rhs.timestamp)
    return true;
  if (rhs.timestamp < lhs.timestamp)
    return false;
  if (lhs.extensions < rhs.extensions)
    return true;
  if (rhs.extensions < lhs.extensions)
    return false;
  if (lhs.signature < rhs.signature)
    return true;
  if (rhs.signature < lhs.signature)
    return false;
  if (lhs.origin < rhs.origin)
    return true;
  if (rhs.origin < lhs.origin)
    return false;
  if (lhs.log_description < rhs.log_description)
    return true;
  if (rhs.log_description < lhs.log_description)
    return false;
  return false;
}


}  // network::mojom

namespace mojo {


template <>
struct  StructTraits<::network::mojom::DigitallySigned::DataView,
                                         ::network::mojom::DigitallySignedPtr> {
  static bool IsNull(const ::network::mojom::DigitallySignedPtr& input) { return !input; }
  static void SetToNull(::network::mojom::DigitallySignedPtr* output) { output->reset(); }

  static decltype(::network::mojom::DigitallySigned::hash_algorithm) hash_algorithm(
      const ::network::mojom::DigitallySignedPtr& input) {
    return input->hash_algorithm;
  }

  static decltype(::network::mojom::DigitallySigned::signature_algorithm) signature_algorithm(
      const ::network::mojom::DigitallySignedPtr& input) {
    return input->signature_algorithm;
  }

  static const decltype(::network::mojom::DigitallySigned::signature)& signature(
      const ::network::mojom::DigitallySignedPtr& input) {
    return input->signature;
  }

  static bool Read(::network::mojom::DigitallySigned::DataView input, ::network::mojom::DigitallySignedPtr* output);
};


template <>
struct  StructTraits<::network::mojom::SignedCertificateTimestamp::DataView,
                                         ::network::mojom::SignedCertificateTimestampPtr> {
  static bool IsNull(const ::network::mojom::SignedCertificateTimestampPtr& input) { return !input; }
  static void SetToNull(::network::mojom::SignedCertificateTimestampPtr* output) { output->reset(); }

  static decltype(::network::mojom::SignedCertificateTimestamp::version) version(
      const ::network::mojom::SignedCertificateTimestampPtr& input) {
    return input->version;
  }

  static const decltype(::network::mojom::SignedCertificateTimestamp::log_id)& log_id(
      const ::network::mojom::SignedCertificateTimestampPtr& input) {
    return input->log_id;
  }

  static const decltype(::network::mojom::SignedCertificateTimestamp::timestamp)& timestamp(
      const ::network::mojom::SignedCertificateTimestampPtr& input) {
    return input->timestamp;
  }

  static const decltype(::network::mojom::SignedCertificateTimestamp::extensions)& extensions(
      const ::network::mojom::SignedCertificateTimestampPtr& input) {
    return input->extensions;
  }

  static const decltype(::network::mojom::SignedCertificateTimestamp::signature)& signature(
      const ::network::mojom::SignedCertificateTimestampPtr& input) {
    return input->signature;
  }

  static decltype(::network::mojom::SignedCertificateTimestamp::origin) origin(
      const ::network::mojom::SignedCertificateTimestampPtr& input) {
    return input->origin;
  }

  static const decltype(::network::mojom::SignedCertificateTimestamp::log_description)& log_description(
      const ::network::mojom::SignedCertificateTimestampPtr& input) {
    return input->log_description;
  }

  static bool Read(::network::mojom::SignedCertificateTimestamp::DataView input, ::network::mojom::SignedCertificateTimestampPtr* output);
};

}  // namespace mojo

#endif  // SERVICES_NETWORK_PUBLIC_MOJOM_SIGNED_CERTIFICATE_TIMESTAMP_MOJOM_H_