Protocol Buffers - Google's data interchange format (grpc依赖)
https://developers.google.com/protocol-buffers/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
556 B
27 lines
556 B
8 months ago
|
#include "rust/cpp_kernel/strings.h"
|
||
|
|
||
|
#include <cstring>
|
||
|
#include <string>
|
||
|
|
||
|
#include "rust/cpp_kernel/rust_alloc_for_cpp_api.h"
|
||
|
|
||
|
namespace google {
|
||
|
namespace protobuf {
|
||
|
namespace rust_internal {
|
||
|
|
||
|
RustStringRawParts::RustStringRawParts(std::string src) {
|
||
|
if (src.empty()) {
|
||
|
data = nullptr;
|
||
|
len = 0;
|
||
|
} else {
|
||
|
void* d = __pb_rust_alloc(src.length(), 1);
|
||
|
std::memcpy(d, src.data(), src.length());
|
||
|
data = static_cast<char*>(d);
|
||
|
len = src.length();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
} // namespace rust_internal
|
||
|
} // namespace protobuf
|
||
|
} // namespace google
|