Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:12:00

0001 // Protocol Buffers - Google's data interchange format
0002 // Copyright 2023 Google LLC.  All rights reserved.
0003 //
0004 // Use of this source code is governed by a BSD-style
0005 // license that can be found in the LICENSE file or at
0006 // https://developers.google.com/open-source/licenses/bsd
0007 
0008 #ifndef GOOGLE_PROTOBUF_COMPILER_RUST_ENUM_H__
0009 #define GOOGLE_PROTOBUF_COMPILER_RUST_ENUM_H__
0010 
0011 #include <cstdint>
0012 #include <string>
0013 #include <utility>
0014 #include <vector>
0015 
0016 #include "absl/strings/string_view.h"
0017 #include "absl/types/span.h"
0018 #include "google/protobuf/compiler/rust/context.h"
0019 #include "google/protobuf/descriptor.h"
0020 
0021 namespace google {
0022 namespace protobuf {
0023 namespace compiler {
0024 namespace rust {
0025 
0026 // Generates code for a particular enum in `.pb.rs`.
0027 void GenerateEnumDefinition(Context& ctx, const EnumDescriptor& desc);
0028 
0029 // Generates code for a particular enum in `.pb.thunk.cc`.
0030 void GenerateEnumThunksCc(Context& ctx, const EnumDescriptor& desc);
0031 
0032 // An enum value with a unique number and any aliases for it.
0033 struct RustEnumValue {
0034   // The canonical CamelCase name in Rust.
0035   std::string name;
0036   int32_t number;
0037   std::vector<std::string> aliases;
0038 };
0039 
0040 // Returns the list of rust enum variants to produce, along with their aliases.
0041 // Performs name normalization, deduplication, and alias determination.
0042 // The `number` and `name` of every returned `RustEnumValue` is unique.
0043 std::vector<RustEnumValue> EnumValues(
0044     absl::string_view enum_name,
0045     absl::Span<const std::pair<absl::string_view, int32_t>> values);
0046 
0047 }  // namespace rust
0048 }  // namespace compiler
0049 }  // namespace protobuf
0050 }  // namespace google
0051 
0052 #endif  // GOOGLE_PROTOBUF_COMPILER_RUST_ENUM_H__