MCPcopy Create free account
hub / github.com/apache/mesos / deserialize

Function deserialize

src/common/http.hpp:109–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107// HTTP content type.
108template <typename Message>
109Try<Message> deserialize(
110 ContentType contentType,
111 const std::string& body)
112{
113 switch (contentType) {
114 case ContentType::PROTOBUF: {
115 Message message;
116 if (!message.ParseFromString(body)) {
117 return Error("Failed to parse body into a protobuf object");
118 }
119 return message;
120 }
121 case ContentType::JSON: {
122 Try<JSON::Value> value = JSON::parse(body);
123 if (value.isError()) {
124 return Error("Failed to parse body into JSON: " + value.error());
125 }
126
127 return ::protobuf::parse<Message>(value.get());
128 }
129 case ContentType::RECORDIO: {
130 return Error("Deserializing a RecordIO stream is not supported");
131 }
132 }
133
134 UNREACHABLE();
135}
136
137
138// Returns true if the media type can be used for

Callers 3

foreachMethod · 0.70
launchParentContainerMethod · 0.50

Calls 5

parseFunction · 0.70
errorMethod · 0.65
ErrorFunction · 0.50
isErrorMethod · 0.45
getMethod · 0.45

Tested by 2

launchParentContainerMethod · 0.40