re_types/archetypes/
asset3d.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::SerializationResult;
17use ::re_types_core::try_serialize_field;
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 Asset3D {
60 pub blob: Option<SerializedComponentBatch>,
62
63 pub media_type: Option<SerializedComponentBatch>,
74
75 pub albedo_factor: Option<SerializedComponentBatch>,
80}
81
82impl Asset3D {
83 #[inline]
87 pub fn descriptor_blob() -> ComponentDescriptor {
88 ComponentDescriptor {
89 archetype: Some("rerun.archetypes.Asset3D".into()),
90 component: "Asset3D:blob".into(),
91 component_type: Some("rerun.components.Blob".into()),
92 }
93 }
94
95 #[inline]
99 pub fn descriptor_media_type() -> ComponentDescriptor {
100 ComponentDescriptor {
101 archetype: Some("rerun.archetypes.Asset3D".into()),
102 component: "Asset3D:media_type".into(),
103 component_type: Some("rerun.components.MediaType".into()),
104 }
105 }
106
107 #[inline]
111 pub fn descriptor_albedo_factor() -> ComponentDescriptor {
112 ComponentDescriptor {
113 archetype: Some("rerun.archetypes.Asset3D".into()),
114 component: "Asset3D:albedo_factor".into(),
115 component_type: Some("rerun.components.AlbedoFactor".into()),
116 }
117 }
118}
119
120static REQUIRED_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 1usize]> =
121 std::sync::LazyLock::new(|| [Asset3D::descriptor_blob()]);
122
123static RECOMMENDED_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 1usize]> =
124 std::sync::LazyLock::new(|| [Asset3D::descriptor_media_type()]);
125
126static OPTIONAL_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 1usize]> =
127 std::sync::LazyLock::new(|| [Asset3D::descriptor_albedo_factor()]);
128
129static ALL_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 3usize]> =
130 std::sync::LazyLock::new(|| {
131 [
132 Asset3D::descriptor_blob(),
133 Asset3D::descriptor_media_type(),
134 Asset3D::descriptor_albedo_factor(),
135 ]
136 });
137
138impl Asset3D {
139 pub const NUM_COMPONENTS: usize = 3usize;
141}
142
143impl ::re_types_core::Archetype for Asset3D {
144 #[inline]
145 fn name() -> ::re_types_core::ArchetypeName {
146 "rerun.archetypes.Asset3D".into()
147 }
148
149 #[inline]
150 fn display_name() -> &'static str {
151 "Asset 3D"
152 }
153
154 #[inline]
155 fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
156 REQUIRED_COMPONENTS.as_slice().into()
157 }
158
159 #[inline]
160 fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
161 RECOMMENDED_COMPONENTS.as_slice().into()
162 }
163
164 #[inline]
165 fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
166 OPTIONAL_COMPONENTS.as_slice().into()
167 }
168
169 #[inline]
170 fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
171 ALL_COMPONENTS.as_slice().into()
172 }
173
174 #[inline]
175 fn from_arrow_components(
176 arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
177 ) -> DeserializationResult<Self> {
178 re_tracing::profile_function!();
179 use ::re_types_core::{Loggable as _, ResultExt as _};
180 let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
181 let blob = arrays_by_descr
182 .get(&Self::descriptor_blob())
183 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_blob()));
184 let media_type = arrays_by_descr
185 .get(&Self::descriptor_media_type())
186 .map(|array| {
187 SerializedComponentBatch::new(array.clone(), Self::descriptor_media_type())
188 });
189 let albedo_factor = arrays_by_descr
190 .get(&Self::descriptor_albedo_factor())
191 .map(|array| {
192 SerializedComponentBatch::new(array.clone(), Self::descriptor_albedo_factor())
193 });
194 Ok(Self {
195 blob,
196 media_type,
197 albedo_factor,
198 })
199 }
200}
201
202impl ::re_types_core::AsComponents for Asset3D {
203 #[inline]
204 fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
205 use ::re_types_core::Archetype as _;
206 [
207 self.blob.clone(),
208 self.media_type.clone(),
209 self.albedo_factor.clone(),
210 ]
211 .into_iter()
212 .flatten()
213 .collect()
214 }
215}
216
217impl ::re_types_core::ArchetypeReflectionMarker for Asset3D {}
218
219impl Asset3D {
220 #[inline]
222 pub fn new(blob: impl Into<crate::components::Blob>) -> Self {
223 Self {
224 blob: try_serialize_field(Self::descriptor_blob(), [blob]),
225 media_type: None,
226 albedo_factor: None,
227 }
228 }
229
230 #[inline]
232 pub fn update_fields() -> Self {
233 Self::default()
234 }
235
236 #[inline]
238 pub fn clear_fields() -> Self {
239 use ::re_types_core::Loggable as _;
240 Self {
241 blob: Some(SerializedComponentBatch::new(
242 crate::components::Blob::arrow_empty(),
243 Self::descriptor_blob(),
244 )),
245 media_type: Some(SerializedComponentBatch::new(
246 crate::components::MediaType::arrow_empty(),
247 Self::descriptor_media_type(),
248 )),
249 albedo_factor: Some(SerializedComponentBatch::new(
250 crate::components::AlbedoFactor::arrow_empty(),
251 Self::descriptor_albedo_factor(),
252 )),
253 }
254 }
255
256 #[inline]
267 pub fn columns<I>(
268 self,
269 _lengths: I,
270 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
271 where
272 I: IntoIterator<Item = usize> + Clone,
273 {
274 let columns = [
275 self.blob
276 .map(|blob| blob.partitioned(_lengths.clone()))
277 .transpose()?,
278 self.media_type
279 .map(|media_type| media_type.partitioned(_lengths.clone()))
280 .transpose()?,
281 self.albedo_factor
282 .map(|albedo_factor| albedo_factor.partitioned(_lengths.clone()))
283 .transpose()?,
284 ];
285 Ok(columns.into_iter().flatten())
286 }
287
288 #[inline]
293 pub fn columns_of_unit_batches(
294 self,
295 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
296 let len_blob = self.blob.as_ref().map(|b| b.array.len());
297 let len_media_type = self.media_type.as_ref().map(|b| b.array.len());
298 let len_albedo_factor = self.albedo_factor.as_ref().map(|b| b.array.len());
299 let len = None
300 .or(len_blob)
301 .or(len_media_type)
302 .or(len_albedo_factor)
303 .unwrap_or(0);
304 self.columns(std::iter::repeat_n(1, len))
305 }
306
307 #[inline]
309 pub fn with_blob(mut self, blob: impl Into<crate::components::Blob>) -> Self {
310 self.blob = try_serialize_field(Self::descriptor_blob(), [blob]);
311 self
312 }
313
314 #[inline]
319 pub fn with_many_blob(
320 mut self,
321 blob: impl IntoIterator<Item = impl Into<crate::components::Blob>>,
322 ) -> Self {
323 self.blob = try_serialize_field(Self::descriptor_blob(), blob);
324 self
325 }
326
327 #[inline]
338 pub fn with_media_type(mut self, media_type: impl Into<crate::components::MediaType>) -> Self {
339 self.media_type = try_serialize_field(Self::descriptor_media_type(), [media_type]);
340 self
341 }
342
343 #[inline]
348 pub fn with_many_media_type(
349 mut self,
350 media_type: impl IntoIterator<Item = impl Into<crate::components::MediaType>>,
351 ) -> Self {
352 self.media_type = try_serialize_field(Self::descriptor_media_type(), media_type);
353 self
354 }
355
356 #[inline]
361 pub fn with_albedo_factor(
362 mut self,
363 albedo_factor: impl Into<crate::components::AlbedoFactor>,
364 ) -> Self {
365 self.albedo_factor = try_serialize_field(Self::descriptor_albedo_factor(), [albedo_factor]);
366 self
367 }
368
369 #[inline]
374 pub fn with_many_albedo_factor(
375 mut self,
376 albedo_factor: impl IntoIterator<Item = impl Into<crate::components::AlbedoFactor>>,
377 ) -> Self {
378 self.albedo_factor = try_serialize_field(Self::descriptor_albedo_factor(), albedo_factor);
379 self
380 }
381}
382
383impl ::re_byte_size::SizeBytes for Asset3D {
384 #[inline]
385 fn heap_size_bytes(&self) -> u64 {
386 self.blob.heap_size_bytes()
387 + self.media_type.heap_size_bytes()
388 + self.albedo_factor.heap_size_bytes()
389 }
390}