rustdds/structure/
topic_kind.rs1use std::fmt;
2
3use speedy::{Readable, Writable};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Readable, Writable)]
7#[repr(u32)]
8pub enum TopicKind {
9 NoKey = 1,
10 WithKey = 2,
11}
12
13impl fmt::Display for TopicKind {
14 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15 write!(
16 f,
17 "{}",
18 match self {
19 TopicKind::NoKey => "NoKey",
20 TopicKind::WithKey => "WithKey",
21 }
22 )
23 }
24}
25
26#[cfg(test)]
27mod tests {
28 use super::*;
29
30 serialization_test!(type = TopicKind,
31 {
32 topic_kind_no_key,
33 TopicKind::NoKey,
34 le = [0x01, 0x00, 0x00, 0x00],
35 be = [0x00, 0x00, 0x00, 0x01]
36 },
37 {
38 topic_kind_with_key,
39 TopicKind::WithKey,
40 le = [0x02, 0x00, 0x00, 0x00],
41 be = [0x00, 0x00, 0x00, 0x02]
42 });
43}