ip_address_mojom_traits.h 893 B

123456789101112131415161718192021222324252627
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_COMPONENTS_SMBFS_IP_ADDRESS_MOJOM_TRAITS_H_
  5. #define ASH_COMPONENTS_SMBFS_IP_ADDRESS_MOJOM_TRAITS_H_
  6. #include "ash/components/smbfs/mojom/ip_address.mojom-shared.h"
  7. #include "base/containers/span.h"
  8. #include "mojo/public/cpp/bindings/struct_traits.h"
  9. #include "net/base/ip_address.h"
  10. namespace mojo {
  11. template <>
  12. struct COMPONENT_EXPORT(NETWORK_CPP_BASE)
  13. StructTraits<smbfs::mojom::IPAddressDataView, net::IPAddress> {
  14. static base::span<const uint8_t> address_bytes(
  15. const net::IPAddress& ip_address) {
  16. return ip_address.bytes();
  17. }
  18. static bool Read(smbfs::mojom::IPAddressDataView obj, net::IPAddress* out);
  19. };
  20. } // namespace mojo
  21. #endif // ASH_COMPONENTS_SMBFS_IP_ADDRESS_MOJOM_TRAITS_H_