Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

oneof vs enum

Prefer to have oneof with a string field describing the specific type of oneof.

message A { // A here is the "interface".
  string name = 1;
  string a_type = 2; // Or an enum. See AIP-126 and AIP-143 for more information.

  // .. Anything else that applies to all A's.

  // Stuff that's specific to the concrete types.
  oneof content {
    B b = 3;
    C c = 4;
    // ...
  }
}

References