re_types/blueprint/archetypes/
background.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 Background {
27 pub kind: Option<SerializedComponentBatch>,
29
30 pub color: Option<SerializedComponentBatch>,
32}
33
34impl Background {
35 #[inline]
39 pub fn descriptor_kind() -> ComponentDescriptor {
40 ComponentDescriptor {
41 archetype: Some("rerun.blueprint.archetypes.Background".into()),
42 component: "Background:kind".into(),
43 component_type: Some("rerun.blueprint.components.BackgroundKind".into()),
44 }
45 }
46
47 #[inline]
51 pub fn descriptor_color() -> ComponentDescriptor {
52 ComponentDescriptor {
53 archetype: Some("rerun.blueprint.archetypes.Background".into()),
54 component: "Background:color".into(),
55 component_type: Some("rerun.components.Color".into()),
56 }
57 }
58}
59
60static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
61 once_cell::sync::Lazy::new(|| [Background::descriptor_kind()]);
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; 1usize]> =
67 once_cell::sync::Lazy::new(|| [Background::descriptor_color()]);
68
69static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> =
70 once_cell::sync::Lazy::new(|| {
71 [
72 Background::descriptor_kind(),
73 Background::descriptor_color(),
74 ]
75 });
76
77impl Background {
78 pub const NUM_COMPONENTS: usize = 2usize;
80}
81
82impl ::re_types_core::Archetype for Background {
83 #[inline]
84 fn name() -> ::re_types_core::ArchetypeName {
85 "rerun.blueprint.archetypes.Background".into()
86 }
87
88 #[inline]
89 fn display_name() -> &'static str {
90 "Background"
91 }
92
93 #[inline]
94 fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
95 REQUIRED_COMPONENTS.as_slice().into()
96 }
97
98 #[inline]
99 fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
100 RECOMMENDED_COMPONENTS.as_slice().into()
101 }
102
103 #[inline]
104 fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
105 OPTIONAL_COMPONENTS.as_slice().into()
106 }
107
108 #[inline]
109 fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
110 ALL_COMPONENTS.as_slice().into()
111 }
112
113 #[inline]
114 fn from_arrow_components(
115 arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
116 ) -> DeserializationResult<Self> {
117 re_tracing::profile_function!();
118 use ::re_types_core::{Loggable as _, ResultExt as _};
119 let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
120 let kind = arrays_by_descr
121 .get(&Self::descriptor_kind())
122 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_kind()));
123 let color = arrays_by_descr
124 .get(&Self::descriptor_color())
125 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_color()));
126 Ok(Self { kind, color })
127 }
128}
129
130impl ::re_types_core::AsComponents for Background {
131 #[inline]
132 fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
133 use ::re_types_core::Archetype as _;
134 [self.kind.clone(), self.color.clone()]
135 .into_iter()
136 .flatten()
137 .collect()
138 }
139}
140
141impl ::re_types_core::ArchetypeReflectionMarker for Background {}
142
143impl Background {
144 #[inline]
146 pub fn new(kind: impl Into<crate::blueprint::components::BackgroundKind>) -> Self {
147 Self {
148 kind: try_serialize_field(Self::descriptor_kind(), [kind]),
149 color: None,
150 }
151 }
152
153 #[inline]
155 pub fn update_fields() -> Self {
156 Self::default()
157 }
158
159 #[inline]
161 pub fn clear_fields() -> Self {
162 use ::re_types_core::Loggable as _;
163 Self {
164 kind: Some(SerializedComponentBatch::new(
165 crate::blueprint::components::BackgroundKind::arrow_empty(),
166 Self::descriptor_kind(),
167 )),
168 color: Some(SerializedComponentBatch::new(
169 crate::components::Color::arrow_empty(),
170 Self::descriptor_color(),
171 )),
172 }
173 }
174
175 #[inline]
177 pub fn with_kind(
178 mut self,
179 kind: impl Into<crate::blueprint::components::BackgroundKind>,
180 ) -> Self {
181 self.kind = try_serialize_field(Self::descriptor_kind(), [kind]);
182 self
183 }
184
185 #[inline]
187 pub fn with_color(mut self, color: impl Into<crate::components::Color>) -> Self {
188 self.color = try_serialize_field(Self::descriptor_color(), [color]);
189 self
190 }
191}
192
193impl ::re_byte_size::SizeBytes for Background {
194 #[inline]
195 fn heap_size_bytes(&self) -> u64 {
196 self.kind.heap_size_bytes() + self.color.heap_size_bytes()
197 }
198}