Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions zenoh/src/api/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<EncodingId, &'static str> = phf_map! {
0u16 => "zenoh/bytes",
Expand Down Expand Up @@ -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 => "",
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -764,6 +773,10 @@ mod tests {
Encoding::from("application/json"),
Encoding::APPLICATION_JSON
);
assert_eq!(
Encoding::from("application/flatbuffers"),
Encoding::APPLICATION_FLATBUFFERS
);
}

#[test]
Expand All @@ -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]
Expand Down
Loading