nominal_api/conjure/objects/scout/video/api/
video_file_timestamp_manifest.rs1use conjure_object::serde::{ser, de};
2use conjure_object::serde::ser::SerializeMap as SerializeMap_;
3use conjure_object::private::{UnionField_, UnionTypeField_};
4use std::fmt;
5#[derive(Debug, Clone, conjure_object::private::DeriveWith)]
6#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
7pub enum VideoFileTimestampManifest {
8 Mcap(super::McapTimestampManifest),
9 S3path(super::super::super::super::api::S3Path),
10 NoManifest(super::NoTimestampManifest),
11 Unknown(Unknown),
13}
14impl ser::Serialize for VideoFileTimestampManifest {
15 fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
16 where
17 S: ser::Serializer,
18 {
19 let mut map = s.serialize_map(Some(2))?;
20 match self {
21 VideoFileTimestampManifest::Mcap(value) => {
22 map.serialize_entry(&"type", &"mcap")?;
23 map.serialize_entry(&"mcap", value)?;
24 }
25 VideoFileTimestampManifest::S3path(value) => {
26 map.serialize_entry(&"type", &"s3path")?;
27 map.serialize_entry(&"s3path", value)?;
28 }
29 VideoFileTimestampManifest::NoManifest(value) => {
30 map.serialize_entry(&"type", &"noManifest")?;
31 map.serialize_entry(&"noManifest", value)?;
32 }
33 VideoFileTimestampManifest::Unknown(value) => {
34 map.serialize_entry(&"type", &value.type_)?;
35 map.serialize_entry(&value.type_, &value.value)?;
36 }
37 }
38 map.end()
39 }
40}
41impl<'de> de::Deserialize<'de> for VideoFileTimestampManifest {
42 fn deserialize<D>(d: D) -> Result<VideoFileTimestampManifest, D::Error>
43 where
44 D: de::Deserializer<'de>,
45 {
46 d.deserialize_map(Visitor_)
47 }
48}
49struct Visitor_;
50impl<'de> de::Visitor<'de> for Visitor_ {
51 type Value = VideoFileTimestampManifest;
52 fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
53 fmt.write_str("union VideoFileTimestampManifest")
54 }
55 fn visit_map<A>(self, mut map: A) -> Result<VideoFileTimestampManifest, A::Error>
56 where
57 A: de::MapAccess<'de>,
58 {
59 let v = match map.next_key::<UnionField_<Variant_>>()? {
60 Some(UnionField_::Type) => {
61 let variant = map.next_value()?;
62 let key = map.next_key()?;
63 match (variant, key) {
64 (Variant_::Mcap, Some(Variant_::Mcap)) => {
65 let value = map.next_value()?;
66 VideoFileTimestampManifest::Mcap(value)
67 }
68 (Variant_::S3path, Some(Variant_::S3path)) => {
69 let value = map.next_value()?;
70 VideoFileTimestampManifest::S3path(value)
71 }
72 (Variant_::NoManifest, Some(Variant_::NoManifest)) => {
73 let value = map.next_value()?;
74 VideoFileTimestampManifest::NoManifest(value)
75 }
76 (Variant_::Unknown(type_), Some(Variant_::Unknown(b))) => {
77 if type_ == b {
78 let value = map.next_value()?;
79 VideoFileTimestampManifest::Unknown(Unknown { type_, value })
80 } else {
81 return Err(
82 de::Error::invalid_value(de::Unexpected::Str(&type_), &&*b),
83 )
84 }
85 }
86 (variant, Some(key)) => {
87 return Err(
88 de::Error::invalid_value(
89 de::Unexpected::Str(key.as_str()),
90 &variant.as_str(),
91 ),
92 );
93 }
94 (variant, None) => {
95 return Err(de::Error::missing_field(variant.as_str()));
96 }
97 }
98 }
99 Some(UnionField_::Value(variant)) => {
100 let value = match &variant {
101 Variant_::Mcap => {
102 let value = map.next_value()?;
103 VideoFileTimestampManifest::Mcap(value)
104 }
105 Variant_::S3path => {
106 let value = map.next_value()?;
107 VideoFileTimestampManifest::S3path(value)
108 }
109 Variant_::NoManifest => {
110 let value = map.next_value()?;
111 VideoFileTimestampManifest::NoManifest(value)
112 }
113 Variant_::Unknown(type_) => {
114 let value = map.next_value()?;
115 VideoFileTimestampManifest::Unknown(Unknown {
116 type_: type_.clone(),
117 value,
118 })
119 }
120 };
121 if map.next_key::<UnionTypeField_>()?.is_none() {
122 return Err(de::Error::missing_field("type"));
123 }
124 let type_variant = map.next_value::<Variant_>()?;
125 if variant != type_variant {
126 return Err(
127 de::Error::invalid_value(
128 de::Unexpected::Str(type_variant.as_str()),
129 &variant.as_str(),
130 ),
131 );
132 }
133 value
134 }
135 None => return Err(de::Error::missing_field("type")),
136 };
137 if map.next_key::<UnionField_<Variant_>>()?.is_some() {
138 return Err(de::Error::invalid_length(3, &"type and value fields"));
139 }
140 Ok(v)
141 }
142}
143#[derive(PartialEq)]
144enum Variant_ {
145 Mcap,
146 S3path,
147 NoManifest,
148 Unknown(Box<str>),
149}
150impl Variant_ {
151 fn as_str(&self) -> &'static str {
152 match *self {
153 Variant_::Mcap => "mcap",
154 Variant_::S3path => "s3path",
155 Variant_::NoManifest => "noManifest",
156 Variant_::Unknown(_) => "unknown variant",
157 }
158 }
159}
160impl<'de> de::Deserialize<'de> for Variant_ {
161 fn deserialize<D>(d: D) -> Result<Variant_, D::Error>
162 where
163 D: de::Deserializer<'de>,
164 {
165 d.deserialize_str(VariantVisitor_)
166 }
167}
168struct VariantVisitor_;
169impl<'de> de::Visitor<'de> for VariantVisitor_ {
170 type Value = Variant_;
171 fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
172 fmt.write_str("string")
173 }
174 fn visit_str<E>(self, value: &str) -> Result<Variant_, E>
175 where
176 E: de::Error,
177 {
178 let v = match value {
179 "mcap" => Variant_::Mcap,
180 "s3path" => Variant_::S3path,
181 "noManifest" => Variant_::NoManifest,
182 value => Variant_::Unknown(value.to_string().into_boxed_str()),
183 };
184 Ok(v)
185 }
186}
187#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
189pub struct Unknown {
190 type_: Box<str>,
191 value: conjure_object::Any,
192}
193impl Unknown {
194 #[inline]
196 pub fn type_(&self) -> &str {
197 &self.type_
198 }
199}