1 #ifndef GOOGLE_PROTOBUF_COMPILER_RUST_MAPPING_FILE_H__ 2 #define GOOGLE_PROTOBUF_COMPILER_RUST_MAPPING_FILE_H__ 3 4 #include <string> 5 6 #include "absl/container/flat_hash_map.h" 7 #include "absl/status/statusor.h" 8 #include "google/protobuf/compiler/rust/context.h" 9 10 namespace google { 11 namespace protobuf { 12 namespace compiler { 13 namespace rust { 14 15 // Returns a map from import path of a .proto file to the name of the crate 16 // (proto_library) covering that file. 17 // 18 // This function parses a .rust_crate_mapping file generated by Bazel. The file 19 // contains: 20 // 21 // <crate_name>\n 22 // <number of .proto files covered by the proto_library with that name>\n 23 // <import path of the first .proto file of the proto_library>\n 24 // ... 25 // <import path of the last .proto file of the proto_library>\n 26 // 27 // repeated for each proto_library transitively reachable from the current 28 // proto_library. 29 // 30 // Note that the logic of translating the proto_library label to a crate name 31 // is handled by the build system completely, protoc is only given the end 32 // results. See `_render_text_crate_mapping` in 33 // //third_party/protobuf/rust:aspects.bzl for how Bazel does this. 34 absl::StatusOr<absl::flat_hash_map<std::string, std::string>> 35 GetImportPathToCrateNameMap(const Options* opts); 36 37 } // namespace rust 38 } // namespace compiler 39 } // namespace protobuf 40 } // namespace google 41 42 #endif // GOOGLE_PROTOBUF_COMPILER_RUST_MAPPING_FILE_H__ 43