re_types/blueprint/archetypes/
force_position.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)]
26pub struct ForcePosition {
27 pub enabled: Option<SerializedComponentBatch>,
31
32 pub strength: Option<SerializedComponentBatch>,
34
35 pub position: Option<SerializedComponentBatch>,
37}
38
39impl ForcePosition {
40 #[inline]
44 pub fn descriptor_enabled() -> ComponentDescriptor {
45 ComponentDescriptor {
46 archetype: Some("rerun.blueprint.archetypes.ForcePosition".into()),
47 component: "ForcePosition:enabled".into(),
48 component_type: Some("rerun.blueprint.components.Enabled".into()),
49 }
50 }
51
52 #[inline]
56 pub fn descriptor_strength() -> ComponentDescriptor {
57 ComponentDescriptor {
58 archetype: Some("rerun.blueprint.archetypes.ForcePosition".into()),
59 component: "ForcePosition:strength".into(),
60 component_type: Some("rerun.blueprint.components.ForceStrength".into()),
61 }
62 }
63
64 #[inline]
68 pub fn descriptor_position() -> ComponentDescriptor {
69 ComponentDescriptor {
70 archetype: Some("rerun.blueprint.archetypes.ForcePosition".into()),
71 component: "ForcePosition:position".into(),
72 component_type: Some("rerun.components.Position2D".into()),
73 }
74 }
75}
76
77static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
78 once_cell::sync::Lazy::new(|| []);
79
80static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
81 once_cell::sync::Lazy::new(|| []);
82
83static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 3usize]> =
84 once_cell::sync::Lazy::new(|| {
85 [
86 ForcePosition::descriptor_enabled(),
87 ForcePosition::descriptor_strength(),
88 ForcePosition::descriptor_position(),
89 ]
90 });
91
92static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 3usize]> =
93 once_cell::sync::Lazy::new(|| {
94 [
95 ForcePosition::descriptor_enabled(),
96 ForcePosition::descriptor_strength(),
97 ForcePosition::descriptor_position(),
98 ]
99 });
100
101impl ForcePosition {
102 pub const NUM_COMPONENTS: usize = 3usize;
104}
105
106impl ::re_types_core::Archetype for ForcePosition {
107 #[inline]
108 fn name() -> ::re_types_core::ArchetypeName {
109 "rerun.blueprint.archetypes.ForcePosition".into()
110 }
111
112 #[inline]
113 fn display_name() -> &'static str {
114 "Force position"
115 }
116
117 #[inline]
118 fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
119 REQUIRED_COMPONENTS.as_slice().into()
120 }
121
122 #[inline]
123 fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
124 RECOMMENDED_COMPONENTS.as_slice().into()
125 }
126
127 #[inline]
128 fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
129 OPTIONAL_COMPONENTS.as_slice().into()
130 }
131
132 #[inline]
133 fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
134 ALL_COMPONENTS.as_slice().into()
135 }
136
137 #[inline]
138 fn from_arrow_components(
139 arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
140 ) -> DeserializationResult<Self> {
141 re_tracing::profile_function!();
142 use ::re_types_core::{Loggable as _, ResultExt as _};
143 let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
144 let enabled = arrays_by_descr
145 .get(&Self::descriptor_enabled())
146 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_enabled()));
147 let strength = arrays_by_descr
148 .get(&Self::descriptor_strength())
149 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_strength()));
150 let position = arrays_by_descr
151 .get(&Self::descriptor_position())
152 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_position()));
153 Ok(Self {
154 enabled,
155 strength,
156 position,
157 })
158 }
159}
160
161impl ::re_types_core::AsComponents for ForcePosition {
162 #[inline]
163 fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
164 use ::re_types_core::Archetype as _;
165 [
166 self.enabled.clone(),
167 self.strength.clone(),
168 self.position.clone(),
169 ]
170 .into_iter()
171 .flatten()
172 .collect()
173 }
174}
175
176impl ::re_types_core::ArchetypeReflectionMarker for ForcePosition {}
177
178impl ForcePosition {
179 #[inline]
181 pub fn new() -> Self {
182 Self {
183 enabled: None,
184 strength: None,
185 position: None,
186 }
187 }
188
189 #[inline]
191 pub fn update_fields() -> Self {
192 Self::default()
193 }
194
195 #[inline]
197 pub fn clear_fields() -> Self {
198 use ::re_types_core::Loggable as _;
199 Self {
200 enabled: Some(SerializedComponentBatch::new(
201 crate::blueprint::components::Enabled::arrow_empty(),
202 Self::descriptor_enabled(),
203 )),
204 strength: Some(SerializedComponentBatch::new(
205 crate::blueprint::components::ForceStrength::arrow_empty(),
206 Self::descriptor_strength(),
207 )),
208 position: Some(SerializedComponentBatch::new(
209 crate::components::Position2D::arrow_empty(),
210 Self::descriptor_position(),
211 )),
212 }
213 }
214
215 #[inline]
219 pub fn with_enabled(
220 mut self,
221 enabled: impl Into<crate::blueprint::components::Enabled>,
222 ) -> Self {
223 self.enabled = try_serialize_field(Self::descriptor_enabled(), [enabled]);
224 self
225 }
226
227 #[inline]
229 pub fn with_strength(
230 mut self,
231 strength: impl Into<crate::blueprint::components::ForceStrength>,
232 ) -> Self {
233 self.strength = try_serialize_field(Self::descriptor_strength(), [strength]);
234 self
235 }
236
237 #[inline]
239 pub fn with_position(mut self, position: impl Into<crate::components::Position2D>) -> Self {
240 self.position = try_serialize_field(Self::descriptor_position(), [position]);
241 self
242 }
243}
244
245impl ::re_byte_size::SizeBytes for ForcePosition {
246 #[inline]
247 fn heap_size_bytes(&self) -> u64 {
248 self.enabled.heap_size_bytes()
249 + self.strength.heap_size_bytes()
250 + self.position.heap_size_bytes()
251 }
252}