// services/network/public/mojom/auth.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_AUTH_MOJOM_H_
#define SERVICES_NETWORK_PUBLIC_MOJOM_AUTH_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/auth.mojom-features.h"  // IWYU pragma: export
#include "services/network/public/mojom/auth.mojom-shared.h"  // IWYU pragma: export
#include "services/network/public/mojom/auth.mojom-forward.h"  // IWYU pragma: export
#include "mojo/public/mojom/base/string16.mojom.h"
#include "url/mojom/scheme_host_port.mojom.h"
#include <string>
#include <vector>




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




namespace network::mojom {









class  AuthChallengeInfo {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<AuthChallengeInfo, T>::value>;
  using DataView = AuthChallengeInfoDataView;
  using Data_ = internal::AuthChallengeInfo_Data;

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

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

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


  AuthChallengeInfo();

  AuthChallengeInfo(
      bool is_proxy,
      const ::url::SchemeHostPort& challenger,
      const std::string& scheme,
      const std::string& realm,
      const std::string& challenge,
      const std::string& path);


  ~AuthChallengeInfo();

  // 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 = AuthChallengeInfoPtr>
  AuthChallengeInfoPtr 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, AuthChallengeInfo::EnableIfSame<T>* = nullptr>
  bool Equals(const T& other) const;

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

  template <typename T, AuthChallengeInfo::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<
        AuthChallengeInfo::DataView, std::vector<uint8_t>, send_validation>(input);
  }

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

  template <typename UserType>
  static mojo::Message SerializeAsMessage(UserType* input) {
    return mojo::internal::SerializeAsMessageImpl<
        AuthChallengeInfo::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::AuthChallengeInfo_UnserializedMessageContext<
            UserType, AuthChallengeInfo::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<AuthChallengeInfo::DataView>(
        message, data, data_num_bytes, output, Validate);
  }

  template <typename UserType>
  static bool Deserialize(base::span<const uint8_t> input,
                          UserType* output) {
    return AuthChallengeInfo::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::AuthChallengeInfo_UnserializedMessageContext<
            UserType, AuthChallengeInfo::DataView>>();
    if (context) {
      *output = std::move(context->TakeData());
      return true;
    }
    input.SerializeIfNecessary();
    return mojo::internal::DeserializeImpl<AuthChallengeInfo::DataView>(
        input, input.payload(), input.payload_num_bytes(), output, Validate);
  }

  
  bool is_proxy;
  
  ::url::SchemeHostPort challenger;
  
  std::string scheme;
  
  std::string realm;
  
  std::string challenge;
  
  std::string path;

  // 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, AuthChallengeInfo::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);

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

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

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





class  AuthCredentials {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<AuthCredentials, T>::value>;
  using DataView = AuthCredentialsDataView;
  using Data_ = internal::AuthCredentials_Data;

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

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

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


  AuthCredentials();

  AuthCredentials(
      const ::std::u16string& username,
      const ::std::u16string& password);


  ~AuthCredentials();

  // 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 = AuthCredentialsPtr>
  AuthCredentialsPtr 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, AuthCredentials::EnableIfSame<T>* = nullptr>
  bool Equals(const T& other) const;

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

  template <typename T, AuthCredentials::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<
        AuthCredentials::DataView, std::vector<uint8_t>, send_validation>(input);
  }

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

  template <typename UserType>
  static mojo::Message SerializeAsMessage(UserType* input) {
    return mojo::internal::SerializeAsMessageImpl<
        AuthCredentials::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::AuthCredentials_UnserializedMessageContext<
            UserType, AuthCredentials::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<AuthCredentials::DataView>(
        message, data, data_num_bytes, output, Validate);
  }

  template <typename UserType>
  static bool Deserialize(base::span<const uint8_t> input,
                          UserType* output) {
    return AuthCredentials::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::AuthCredentials_UnserializedMessageContext<
            UserType, AuthCredentials::DataView>>();
    if (context) {
      *output = std::move(context->TakeData());
      return true;
    }
    input.SerializeIfNecessary();
    return mojo::internal::DeserializeImpl<AuthCredentials::DataView>(
        input, input.payload(), input.payload_num_bytes(), output, Validate);
  }

  
  ::std::u16string username;
  
  ::std::u16string password;

  // 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, AuthCredentials::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);

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

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

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

template <typename StructPtrType>
AuthChallengeInfoPtr AuthChallengeInfo::Clone() const {
  return New(
      mojo::Clone(is_proxy),
      mojo::Clone(challenger),
      mojo::Clone(scheme),
      mojo::Clone(realm),
      mojo::Clone(challenge),
      mojo::Clone(path)
  );
}

template <typename T, AuthChallengeInfo::EnableIfSame<T>*>
bool AuthChallengeInfo::Equals(const T& other_struct) const {
  if (!mojo::Equals(this->is_proxy, other_struct.is_proxy))
    return false;
  if (!mojo::Equals(this->challenger, other_struct.challenger))
    return false;
  if (!mojo::Equals(this->scheme, other_struct.scheme))
    return false;
  if (!mojo::Equals(this->realm, other_struct.realm))
    return false;
  if (!mojo::Equals(this->challenge, other_struct.challenge))
    return false;
  if (!mojo::Equals(this->path, other_struct.path))
    return false;
  return true;
}

template <typename T, AuthChallengeInfo::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.is_proxy < rhs.is_proxy)
    return true;
  if (rhs.is_proxy < lhs.is_proxy)
    return false;
  if (lhs.challenger < rhs.challenger)
    return true;
  if (rhs.challenger < lhs.challenger)
    return false;
  if (lhs.scheme < rhs.scheme)
    return true;
  if (rhs.scheme < lhs.scheme)
    return false;
  if (lhs.realm < rhs.realm)
    return true;
  if (rhs.realm < lhs.realm)
    return false;
  if (lhs.challenge < rhs.challenge)
    return true;
  if (rhs.challenge < lhs.challenge)
    return false;
  if (lhs.path < rhs.path)
    return true;
  if (rhs.path < lhs.path)
    return false;
  return false;
}
template <typename StructPtrType>
AuthCredentialsPtr AuthCredentials::Clone() const {
  return New(
      mojo::Clone(username),
      mojo::Clone(password)
  );
}

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

template <typename T, AuthCredentials::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.username < rhs.username)
    return true;
  if (rhs.username < lhs.username)
    return false;
  if (lhs.password < rhs.password)
    return true;
  if (rhs.password < lhs.password)
    return false;
  return false;
}


}  // network::mojom

namespace mojo {


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

  static decltype(::network::mojom::AuthChallengeInfo::is_proxy) is_proxy(
      const ::network::mojom::AuthChallengeInfoPtr& input) {
    return input->is_proxy;
  }

  static const decltype(::network::mojom::AuthChallengeInfo::challenger)& challenger(
      const ::network::mojom::AuthChallengeInfoPtr& input) {
    return input->challenger;
  }

  static const decltype(::network::mojom::AuthChallengeInfo::scheme)& scheme(
      const ::network::mojom::AuthChallengeInfoPtr& input) {
    return input->scheme;
  }

  static const decltype(::network::mojom::AuthChallengeInfo::realm)& realm(
      const ::network::mojom::AuthChallengeInfoPtr& input) {
    return input->realm;
  }

  static const decltype(::network::mojom::AuthChallengeInfo::challenge)& challenge(
      const ::network::mojom::AuthChallengeInfoPtr& input) {
    return input->challenge;
  }

  static const decltype(::network::mojom::AuthChallengeInfo::path)& path(
      const ::network::mojom::AuthChallengeInfoPtr& input) {
    return input->path;
  }

  static bool Read(::network::mojom::AuthChallengeInfo::DataView input, ::network::mojom::AuthChallengeInfoPtr* output);
};


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

  static const decltype(::network::mojom::AuthCredentials::username)& username(
      const ::network::mojom::AuthCredentialsPtr& input) {
    return input->username;
  }

  static const decltype(::network::mojom::AuthCredentials::password)& password(
      const ::network::mojom::AuthCredentialsPtr& input) {
    return input->password;
  }

  static bool Read(::network::mojom::AuthCredentials::DataView input, ::network::mojom::AuthCredentialsPtr* output);
};

}  // namespace mojo

#endif  // SERVICES_NETWORK_PUBLIC_MOJOM_AUTH_MOJOM_H_