mcap2arrow_core/
schema_encoding.rs1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6pub enum SchemaEncoding {
7 None,
9 Protobuf,
11 FlatBuffer,
13 Ros1Msg,
15 Ros2Msg,
17 Ros2Idl,
19 OmgIdl,
21 JsonSchema,
23 Unknown(String),
25}
26
27impl SchemaEncoding {
28 pub fn as_str(&self) -> &str {
29 match self {
30 Self::None => "",
31 Self::Protobuf => "protobuf",
32 Self::FlatBuffer => "flatbuffer",
33 Self::Ros1Msg => "ros1msg",
34 Self::Ros2Msg => "ros2msg",
35 Self::Ros2Idl => "ros2idl",
36 Self::OmgIdl => "omgidl",
37 Self::JsonSchema => "jsonschema",
38 Self::Unknown(s) => s,
39 }
40 }
41}
42
43impl From<&str> for SchemaEncoding {
44 fn from(s: &str) -> Self {
45 match s {
46 "" => Self::None,
47 "protobuf" => Self::Protobuf,
48 "flatbuffer" => Self::FlatBuffer,
49 "ros1msg" => Self::Ros1Msg,
50 "ros2msg" => Self::Ros2Msg,
51 "ros2idl" => Self::Ros2Idl,
52 "omgidl" => Self::OmgIdl,
53 "jsonschema" => Self::JsonSchema,
54 other => Self::Unknown(other.to_string()),
55 }
56 }
57}
58
59impl fmt::Display for SchemaEncoding {
60 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
61 f.write_str(self.as_str())
62 }
63}