#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
#[non_exhaustive]
pub enum Edition {
Proto2,
Proto3,
Edition2023,
Edition2024,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum FieldPresence {
Explicit,
Implicit,
LegacyRequired,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum EnumType {
Open,
Closed,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum RepeatedFieldEncoding {
Packed,
Expanded,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum Utf8Validation {
Verify,
None,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum MessageEncoding {
LengthPrefixed,
Delimited,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum JsonFormat {
Allow,
LegacyBestEffort,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct ResolvedFeatures {
pub field_presence: FieldPresence,
pub enum_type: EnumType,
pub repeated_field_encoding: RepeatedFieldEncoding,
pub utf8_validation: Utf8Validation,
pub message_encoding: MessageEncoding,
pub json_format: JsonFormat,
}
impl ResolvedFeatures {
pub fn edition_2023_defaults() -> Self {
Self {
field_presence: FieldPresence::Explicit,
enum_type: EnumType::Open,
repeated_field_encoding: RepeatedFieldEncoding::Packed,
utf8_validation: Utf8Validation::Verify,
message_encoding: MessageEncoding::LengthPrefixed,
json_format: JsonFormat::Allow,
}
}
pub fn proto2_defaults() -> Self {
Self {
field_presence: FieldPresence::Explicit,
enum_type: EnumType::Closed,
repeated_field_encoding: RepeatedFieldEncoding::Expanded,
utf8_validation: Utf8Validation::None,
message_encoding: MessageEncoding::LengthPrefixed,
json_format: JsonFormat::LegacyBestEffort,
}
}
pub fn proto3_defaults() -> Self {
Self {
field_presence: FieldPresence::Implicit,
enum_type: EnumType::Open,
repeated_field_encoding: RepeatedFieldEncoding::Packed,
utf8_validation: Utf8Validation::Verify,
message_encoding: MessageEncoding::LengthPrefixed,
json_format: JsonFormat::Allow,
}
}
}