// components/os_crypt/async/common/encryptor.mojom.cc 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.

#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-private-field"
#endif

#include "components/os_crypt/async/common/encryptor.mojom.h"
#include <stdint.h>
#include <utility>
#include "mojo/public/cpp/bindings/lib/default_construct_tag_internal.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/mojo_buildflags.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"

#include "components/os_crypt/async/common/encryptor.mojom-params-data.h"
#include "components/os_crypt/async/common/encryptor.mojom-shared-message-ids.h"

#include "components/os_crypt/async/common/encryptor.mojom-import-headers.h"
#include "components/os_crypt/async/common/encryptor.mojom-test-utils.h"


namespace os_crypt_async::mojom {
Key::Key()
    : algorithm(),
      key() {}

Key::Key(
    ::os_crypt_async::mojom::Algorithm algorithm_in,
    ::base::UnsafeSharedMemoryRegion key_in)
    : algorithm(std::move(algorithm_in)),
      key(std::move(key_in)) {}

Key::~Key() = default;

void Key::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "algorithm"), this->algorithm,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::os_crypt_async::mojom::Algorithm>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "key"), this->key,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::base::UnsafeSharedMemoryRegion>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool Key::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
Encryptor::Encryptor()
    : provider_for_encryption(),
      key_entries() {}

Encryptor::Encryptor(
    const std::string& provider_for_encryption_in,
    base::flat_map<std::string, std::optional<::os_crypt_async::Encryptor::Key>> key_entries_in)
    : provider_for_encryption(std::move(provider_for_encryption_in)),
      key_entries(std::move(key_entries_in)) {}

Encryptor::~Encryptor() = default;

void Encryptor::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "provider_for_encryption"), this->provider_for_encryption,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::string&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "key_entries"), this->key_entries,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type base::flat_map<std::string, std::optional<::os_crypt_async::Encryptor::Key>>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool Encryptor::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}


}  // os_crypt_async::mojom


namespace mojo {


// static
bool StructTraits<::os_crypt_async::mojom::Key::DataView, ::os_crypt_async::mojom::KeyPtr>::Read(
    ::os_crypt_async::mojom::Key::DataView input,
    ::os_crypt_async::mojom::KeyPtr* output) {
  bool success = true;
  ::os_crypt_async::mojom::KeyPtr result(::os_crypt_async::mojom::Key::New());
  
      if (success && !input.ReadAlgorithm(&result->algorithm))
        success = false;
      if (success && !input.ReadKey(&result->key))
        success = false;
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::os_crypt_async::mojom::Encryptor::DataView, ::os_crypt_async::mojom::EncryptorPtr>::Read(
    ::os_crypt_async::mojom::Encryptor::DataView input,
    ::os_crypt_async::mojom::EncryptorPtr* output) {
  bool success = true;
  ::os_crypt_async::mojom::EncryptorPtr result(::os_crypt_async::mojom::Encryptor::New());
  
      if (success && !input.ReadProviderForEncryption(&result->provider_for_encryption))
        success = false;
      if (success && !input.ReadKeyEntries(&result->key_entries))
        success = false;
  *output = std::move(result);
  return success;
}

}  // namespace mojo


// Symbols declared in the -test-utils.h header are defined here instead of a
// separate .cc file to save compile time.


namespace os_crypt_async::mojom {




}  // os_crypt_async::mojom


#if defined(__clang__)
#pragma clang diagnostic pop
#endif