From 87960114a5ae13d2e869bc056b9971043a0feca6 Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Thu, 26 Jun 2025 11:10:12 +0200 Subject: [PATCH] Add `application/flatbuffers` encoding --- zenoh/src/api/encoding.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/zenoh/src/api/encoding.rs b/zenoh/src/api/encoding.rs index e31088407..47785e79e 100644 --- a/zenoh/src/api/encoding.rs +++ b/zenoh/src/api/encoding.rs @@ -462,6 +462,13 @@ impl Encoding { id: 52, schema: None, }); + /// An application-specific [FlatBuffers](https://flatbuffers.dev/)-encoded data. + /// + /// Constant alias for string: `"application/flatbuffers"`. + pub const APPLICATION_FLATBUFFERS: Encoding = Self(zenoh_protocol::core::Encoding { + id: 53, + schema: None, + }); const ID_TO_STR: phf::Map = phf_map! { 0u16 => "zenoh/bytes", @@ -517,6 +524,7 @@ impl Encoding { 50u16 => "video/raw", 51u16 => "video/vp8", 52u16 => "video/vp9", + 53u16 => "application/flatbuffers", // The 0xFFFFu16 is used to indicate an custom encoding where both encoding and schema // are stored in the schema field. 0xFFFFu16 => "", @@ -576,6 +584,7 @@ impl Encoding { "video/raw" => 50u16, "video/vp8" => 51u16, "video/vp9" => 52u16, + "application/flatbuffers" => 53u16, }; /// The default [`Encoding`] is [`ZENOH_BYTES`](Encoding::ZENOH_BYTES). @@ -764,6 +773,10 @@ mod tests { Encoding::from("application/json"), Encoding::APPLICATION_JSON ); + assert_eq!( + Encoding::from("application/flatbuffers"), + Encoding::APPLICATION_FLATBUFFERS + ); } #[test] @@ -773,6 +786,10 @@ mod tests { assert_eq!(Encoding::ZENOH_STRING.to_string(), "zenoh/string"); assert_eq!(Encoding::TEXT_PLAIN.to_string(), "text/plain"); assert_eq!(Encoding::APPLICATION_JSON.to_string(), "application/json"); + assert_eq!( + Encoding::APPLICATION_FLATBUFFERS.to_string(), + "application/flatbuffers" + ); } #[test]