Skip to content
This repository was archived by the owner on Apr 8, 2024. It is now read-only.
This repository was archived by the owner on Apr 8, 2024. It is now read-only.

Avoid collisions with protobuf fields that are rust keywords #179

@DazWilkin

Description

@DazWilkin

E.g. googleapis/google/api/auth.proto#JwtLocation:

// Specifies a location to extract JWT from an API request.
message JwtLocation {
  oneof in {
    // Specifies HTTP header name to extract JWT token.
    string header = 1;

    // Specifies URL query parameter name to extract JWT token.
    string query = 2;
  }

protoc_rust_grpc generates:

auth.rs:

#[derive(PartialEq,Clone,Default)]
pub struct JwtLocation {
    // message fields
    pub value_prefix: ::std::string::String,
    // message oneof groups
    pub in: ::std::option::Option<JwtLocation_oneof_in>,
    // special fields
    pub unknown_fields: ::protobuf::UnknownFields,
    pub cached_size: ::protobuf::CachedSize,
}

Results in:

expected identifier, found keyword `in`

expected identifier, found keyword

help: you can escape reserved keywords to use them as identifiers: `r#in`

It's unclear to me whether prefixing all|keyword fields with raw string literals would address this issue comprehensively.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions