re_types/archetypes/
recording_info.rs1#![allow(unused_braces)]
5#![allow(unused_imports)]
6#![allow(unused_parens)]
7#![allow(clippy::allow_attributes)]
8#![allow(clippy::clone_on_copy)]
9#![allow(clippy::cloned_instead_of_copied)]
10#![allow(clippy::map_flatten)]
11#![allow(clippy::needless_question_mark)]
12#![allow(clippy::new_without_default)]
13#![allow(clippy::redundant_closure)]
14#![allow(clippy::too_many_arguments)]
15#![allow(clippy::too_many_lines)]
16#![allow(clippy::wildcard_imports)]
17
18use ::re_types_core::SerializationResult;
19use ::re_types_core::try_serialize_field;
20use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
21use ::re_types_core::{ComponentDescriptor, ComponentType};
22use ::re_types_core::{DeserializationError, DeserializationResult};
23
24#[derive(Clone, Debug, Default)]
26pub struct RecordingInfo {
27 pub start_time: Option<SerializedComponentBatch>,
31
32 pub name: Option<SerializedComponentBatch>,
34}
35
36impl RecordingInfo {
37 #[inline]
41 pub fn descriptor_start_time() -> ComponentDescriptor {
42 ComponentDescriptor {
43 archetype: Some("rerun.archetypes.RecordingInfo".into()),
44 component: "RecordingInfo:start_time".into(),
45 component_type: Some("rerun.components.Timestamp".into()),
46 }
47 }
48
49 #[inline]
53 pub fn descriptor_name() -> ComponentDescriptor {
54 ComponentDescriptor {
55 archetype: Some("rerun.archetypes.RecordingInfo".into()),
56 component: "RecordingInfo:name".into(),
57 component_type: Some("rerun.components.Name".into()),
58 }
59 }
60}
61
62static REQUIRED_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 0usize]> =
63 std::sync::LazyLock::new(|| []);
64
65static RECOMMENDED_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 0usize]> =
66 std::sync::LazyLock::new(|| []);
67
68static OPTIONAL_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 2usize]> =
69 std::sync::LazyLock::new(|| {
70 [
71 RecordingInfo::descriptor_start_time(),
72 RecordingInfo::descriptor_name(),
73 ]
74 });
75
76static ALL_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 2usize]> =
77 std::sync::LazyLock::new(|| {
78 [
79 RecordingInfo::descriptor_start_time(),
80 RecordingInfo::descriptor_name(),
81 ]
82 });
83
84impl RecordingInfo {
85 pub const NUM_COMPONENTS: usize = 2usize;
87}
88
89impl ::re_types_core::Archetype for RecordingInfo {
90 #[inline]
91 fn name() -> ::re_types_core::ArchetypeName {
92 "rerun.archetypes.RecordingInfo".into()
93 }
94
95 #[inline]
96 fn display_name() -> &'static str {
97 "Recording info"
98 }
99
100 #[inline]
101 fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
102 REQUIRED_COMPONENTS.as_slice().into()
103 }
104
105 #[inline]
106 fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
107 RECOMMENDED_COMPONENTS.as_slice().into()
108 }
109
110 #[inline]
111 fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
112 OPTIONAL_COMPONENTS.as_slice().into()
113 }
114
115 #[inline]
116 fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
117 ALL_COMPONENTS.as_slice().into()
118 }
119
120 #[inline]
121 fn from_arrow_components(
122 arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
123 ) -> DeserializationResult<Self> {
124 re_tracing::profile_function!();
125 use ::re_types_core::{Loggable as _, ResultExt as _};
126 let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
127 let start_time = arrays_by_descr
128 .get(&Self::descriptor_start_time())
129 .map(|array| {
130 SerializedComponentBatch::new(array.clone(), Self::descriptor_start_time())
131 });
132 let name = arrays_by_descr
133 .get(&Self::descriptor_name())
134 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_name()));
135 Ok(Self { start_time, name })
136 }
137}
138
139impl ::re_types_core::AsComponents for RecordingInfo {
140 #[inline]
141 fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
142 use ::re_types_core::Archetype as _;
143 [self.start_time.clone(), self.name.clone()]
144 .into_iter()
145 .flatten()
146 .collect()
147 }
148}
149
150impl ::re_types_core::ArchetypeReflectionMarker for RecordingInfo {}
151
152impl RecordingInfo {
153 #[inline]
155 pub fn new() -> Self {
156 Self {
157 start_time: None,
158 name: None,
159 }
160 }
161
162 #[inline]
164 pub fn update_fields() -> Self {
165 Self::default()
166 }
167
168 #[inline]
170 pub fn clear_fields() -> Self {
171 use ::re_types_core::Loggable as _;
172 Self {
173 start_time: Some(SerializedComponentBatch::new(
174 crate::components::Timestamp::arrow_empty(),
175 Self::descriptor_start_time(),
176 )),
177 name: Some(SerializedComponentBatch::new(
178 crate::components::Name::arrow_empty(),
179 Self::descriptor_name(),
180 )),
181 }
182 }
183
184 #[inline]
195 pub fn columns<I>(
196 self,
197 _lengths: I,
198 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
199 where
200 I: IntoIterator<Item = usize> + Clone,
201 {
202 let columns = [
203 self.start_time
204 .map(|start_time| start_time.partitioned(_lengths.clone()))
205 .transpose()?,
206 self.name
207 .map(|name| name.partitioned(_lengths.clone()))
208 .transpose()?,
209 ];
210 Ok(columns.into_iter().flatten())
211 }
212
213 #[inline]
218 pub fn columns_of_unit_batches(
219 self,
220 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
221 let len_start_time = self.start_time.as_ref().map(|b| b.array.len());
222 let len_name = self.name.as_ref().map(|b| b.array.len());
223 let len = None.or(len_start_time).or(len_name).unwrap_or(0);
224 self.columns(std::iter::repeat_n(1, len))
225 }
226
227 #[inline]
231 pub fn with_start_time(mut self, start_time: impl Into<crate::components::Timestamp>) -> Self {
232 self.start_time = try_serialize_field(Self::descriptor_start_time(), [start_time]);
233 self
234 }
235
236 #[inline]
241 pub fn with_many_start_time(
242 mut self,
243 start_time: impl IntoIterator<Item = impl Into<crate::components::Timestamp>>,
244 ) -> Self {
245 self.start_time = try_serialize_field(Self::descriptor_start_time(), start_time);
246 self
247 }
248
249 #[inline]
251 pub fn with_name(mut self, name: impl Into<crate::components::Name>) -> Self {
252 self.name = try_serialize_field(Self::descriptor_name(), [name]);
253 self
254 }
255
256 #[inline]
261 pub fn with_many_name(
262 mut self,
263 name: impl IntoIterator<Item = impl Into<crate::components::Name>>,
264 ) -> Self {
265 self.name = try_serialize_field(Self::descriptor_name(), name);
266 self
267 }
268}
269
270impl ::re_byte_size::SizeBytes for RecordingInfo {
271 #[inline]
272 fn heap_size_bytes(&self) -> u64 {
273 self.start_time.heap_size_bytes() + self.name.heap_size_bytes()
274 }
275}