A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
json.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 The A11 Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef A11_DATA_JSON_H_
18#define A11_DATA_JSON_H_
19
20#include <string>
21#include <string_view>
22
23#include <absl/status/statusor.h>
24#include <nlohmann/json_fwd.hpp>
25
26#include "a11/data/types.h"
27
28namespace a11::data {
29
31absl::StatusOr<nlohmann::json> ChunkMetadataToJsonValue(
32 const ChunkMetadata& value);
34absl::StatusOr<ChunkMetadata> ChunkMetadataFromJsonValue(
35 const nlohmann::json& value);
36
38absl::StatusOr<nlohmann::json> ChunkToJsonValue(const Chunk& value);
40absl::StatusOr<Chunk> ChunkFromJsonValue(const nlohmann::json& value);
41
43absl::StatusOr<nlohmann::json> StorageIdentityToJsonValue(
44 const StorageIdentity& value);
46absl::StatusOr<StorageIdentity> StorageIdentityFromJsonValue(
47 const nlohmann::json& value);
48
50absl::StatusOr<nlohmann::json> NodeRefToJsonValue(const NodeRef& value);
52absl::StatusOr<NodeRef> NodeRefFromJsonValue(const nlohmann::json& value);
53
55absl::StatusOr<nlohmann::json> NodeFragmentToJsonValue(
56 const NodeFragment& value);
58absl::StatusOr<NodeFragment> NodeFragmentFromJsonValue(
59 const nlohmann::json& value);
60
62absl::StatusOr<nlohmann::json> PortToJsonValue(const Port& value);
64absl::StatusOr<Port> PortFromJsonValue(const nlohmann::json& value);
65
67absl::StatusOr<nlohmann::json> ActionMessageToJsonValue(
68 const ActionMessage& value);
70absl::StatusOr<ActionMessage> ActionMessageFromJsonValue(
71 const nlohmann::json& value);
72
73// JSON encoding used by A11's HTTP/SSE transports.
74absl::StatusOr<nlohmann::json> WireMessageToJsonValue(
75 const WireMessage& message);
76absl::StatusOr<std::string> WireMessageToJson(const WireMessage& message);
77absl::StatusOr<WireMessage> WireMessageFromJsonValue(
78 const nlohmann::json& value);
79absl::StatusOr<WireMessage> WireMessageFromJson(std::string_view encoded);
80
81} // namespace a11::data
82
83#endif // A11_DATA_JSON_H_
std::string value
Definition discover.cc:100
Definition json.cc:35
absl::StatusOr< WireMessage > WireMessageFromJsonValue(const Json &value)
Definition json.cc:618
absl::StatusOr< Json > StorageIdentityToJsonValue(const StorageIdentity &value)
Encode storage identity and optional access fields at the wire boundary.
Definition json.cc:442
absl::StatusOr< NodeFragment > NodeFragmentFromJsonValue(const Json &value)
Definition json.cc:568
absl::StatusOr< NodeRef > NodeRefFromJsonValue(const Json &value)
Definition json.cc:559
absl::StatusOr< WireMessage > WireMessageFromJson(std::string_view encoded)
Definition json.cc:654
absl::StatusOr< std::string > WireMessageToJson(const WireMessage &message)
Definition json.cc:613
absl::StatusOr< Json > NodeRefToJsonValue(const NodeRef &value)
Encode a NodeRef using the native wire JSON representation.
Definition json.cc:554
absl::StatusOr< ActionMessage > ActionMessageFromJsonValue(const Json &value)
Definition json.cc:586
absl::StatusOr< Port > PortFromJsonValue(const Json &value)
Definition json.cc:577
absl::StatusOr< Json > ChunkMetadataToJsonValue(const ChunkMetadata &value)
Encode a ChunkMetadata using the native wire JSON representation.
Definition json.cc:424
absl::StatusOr< Json > ChunkToJsonValue(const Chunk &value)
Encode a Chunk using the native wire JSON representation.
Definition json.cc:433
absl::StatusOr< ChunkMetadata > ChunkMetadataFromJsonValue(const Json &value)
Definition json.cc:429
absl::StatusOr< Json > WireMessageToJsonValue(const WireMessage &message)
Definition json.cc:590
absl::StatusOr< Json > PortToJsonValue(const Port &value)
Encode a Port using the native wire JSON representation.
Definition json.cc:572
absl::StatusOr< StorageIdentity > StorageIdentityFromJsonValue(const Json &value)
Definition json.cc:472
absl::StatusOr< Json > ActionMessageToJsonValue(const ActionMessage &value)
Encode a ActionMessage using the native wire JSON representation.
Definition json.cc:581
absl::StatusOr< Chunk > ChunkFromJsonValue(const Json &value)
Definition json.cc:438
absl::StatusOr< Json > NodeFragmentToJsonValue(const NodeFragment &value)
Encode a NodeFragment using the native wire JSON representation.
Definition json.cc:563
The wire description of an action invocation.
Definition types.h:466
A unit of data: bytes plus optional descriptive metadata.
Definition types.h:173
One piece of a node's stream: an inline chunk or a node reference.
Definition types.h:366
A reference to a (slice of a) logical node, in lieu of inline data.
Definition types.h:311
Binds an action's port name to the concrete node id serving it.
Definition types.h:420
Logical namespace with optional host-interpreted backend access information.
Definition types.h:290
The top-level frame exchanged between two A11 endpoints.
Definition types.h:516
A11's core wire value types: chunks, node fragments and messages.