re_types/archetypes/
recording_info.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, Default)]
24pub struct RecordingInfo {
25 pub start_time: Option<SerializedComponentBatch>,
29
30 pub name: Option<SerializedComponentBatch>,
32}
33
34impl RecordingInfo {
35 #[inline]
39 pub fn descriptor_start_time() -> ComponentDescriptor {
40 ComponentDescriptor {
41 archetype: Some("rerun.archetypes.RecordingInfo".into()),
42 component: "RecordingInfo:start_time".into(),
43 component_type: Some("rerun.components.Timestamp".into()),
44 }
45 }
46
47 #[inline]
51 pub fn descriptor_name() -> ComponentDescriptor {
52 ComponentDescriptor {
53 archetype: Some("rerun.archetypes.RecordingInfo".into()),
54 component: "RecordingInfo:name".into(),
55 component_type: Some("rerun.components.Name".into()),
56 }
57 }
58}
59
60static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
61 once_cell::sync::Lazy::new(|| []);
62
63static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
64 once_cell::sync::Lazy::new(|| []);
65
66static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> =
67 once_cell::sync::Lazy::new(|| {
68 [
69 RecordingInfo::descriptor_start_time(),
70 RecordingInfo::descriptor_name(),
71 ]
72 });
73
74static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> =
75 once_cell::sync::Lazy::new(|| {
76 [
77 RecordingInfo::descriptor_start_time(),
78 RecordingInfo::descriptor_name(),
79 ]
80 });
81
82impl RecordingInfo {
83 pub const NUM_COMPONENTS: usize = 2usize;
85}
86
87impl ::re_types_core::Archetype for RecordingInfo {
88 #[inline]
89 fn name() -> ::re_types_core::ArchetypeName {
90 "rerun.archetypes.RecordingInfo".into()
91 }
92
93 #[inline]
94 fn display_name() -> &'static str {
95 "Recording info"
96 }
97
98 #[inline]
99 fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
100 REQUIRED_COMPONENTS.as_slice().into()
101 }
102
103 #[inline]
104 fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
105 RECOMMENDED_COMPONENTS.as_slice().into()
106 }
107
108 #[inline]
109 fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
110 OPTIONAL_COMPONENTS.as_slice().into()
111 }
112
113 #[inline]
114 fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
115 ALL_COMPONENTS.as_slice().into()
116 }
117
118 #[inline]
119 fn from_arrow_components(
120 arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
121 ) -> DeserializationResult<Self> {
122 re_tracing::profile_function!();
123 use ::re_types_core::{Loggable as _, ResultExt as _};
124 let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
125 let start_time = arrays_by_descr
126 .get(&Self::descriptor_start_time())
127 .map(|array| {
128 SerializedComponentBatch::new(array.clone(), Self::descriptor_start_time())
129 });
130 let name = arrays_by_descr
131 .get(&Self::descriptor_name())
132 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_name()));
133 Ok(Self { start_time, name })
134 }
135}
136
137impl ::re_types_core::AsComponents for RecordingInfo {
138 #[inline]
139 fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
140 use ::re_types_core::Archetype as _;
141 [self.start_time.clone(), self.name.clone()]
142 .into_iter()
143 .flatten()
144 .collect()
145 }
146}
147
148impl ::re_types_core::ArchetypeReflectionMarker for RecordingInfo {}
149
150impl RecordingInfo {
151 #[inline]
153 pub fn new() -> Self {
154 Self {
155 start_time: None,
156 name: None,
157 }
158 }
159
160 #[inline]
162 pub fn update_fields() -> Self {
163 Self::default()
164 }
165
166 #[inline]
168 pub fn clear_fields() -> Self {
169 use ::re_types_core::Loggable as _;
170 Self {
171 start_time: Some(SerializedComponentBatch::new(
172 crate::components::Timestamp::arrow_empty(),
173 Self::descriptor_start_time(),
174 )),
175 name: Some(SerializedComponentBatch::new(
176 crate::components::Name::arrow_empty(),
177 Self::descriptor_name(),
178 )),
179 }
180 }
181
182 #[inline]
193 pub fn columns<I>(
194 self,
195 _lengths: I,
196 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
197 where
198 I: IntoIterator<Item = usize> + Clone,
199 {
200 let columns = [
201 self.start_time
202 .map(|start_time| start_time.partitioned(_lengths.clone()))
203 .transpose()?,
204 self.name
205 .map(|name| name.partitioned(_lengths.clone()))
206 .transpose()?,
207 ];
208 Ok(columns.into_iter().flatten())
209 }
210
211 #[inline]
216 pub fn columns_of_unit_batches(
217 self,
218 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
219 let len_start_time = self.start_time.as_ref().map(|b| b.array.len());
220 let len_name = self.name.as_ref().map(|b| b.array.len());
221 let len = None.or(len_start_time).or(len_name).unwrap_or(0);
222 self.columns(std::iter::repeat(1).take(len))
223 }
224
225 #[inline]
229 pub fn with_start_time(mut self, start_time: impl Into<crate::components::Timestamp>) -> Self {
230 self.start_time = try_serialize_field(Self::descriptor_start_time(), [start_time]);
231 self
232 }
233
234 #[inline]
239 pub fn with_many_start_time(
240 mut self,
241 start_time: impl IntoIterator<Item = impl Into<crate::components::Timestamp>>,
242 ) -> Self {
243 self.start_time = try_serialize_field(Self::descriptor_start_time(), start_time);
244 self
245 }
246
247 #[inline]
249 pub fn with_name(mut self, name: impl Into<crate::components::Name>) -> Self {
250 self.name = try_serialize_field(Self::descriptor_name(), [name]);
251 self
252 }
253
254 #[inline]
259 pub fn with_many_name(
260 mut self,
261 name: impl IntoIterator<Item = impl Into<crate::components::Name>>,
262 ) -> Self {
263 self.name = try_serialize_field(Self::descriptor_name(), name);
264 self
265 }
266}
267
268impl ::re_byte_size::SizeBytes for RecordingInfo {
269 #[inline]
270 fn heap_size_bytes(&self) -> u64 {
271 self.start_time.heap_size_bytes() + self.name.heap_size_bytes()
272 }
273}