MCPcopy Create free account
hub / github.com/PiSCSI/piscsi / SerializeMessage

Method SerializeMessage

cpp/shared/protobuf_util.cpp:182–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180//---------------------------------------------------------------------------
181
182void protobuf_util::SerializeMessage(int fd, const google::protobuf::Message& message)
183{
184 const string data = message.SerializeAsString();
185
186 // Write the size of the protobuf data as a header
187 const auto size = static_cast<int32_t>(data.length());
188 if (write(fd, &size, sizeof(size)) != sizeof(size)) {
189 throw io_exception("Can't write protobuf message size");
190 }
191
192 // Write the actual protobuf data
193 if (write(fd, data.data(), size) != size) {
194 throw io_exception("Can't write protobuf message data");
195 }
196}
197
198void protobuf_util::DeserializeMessage(int fd, google::protobuf::Message& message)
199{

Callers

nothing calls this directly

Calls 1

io_exceptionClass · 0.85

Tested by

no test coverage detected