1#![allow(unused_imports)]
5#![allow(unused_parens)]
6#![allow(clippy::clone_on_copy)]
7#![allow(clippy::cloned_instead_of_copied)]
8#![allow(clippy::map_flatten)]
9#![allow(clippy::needless_question_mark)]
10#![allow(clippy::new_without_default)]
11#![allow(clippy::redundant_closure)]
12#![allow(clippy::too_many_arguments)]
13#![allow(clippy::too_many_lines)]
14#![allow(non_camel_case_types)]
15
16use ::re_types_core::try_serialize_field;
17use ::re_types_core::SerializationResult;
18use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
19use ::re_types_core::{ComponentDescriptor, ComponentName};
20use ::re_types_core::{DeserializationError, DeserializationResult};
21
22#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Default)]
24#[repr(u8)]
25pub enum MarkerShape {
26 #[default]
28 Circle = 1,
29
30 Diamond = 2,
32
33 Square = 3,
35
36 Cross = 4,
38
39 Plus = 5,
41
42 Up = 6,
44
45 Down = 7,
47
48 Left = 8,
50
51 Right = 9,
53
54 Asterisk = 10,
56}
57
58impl ::re_types_core::Component for MarkerShape {
59 #[inline]
60 fn descriptor() -> ComponentDescriptor {
61 ComponentDescriptor::new("rerun.components.MarkerShape")
62 }
63}
64
65::re_types_core::macros::impl_into_cow!(MarkerShape);
66
67impl ::re_types_core::Loggable for MarkerShape {
68 #[inline]
69 fn arrow_datatype() -> arrow::datatypes::DataType {
70 #![allow(clippy::wildcard_imports)]
71 use arrow::datatypes::*;
72 DataType::UInt8
73 }
74
75 fn to_arrow_opt<'a>(
76 data: impl IntoIterator<Item = Option<impl Into<::std::borrow::Cow<'a, Self>>>>,
77 ) -> SerializationResult<arrow::array::ArrayRef>
78 where
79 Self: Clone + 'a,
80 {
81 #![allow(clippy::wildcard_imports)]
82 #![allow(clippy::manual_is_variant_and)]
83 use ::re_types_core::{arrow_helpers::as_array_ref, Loggable as _, ResultExt as _};
84 use arrow::{array::*, buffer::*, datatypes::*};
85 Ok({
86 let (somes, data0): (Vec<_>, Vec<_>) = data
87 .into_iter()
88 .map(|datum| {
89 let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into);
90 let datum = datum.map(|datum| *datum as u8);
91 (datum.is_some(), datum)
92 })
93 .unzip();
94 let data0_validity: Option<arrow::buffer::NullBuffer> = {
95 let any_nones = somes.iter().any(|some| !*some);
96 any_nones.then(|| somes.into())
97 };
98 as_array_ref(PrimitiveArray::<UInt8Type>::new(
99 ScalarBuffer::from(
100 data0
101 .into_iter()
102 .map(|v| v.unwrap_or_default())
103 .collect::<Vec<_>>(),
104 ),
105 data0_validity,
106 ))
107 })
108 }
109
110 fn from_arrow_opt(
111 arrow_data: &dyn arrow::array::Array,
112 ) -> DeserializationResult<Vec<Option<Self>>>
113 where
114 Self: Sized,
115 {
116 #![allow(clippy::wildcard_imports)]
117 use ::re_types_core::{arrow_zip_validity::ZipValidity, Loggable as _, ResultExt as _};
118 use arrow::{array::*, buffer::*, datatypes::*};
119 Ok(arrow_data
120 .as_any()
121 .downcast_ref::<UInt8Array>()
122 .ok_or_else(|| {
123 let expected = Self::arrow_datatype();
124 let actual = arrow_data.data_type().clone();
125 DeserializationError::datatype_mismatch(expected, actual)
126 })
127 .with_context("rerun.components.MarkerShape#enum")?
128 .into_iter()
129 .map(|typ| match typ {
130 Some(1) => Ok(Some(Self::Circle)),
131 Some(2) => Ok(Some(Self::Diamond)),
132 Some(3) => Ok(Some(Self::Square)),
133 Some(4) => Ok(Some(Self::Cross)),
134 Some(5) => Ok(Some(Self::Plus)),
135 Some(6) => Ok(Some(Self::Up)),
136 Some(7) => Ok(Some(Self::Down)),
137 Some(8) => Ok(Some(Self::Left)),
138 Some(9) => Ok(Some(Self::Right)),
139 Some(10) => Ok(Some(Self::Asterisk)),
140 None => Ok(None),
141 Some(invalid) => Err(DeserializationError::missing_union_arm(
142 Self::arrow_datatype(),
143 "<invalid>",
144 invalid as _,
145 )),
146 })
147 .collect::<DeserializationResult<Vec<Option<_>>>>()
148 .with_context("rerun.components.MarkerShape")?)
149 }
150}
151
152impl std::fmt::Display for MarkerShape {
153 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
154 match self {
155 Self::Circle => write!(f, "Circle"),
156 Self::Diamond => write!(f, "Diamond"),
157 Self::Square => write!(f, "Square"),
158 Self::Cross => write!(f, "Cross"),
159 Self::Plus => write!(f, "Plus"),
160 Self::Up => write!(f, "Up"),
161 Self::Down => write!(f, "Down"),
162 Self::Left => write!(f, "Left"),
163 Self::Right => write!(f, "Right"),
164 Self::Asterisk => write!(f, "Asterisk"),
165 }
166 }
167}
168
169impl ::re_types_core::reflection::Enum for MarkerShape {
170 #[inline]
171 fn variants() -> &'static [Self] {
172 &[
173 Self::Circle,
174 Self::Diamond,
175 Self::Square,
176 Self::Cross,
177 Self::Plus,
178 Self::Up,
179 Self::Down,
180 Self::Left,
181 Self::Right,
182 Self::Asterisk,
183 ]
184 }
185
186 #[inline]
187 fn docstring_md(self) -> &'static str {
188 match self {
189 Self::Circle => "`⏺`",
190 Self::Diamond => "`◆`",
191 Self::Square => "`◼\u{fe0f}`",
192 Self::Cross => "`x`",
193 Self::Plus => "`+`",
194 Self::Up => "`▲`",
195 Self::Down => "`▼`",
196 Self::Left => "`◀`",
197 Self::Right => "`▶`",
198 Self::Asterisk => "`*`",
199 }
200 }
201}
202
203impl ::re_byte_size::SizeBytes for MarkerShape {
204 #[inline]
205 fn heap_size_bytes(&self) -> u64 {
206 0
207 }
208
209 #[inline]
210 fn is_pod() -> bool {
211 true
212 }
213}