// services/device/public/mojom/hid.mojom-shared.cc is auto generated by mojom_bindings_generator.py, do not edit

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

#include "services/device/public/mojom/hid.mojom-shared.h"
#include <ostream>
#include <utility>
#include "base/strings/stringprintf.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/lib/validation_util.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"

#include "services/device/public/mojom/hid.mojom-params-data.h"
namespace device {
namespace mojom {

NOINLINE static const char* HidBusTypeToStringHelper(HidBusType value) {
  // Defined in a helper function to ensure that Clang generates a lookup table.
  switch(value) {
    case HidBusType::kHIDBusTypeUSB:
      return "kHIDBusTypeUSB";
    case HidBusType::kHIDBusTypeBluetooth:
      return "kHIDBusTypeBluetooth";
    case HidBusType::kHIDBusTypeUnknown:
      return "kHIDBusTypeUnknown";
    case HidBusType::kHIDBusTypeI2C:
      return "kHIDBusTypeI2C";
    case HidBusType::kHIDBusTypeSPI:
      return "kHIDBusTypeSPI";
    case HidBusType::kHIDBusTypeUHID:
      return "kHIDBusTypeUHID";
    default:
      return nullptr;
  }
}

std::string HidBusTypeToString(HidBusType value) {
  const char *str = HidBusTypeToStringHelper(value);
  if (!str) {
    return base::StringPrintf("Unknown HidBusType value: %i", static_cast<int32_t>(value));
  }
  return str;
}

std::ostream& operator<<(std::ostream& os, HidBusType value) {
  return os << HidBusTypeToString(value);
}

namespace internal {


// static
bool HidUsageAndPage_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidUsageAndPage_Data* object =
      static_cast<const HidUsageAndPage_Data*>(data);

  return true;
}

HidUsageAndPage_Data::HidUsageAndPage_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidReportItem_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 88, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidReportItem_Data* object =
      static_cast<const HidReportItem_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->usages, 11, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& usages_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->usages, validation_context,
                                         &usages_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidatePointerNonNullable(
          object->usage_minimum, 12, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateStruct(object->usage_minimum, validation_context))
    return false;

  if (!mojo::internal::ValidatePointerNonNullable(
          object->usage_maximum, 13, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateStruct(object->usage_maximum, validation_context))
    return false;

  return true;
}

HidReportItem_Data::HidReportItem_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidReportDescription_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 24, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidReportDescription_Data* object =
      static_cast<const HidReportDescription_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->items, 2, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& items_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->items, validation_context,
                                         &items_validate_params)) {
    return false;
  }

  return true;
}

HidReportDescription_Data::HidReportDescription_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidCollectionInfo_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 64, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidCollectionInfo_Data* object =
      static_cast<const HidCollectionInfo_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->usage, 1, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateStruct(object->usage, validation_context))
    return false;

  if (!mojo::internal::ValidatePointerNonNullable(
          object->report_ids, 2, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& report_ids_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->report_ids, validation_context,
                                         &report_ids_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidatePointerNonNullable(
          object->input_reports, 4, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& input_reports_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->input_reports, validation_context,
                                         &input_reports_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidatePointerNonNullable(
          object->output_reports, 5, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& output_reports_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->output_reports, validation_context,
                                         &output_reports_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidatePointerNonNullable(
          object->feature_reports, 6, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& feature_reports_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->feature_reports, validation_context,
                                         &feature_reports_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidatePointerNonNullable(
          object->children, 7, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& children_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->children, validation_context,
                                         &children_validate_params)) {
    return false;
  }

  return true;
}

HidCollectionInfo_Data::HidCollectionInfo_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidDeviceInfo_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  static constexpr mojo::internal::StructVersionSize kVersionSizes[] = {
    { 0, 104 },
    { 1, 128 },
    { 3, 128 },
  };
  if (!ValidateStructHeaderAndVersionSizeAndClaimMemory(
          data, kVersionSizes, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidDeviceInfo_Data* object =
      static_cast<const HidDeviceInfo_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->guid, 1, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& guid_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->guid, validation_context,
                                         &guid_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidatePointerNonNullable(
          object->physical_device_id, 2, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& physical_device_id_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->physical_device_id, validation_context,
                                         &physical_device_id_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidatePointerNonNullable(
          object->product_name, 5, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& product_name_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->product_name, validation_context,
                                         &product_name_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidatePointerNonNullable(
          object->serial_number, 6, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& serial_number_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->serial_number, validation_context,
                                         &serial_number_validate_params)) {
    return false;
  }


  if (!::device::mojom::internal::HidBusType_Data
        ::Validate(object->bus_type, validation_context))
    return false;

  if (!mojo::internal::ValidatePointerNonNullable(
          object->report_descriptor, 8, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& report_descriptor_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->report_descriptor, validation_context,
                                         &report_descriptor_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidatePointerNonNullable(
          object->collections, 9, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& collections_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->collections, validation_context,
                                         &collections_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidatePointerNonNullable(
          object->device_node, 14, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& device_node_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->device_node, validation_context,
                                         &device_node_validate_params)) {
    return false;
  }
  if (object->header_.version < 1)
    return true;

  constexpr const mojo::internal::ContainerValidateParams& protected_input_report_ids_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->protected_input_report_ids, validation_context,
                                         &protected_input_report_ids_validate_params)) {
    return false;
  }

  constexpr const mojo::internal::ContainerValidateParams& protected_output_report_ids_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->protected_output_report_ids, validation_context,
                                         &protected_output_report_ids_validate_params)) {
    return false;
  }

  constexpr const mojo::internal::ContainerValidateParams& protected_feature_report_ids_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->protected_feature_report_ids, validation_context,
                                         &protected_feature_report_ids_validate_params)) {
    return false;
  }

  return true;
}

HidDeviceInfo_Data::HidDeviceInfo_Data()
    : header_({sizeof(*this), 3}) {}


// static
bool HidManagerClient_DeviceAdded_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidManagerClient_DeviceAdded_Params_Data* object =
      static_cast<const HidManagerClient_DeviceAdded_Params_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->device_info, 1, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateStruct(object->device_info, validation_context))
    return false;

  return true;
}

HidManagerClient_DeviceAdded_Params_Data::HidManagerClient_DeviceAdded_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidManagerClient_DeviceRemoved_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidManagerClient_DeviceRemoved_Params_Data* object =
      static_cast<const HidManagerClient_DeviceRemoved_Params_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->device_info, 1, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateStruct(object->device_info, validation_context))
    return false;

  return true;
}

HidManagerClient_DeviceRemoved_Params_Data::HidManagerClient_DeviceRemoved_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidManagerClient_DeviceChanged_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidManagerClient_DeviceChanged_Params_Data* object =
      static_cast<const HidManagerClient_DeviceChanged_Params_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->device_info, 1, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateStruct(object->device_info, validation_context))
    return false;

  return true;
}

HidManagerClient_DeviceChanged_Params_Data::HidManagerClient_DeviceChanged_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidManager_GetDevicesAndSetClient_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidManager_GetDevicesAndSetClient_Params_Data* object =
      static_cast<const HidManager_GetDevicesAndSetClient_Params_Data*>(data);

  if (!mojo::internal::ValidateHandleOrInterfaceNonNullable(
          object->client, 1, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateHandleOrInterface(object->client,
                                                 validation_context)) {
    return false;
  }

  return true;
}

HidManager_GetDevicesAndSetClient_Params_Data::HidManager_GetDevicesAndSetClient_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidManager_GetDevicesAndSetClient_ResponseParams_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidManager_GetDevicesAndSetClient_ResponseParams_Data* object =
      static_cast<const HidManager_GetDevicesAndSetClient_ResponseParams_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->devices, 1, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& devices_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->devices, validation_context,
                                         &devices_validate_params)) {
    return false;
  }

  return true;
}

HidManager_GetDevicesAndSetClient_ResponseParams_Data::HidManager_GetDevicesAndSetClient_ResponseParams_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidManager_GetDevices_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 8, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidManager_GetDevices_Params_Data* object =
      static_cast<const HidManager_GetDevices_Params_Data*>(data);

  return true;
}

HidManager_GetDevices_Params_Data::HidManager_GetDevices_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidManager_GetDevices_ResponseParams_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidManager_GetDevices_ResponseParams_Data* object =
      static_cast<const HidManager_GetDevices_ResponseParams_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->devices, 1, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& devices_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->devices, validation_context,
                                         &devices_validate_params)) {
    return false;
  }

  return true;
}

HidManager_GetDevices_ResponseParams_Data::HidManager_GetDevices_ResponseParams_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidManager_Connect_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  static constexpr mojo::internal::StructVersionSize kVersionSizes[] = {
    { 0, 32 },
    { 1, 40 },
    { 2, 40 },
  };
  if (!ValidateStructHeaderAndVersionSizeAndClaimMemory(
          data, kVersionSizes, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidManager_Connect_Params_Data* object =
      static_cast<const HidManager_Connect_Params_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->device_guid, 1, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& device_guid_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->device_guid, validation_context,
                                         &device_guid_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidateHandleOrInterface(object->connection_client,
                                                 validation_context)) {
    return false;
  }

  if (!mojo::internal::ValidateHandleOrInterface(object->watcher,
                                                 validation_context)) {
    return false;
  }

  return true;
}

HidManager_Connect_Params_Data::HidManager_Connect_Params_Data()
    : header_({sizeof(*this), 2}) {}


// static
bool HidManager_Connect_ResponseParams_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidManager_Connect_ResponseParams_Data* object =
      static_cast<const HidManager_Connect_ResponseParams_Data*>(data);

  if (!mojo::internal::ValidateHandleOrInterface(object->connection,
                                                 validation_context)) {
    return false;
  }

  return true;
}

HidManager_Connect_ResponseParams_Data::HidManager_Connect_ResponseParams_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidManager_AddReceiver_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidManager_AddReceiver_Params_Data* object =
      static_cast<const HidManager_AddReceiver_Params_Data*>(data);

  if (!mojo::internal::ValidateHandleOrInterfaceNonNullable(
          object->receiver, 1, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateHandleOrInterface(object->receiver,
                                                 validation_context)) {
    return false;
  }

  return true;
}

HidManager_AddReceiver_Params_Data::HidManager_AddReceiver_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidConnection_Read_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 8, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidConnection_Read_Params_Data* object =
      static_cast<const HidConnection_Read_Params_Data*>(data);

  return true;
}

HidConnection_Read_Params_Data::HidConnection_Read_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidConnection_Read_ResponseParams_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 24, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidConnection_Read_ResponseParams_Data* object =
      static_cast<const HidConnection_Read_ResponseParams_Data*>(data);

  constexpr const mojo::internal::ContainerValidateParams& buffer_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->buffer, validation_context,
                                         &buffer_validate_params)) {
    return false;
  }

  return true;
}

HidConnection_Read_ResponseParams_Data::HidConnection_Read_ResponseParams_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidConnection_Write_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 24, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidConnection_Write_Params_Data* object =
      static_cast<const HidConnection_Write_Params_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->buffer, 2, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& buffer_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->buffer, validation_context,
                                         &buffer_validate_params)) {
    return false;
  }

  return true;
}

HidConnection_Write_Params_Data::HidConnection_Write_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidConnection_Write_ResponseParams_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidConnection_Write_ResponseParams_Data* object =
      static_cast<const HidConnection_Write_ResponseParams_Data*>(data);

  return true;
}

HidConnection_Write_ResponseParams_Data::HidConnection_Write_ResponseParams_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidConnection_GetFeatureReport_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidConnection_GetFeatureReport_Params_Data* object =
      static_cast<const HidConnection_GetFeatureReport_Params_Data*>(data);

  return true;
}

HidConnection_GetFeatureReport_Params_Data::HidConnection_GetFeatureReport_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidConnection_GetFeatureReport_ResponseParams_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 24, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidConnection_GetFeatureReport_ResponseParams_Data* object =
      static_cast<const HidConnection_GetFeatureReport_ResponseParams_Data*>(data);

  constexpr const mojo::internal::ContainerValidateParams& buffer_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->buffer, validation_context,
                                         &buffer_validate_params)) {
    return false;
  }

  return true;
}

HidConnection_GetFeatureReport_ResponseParams_Data::HidConnection_GetFeatureReport_ResponseParams_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidConnection_SendFeatureReport_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 24, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidConnection_SendFeatureReport_Params_Data* object =
      static_cast<const HidConnection_SendFeatureReport_Params_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->buffer, 2, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& buffer_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->buffer, validation_context,
                                         &buffer_validate_params)) {
    return false;
  }

  return true;
}

HidConnection_SendFeatureReport_Params_Data::HidConnection_SendFeatureReport_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidConnection_SendFeatureReport_ResponseParams_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidConnection_SendFeatureReport_ResponseParams_Data* object =
      static_cast<const HidConnection_SendFeatureReport_ResponseParams_Data*>(data);

  return true;
}

HidConnection_SendFeatureReport_ResponseParams_Data::HidConnection_SendFeatureReport_ResponseParams_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool HidConnectionClient_OnInputReport_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 24, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const HidConnectionClient_OnInputReport_Params_Data* object =
      static_cast<const HidConnectionClient_OnInputReport_Params_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->buffer, 2, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& buffer_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->buffer, validation_context,
                                         &buffer_validate_params)) {
    return false;
  }

  return true;
}

HidConnectionClient_OnInputReport_Params_Data::HidConnectionClient_OnInputReport_Params_Data()
    : header_({sizeof(*this), 0}) {}

}  // namespace internal
}  // namespace mojom
}  // namespace device

namespace perfetto {

// static
void TraceFormatTraits<::device::mojom::HidBusType>::WriteIntoTrace(
   perfetto::TracedValue context, ::device::mojom::HidBusType value) {
  return std::move(context).WriteString(::device::mojom::HidBusTypeToString(value));
}

} // namespace perfetto