re_types/archetypes/
geo_line_strings.rs1#![allow(unused_braces)]
5#![allow(unused_imports)]
6#![allow(unused_parens)]
7#![allow(clippy::clone_on_copy)]
8#![allow(clippy::cloned_instead_of_copied)]
9#![allow(clippy::map_flatten)]
10#![allow(clippy::needless_question_mark)]
11#![allow(clippy::new_without_default)]
12#![allow(clippy::redundant_closure)]
13#![allow(clippy::too_many_arguments)]
14#![allow(clippy::too_many_lines)]
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, ComponentType};
20use ::re_types_core::{DeserializationError, DeserializationResult};
21
22#[derive(Clone, Debug, PartialEq, Default)]
59pub struct GeoLineStrings {
60 pub line_strings: Option<SerializedComponentBatch>,
62
63 pub radii: Option<SerializedComponentBatch>,
68
69 pub colors: Option<SerializedComponentBatch>,
71}
72
73impl GeoLineStrings {
74 #[inline]
78 pub fn descriptor_line_strings() -> ComponentDescriptor {
79 ComponentDescriptor {
80 archetype: Some("rerun.archetypes.GeoLineStrings".into()),
81 component: "GeoLineStrings:line_strings".into(),
82 component_type: Some("rerun.components.GeoLineString".into()),
83 }
84 }
85
86 #[inline]
90 pub fn descriptor_radii() -> ComponentDescriptor {
91 ComponentDescriptor {
92 archetype: Some("rerun.archetypes.GeoLineStrings".into()),
93 component: "GeoLineStrings:radii".into(),
94 component_type: Some("rerun.components.Radius".into()),
95 }
96 }
97
98 #[inline]
102 pub fn descriptor_colors() -> ComponentDescriptor {
103 ComponentDescriptor {
104 archetype: Some("rerun.archetypes.GeoLineStrings".into()),
105 component: "GeoLineStrings:colors".into(),
106 component_type: Some("rerun.components.Color".into()),
107 }
108 }
109}
110
111static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
112 once_cell::sync::Lazy::new(|| [GeoLineStrings::descriptor_line_strings()]);
113
114static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> =
115 once_cell::sync::Lazy::new(|| {
116 [
117 GeoLineStrings::descriptor_radii(),
118 GeoLineStrings::descriptor_colors(),
119 ]
120 });
121
122static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
123 once_cell::sync::Lazy::new(|| []);
124
125static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 3usize]> =
126 once_cell::sync::Lazy::new(|| {
127 [
128 GeoLineStrings::descriptor_line_strings(),
129 GeoLineStrings::descriptor_radii(),
130 GeoLineStrings::descriptor_colors(),
131 ]
132 });
133
134impl GeoLineStrings {
135 pub const NUM_COMPONENTS: usize = 3usize;
137}
138
139impl ::re_types_core::Archetype for GeoLineStrings {
140 #[inline]
141 fn name() -> ::re_types_core::ArchetypeName {
142 "rerun.archetypes.GeoLineStrings".into()
143 }
144
145 #[inline]
146 fn display_name() -> &'static str {
147 "Geo line strings"
148 }
149
150 #[inline]
151 fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
152 REQUIRED_COMPONENTS.as_slice().into()
153 }
154
155 #[inline]
156 fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
157 RECOMMENDED_COMPONENTS.as_slice().into()
158 }
159
160 #[inline]
161 fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
162 OPTIONAL_COMPONENTS.as_slice().into()
163 }
164
165 #[inline]
166 fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
167 ALL_COMPONENTS.as_slice().into()
168 }
169
170 #[inline]
171 fn from_arrow_components(
172 arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
173 ) -> DeserializationResult<Self> {
174 re_tracing::profile_function!();
175 use ::re_types_core::{Loggable as _, ResultExt as _};
176 let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
177 let line_strings = arrays_by_descr
178 .get(&Self::descriptor_line_strings())
179 .map(|array| {
180 SerializedComponentBatch::new(array.clone(), Self::descriptor_line_strings())
181 });
182 let radii = arrays_by_descr
183 .get(&Self::descriptor_radii())
184 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_radii()));
185 let colors = arrays_by_descr
186 .get(&Self::descriptor_colors())
187 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_colors()));
188 Ok(Self {
189 line_strings,
190 radii,
191 colors,
192 })
193 }
194}
195
196impl ::re_types_core::AsComponents for GeoLineStrings {
197 #[inline]
198 fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
199 use ::re_types_core::Archetype as _;
200 [
201 self.line_strings.clone(),
202 self.radii.clone(),
203 self.colors.clone(),
204 ]
205 .into_iter()
206 .flatten()
207 .collect()
208 }
209}
210
211impl ::re_types_core::ArchetypeReflectionMarker for GeoLineStrings {}
212
213impl GeoLineStrings {
214 #[inline]
216 pub(crate) fn new(
217 line_strings: impl IntoIterator<Item = impl Into<crate::components::GeoLineString>>,
218 ) -> Self {
219 Self {
220 line_strings: try_serialize_field(Self::descriptor_line_strings(), line_strings),
221 radii: None,
222 colors: None,
223 }
224 }
225
226 #[inline]
228 pub fn update_fields() -> Self {
229 Self::default()
230 }
231
232 #[inline]
234 pub fn clear_fields() -> Self {
235 use ::re_types_core::Loggable as _;
236 Self {
237 line_strings: Some(SerializedComponentBatch::new(
238 crate::components::GeoLineString::arrow_empty(),
239 Self::descriptor_line_strings(),
240 )),
241 radii: Some(SerializedComponentBatch::new(
242 crate::components::Radius::arrow_empty(),
243 Self::descriptor_radii(),
244 )),
245 colors: Some(SerializedComponentBatch::new(
246 crate::components::Color::arrow_empty(),
247 Self::descriptor_colors(),
248 )),
249 }
250 }
251
252 #[inline]
263 pub fn columns<I>(
264 self,
265 _lengths: I,
266 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
267 where
268 I: IntoIterator<Item = usize> + Clone,
269 {
270 let columns = [
271 self.line_strings
272 .map(|line_strings| line_strings.partitioned(_lengths.clone()))
273 .transpose()?,
274 self.radii
275 .map(|radii| radii.partitioned(_lengths.clone()))
276 .transpose()?,
277 self.colors
278 .map(|colors| colors.partitioned(_lengths.clone()))
279 .transpose()?,
280 ];
281 Ok(columns.into_iter().flatten())
282 }
283
284 #[inline]
289 pub fn columns_of_unit_batches(
290 self,
291 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
292 let len_line_strings = self.line_strings.as_ref().map(|b| b.array.len());
293 let len_radii = self.radii.as_ref().map(|b| b.array.len());
294 let len_colors = self.colors.as_ref().map(|b| b.array.len());
295 let len = None
296 .or(len_line_strings)
297 .or(len_radii)
298 .or(len_colors)
299 .unwrap_or(0);
300 self.columns(std::iter::repeat(1).take(len))
301 }
302
303 #[inline]
305 pub fn with_line_strings(
306 mut self,
307 line_strings: impl IntoIterator<Item = impl Into<crate::components::GeoLineString>>,
308 ) -> Self {
309 self.line_strings = try_serialize_field(Self::descriptor_line_strings(), line_strings);
310 self
311 }
312
313 #[inline]
318 pub fn with_radii(
319 mut self,
320 radii: impl IntoIterator<Item = impl Into<crate::components::Radius>>,
321 ) -> Self {
322 self.radii = try_serialize_field(Self::descriptor_radii(), radii);
323 self
324 }
325
326 #[inline]
328 pub fn with_colors(
329 mut self,
330 colors: impl IntoIterator<Item = impl Into<crate::components::Color>>,
331 ) -> Self {
332 self.colors = try_serialize_field(Self::descriptor_colors(), colors);
333 self
334 }
335}
336
337impl ::re_byte_size::SizeBytes for GeoLineStrings {
338 #[inline]
339 fn heap_size_bytes(&self) -> u64 {
340 self.line_strings.heap_size_bytes()
341 + self.radii.heap_size_bytes()
342 + self.colors.heap_size_bytes()
343 }
344}