This is an automated email from the ASF dual-hosted git repository. kriskras99 pushed a commit to branch notes/enum in repository https://gitbox.apache.org/repos/asf/avro-rs.git
commit fdbd36f24da940508a47760250db5f452000982b Author: Kriskras99 <[email protected]> AuthorDate: Thu Jan 8 08:46:43 2026 +0100 notes on enums --- enum.md | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/enum.md b/enum.md new file mode 100644 index 0000000..816cd0e --- /dev/null +++ b/enum.md @@ -0,0 +1,71 @@ +# Current state of Rust enum support in Avro + +Plain enums are serialized as Avro enums (only enum support by `#[derive(AvroSchema)]`): +```rust +pub enum Foo { + A, + B, + C, +} +``` +```json +{ + "name": "Foo", + "type": "enum", + "symbols": ["A", "B", "C"] +} +``` + +Mixed enums are serialized as a record with a discriminator field (Avro enum) and a value field (Avro union): +```rust +pub struct Bar { + integer: i32, +} +pub enum Foo { + A, + B { + field: String, + }, + C(Bar) +} +``` +```json +{ + "name": "Foo", + "type": "record", + "fields": [ + { + "name": "type", + "type": { + "type": "enum", + "symbols": ["A", "B", "C"] + } + }, + { + "name": "value", + "type": [ + "Null", + { + "type": "record", + "fields": [ + { + "name": "field", + "type": "string" + } + ] + }, + { + "name": "Bar", + "type": "record", + "fields": [ + { + "name": "integer", + "type": "int" + } + ] + } + ] + } + ] +} +``` \ No newline at end of file
