xref: /aosp_15_r20/external/executorch/backends/apple/coreml/runtime/delegate/serde_json.h (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1 //
2 // Serdes.hpp
3 //
4 // Copyright © 2024 Apple Inc. All rights reserved.
5 //
6 // Please refer to the license found in the LICENSE file in the root directory of the source tree.
7 
8 #pragma once
9 
10 #import <string>
11 
12 namespace executorchcoreml {
13 struct Asset;
14 struct ModelMetadata;
15 
16 namespace serde {
17 namespace json {
18 
19 /// Serializes `Asset` to json.
20 ///
21 /// @param asset The asset value.
22 /// @retval Serialized json.
23 std::string to_json_string(const executorchcoreml::Asset& asset);
24 
25 /// Populates `Asset` from serialized json.
26 ///
27 /// @param json_string  A json string.
28 /// @param asset The asset value to be populated from the json string.
29 void from_json_string(const std::string& json_string, executorchcoreml::Asset& asset);
30 
31 /// Serializes `ModelMetadata` to json.
32 ///
33 /// @param metdata The metadata value.
34 /// @retval Serialized json.
35 std::string to_json_string(const executorchcoreml::ModelMetadata& metdata);
36 
37 /// Populates `ModelMetadata` from serialized json.
38 ///
39 /// @param json_string  A json string.
40 /// @param metadata The metadata value to be populated from the json string.
41 void from_json_string(const std::string& json_string, executorchcoreml::ModelMetadata& metadata);
42 
43 } // namespace json
44 } // namespace serde
45 } // namespace executorchcoreml
46