#ifndef DEVICE_BLUETOOTH_PUBLIC_MOJOM_UUID_MOJOM_TRAITS_H_
#define DEVICE_BLUETOOTH_PUBLIC_MOJOM_UUID_MOJOM_TRAITS_H_
#include <string>
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
#include "device/bluetooth/public/mojom/uuid.mojom-shared.h"
#include "mojo/public/cpp/bindings/struct_traits.h"
namespace mojo {
template <>
struct StructTraits<bluetooth::mojom::UUIDDataView, device::BluetoothUUID> {
static const std::string& uuid(const device::BluetoothUUID& uuid) {
return uuid.canonical_value();
}
static bool Read(bluetooth::mojom::UUIDDataView input,
device::BluetoothUUID* output) {
std::string result;
if (!input.ReadUuid(&result))
return false;
*output = device::BluetoothUUID(result);
return output->IsValid() &&
output->format() == device::BluetoothUUID::kFormat128Bit;
}
};
}
#endif