re_types/blueprint/components/
panel_state.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#![allow(non_camel_case_types)]
16
17use ::re_types_core::try_serialize_field;
18use ::re_types_core::SerializationResult;
19use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
20use ::re_types_core::{ComponentDescriptor, ComponentType};
21use ::re_types_core::{DeserializationError, DeserializationResult};
22
23#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Default)]
25#[repr(u8)]
26pub enum PanelState {
27 Hidden = 1,
29
30 Collapsed = 2,
32
33 #[default]
35 Expanded = 3,
36}
37
38impl ::re_types_core::Component for PanelState {
39 #[inline]
40 fn name() -> ComponentType {
41 "rerun.blueprint.components.PanelState".into()
42 }
43}
44
45::re_types_core::macros::impl_into_cow!(PanelState);
46
47impl ::re_types_core::Loggable for PanelState {
48 #[inline]
49 fn arrow_datatype() -> arrow::datatypes::DataType {
50 #![allow(clippy::wildcard_imports)]
51 use arrow::datatypes::*;
52 DataType::UInt8
53 }
54
55 fn to_arrow_opt<'a>(
56 data: impl IntoIterator<Item = Option<impl Into<::std::borrow::Cow<'a, Self>>>>,
57 ) -> SerializationResult<arrow::array::ArrayRef>
58 where
59 Self: Clone + 'a,
60 {
61 #![allow(clippy::wildcard_imports)]
62 #![allow(clippy::manual_is_variant_and)]
63 use ::re_types_core::{arrow_helpers::as_array_ref, Loggable as _, ResultExt as _};
64 use arrow::{array::*, buffer::*, datatypes::*};
65 Ok({
66 let (somes, data0): (Vec<_>, Vec<_>) = data
67 .into_iter()
68 .map(|datum| {
69 let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into);
70 let datum = datum.map(|datum| *datum as u8);
71 (datum.is_some(), datum)
72 })
73 .unzip();
74 let data0_validity: Option<arrow::buffer::NullBuffer> = {
75 let any_nones = somes.iter().any(|some| !*some);
76 any_nones.then(|| somes.into())
77 };
78 as_array_ref(PrimitiveArray::<UInt8Type>::new(
79 ScalarBuffer::from(
80 data0
81 .into_iter()
82 .map(|v| v.unwrap_or_default())
83 .collect::<Vec<_>>(),
84 ),
85 data0_validity,
86 ))
87 })
88 }
89
90 fn from_arrow_opt(
91 arrow_data: &dyn arrow::array::Array,
92 ) -> DeserializationResult<Vec<Option<Self>>>
93 where
94 Self: Sized,
95 {
96 #![allow(clippy::wildcard_imports)]
97 use ::re_types_core::{arrow_zip_validity::ZipValidity, Loggable as _, ResultExt as _};
98 use arrow::{array::*, buffer::*, datatypes::*};
99 Ok(arrow_data
100 .as_any()
101 .downcast_ref::<UInt8Array>()
102 .ok_or_else(|| {
103 let expected = Self::arrow_datatype();
104 let actual = arrow_data.data_type().clone();
105 DeserializationError::datatype_mismatch(expected, actual)
106 })
107 .with_context("rerun.blueprint.components.PanelState#enum")?
108 .into_iter()
109 .map(|typ| match typ {
110 Some(1) => Ok(Some(Self::Hidden)),
111 Some(2) => Ok(Some(Self::Collapsed)),
112 Some(3) => Ok(Some(Self::Expanded)),
113 None => Ok(None),
114 Some(invalid) => Err(DeserializationError::missing_union_arm(
115 Self::arrow_datatype(),
116 "<invalid>",
117 invalid as _,
118 )),
119 })
120 .collect::<DeserializationResult<Vec<Option<_>>>>()
121 .with_context("rerun.blueprint.components.PanelState")?)
122 }
123}
124
125impl std::fmt::Display for PanelState {
126 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
127 match self {
128 Self::Hidden => write!(f, "Hidden"),
129 Self::Collapsed => write!(f, "Collapsed"),
130 Self::Expanded => write!(f, "Expanded"),
131 }
132 }
133}
134
135impl ::re_types_core::reflection::Enum for PanelState {
136 #[inline]
137 fn variants() -> &'static [Self] {
138 &[Self::Hidden, Self::Collapsed, Self::Expanded]
139 }
140
141 #[inline]
142 fn docstring_md(self) -> &'static str {
143 match self {
144 Self::Hidden => "Completely hidden.",
145 Self::Collapsed => "Visible, but as small as possible on its shorter axis.",
146 Self::Expanded => "Fully expanded.",
147 }
148 }
149}
150
151impl ::re_byte_size::SizeBytes for PanelState {
152 #[inline]
153 fn heap_size_bytes(&self) -> u64 {
154 0
155 }
156
157 #[inline]
158 fn is_pod() -> bool {
159 true
160 }
161}