You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by kr...@apache.org on 2026/01/08 07:46:53 UTC
(avro-rs) branch notes/enum created (now fdbd36f)
This is an automated email from the ASF dual-hosted git repository.
kriskras99 pushed a change to branch notes/enum
in repository https://gitbox.apache.org/repos/asf/avro-rs.git
at fdbd36f notes on enums
This branch includes the following new commits:
new fdbd36f notes on enums
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(avro-rs) 01/01: notes on enums
Posted by kr...@apache.org.
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 <gi...@kriskras99.nl>
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