re_types/blueprint/components/
panel_state.rs

1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs
2// Based on "crates/store/re_types/definitions/rerun/blueprint/components/panel_state.fbs".
3
4#![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#![allow(non_camel_case_types)]
18
19use ::re_types_core::SerializationResult;
20use ::re_types_core::try_serialize_field;
21use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
22use ::re_types_core::{ComponentDescriptor, ComponentType};
23use ::re_types_core::{DeserializationError, DeserializationResult};
24
25/// **Component**: Tri-state for panel controls.
26#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Default)]
27#[repr(u8)]
28pub enum PanelState {
29    /// Completely hidden.
30    Hidden = 1,
31
32    /// Visible, but as small as possible on its shorter axis.
33    Collapsed = 2,
34
35    /// Fully expanded.
36    #[default]
37    Expanded = 3,
38}
39
40impl ::re_types_core::Component for PanelState {
41    #[inline]
42    fn name() -> ComponentType {
43        "rerun.blueprint.components.PanelState".into()
44    }
45}
46
47::re_types_core::macros::impl_into_cow!(PanelState);
48
49impl ::re_types_core::Loggable for PanelState {
50    #[inline]
51    fn arrow_datatype() -> arrow::datatypes::DataType {
52        use arrow::datatypes::*;
53        DataType::UInt8
54    }
55
56    fn to_arrow_opt<'a>(
57        data: impl IntoIterator<Item = Option<impl Into<::std::borrow::Cow<'a, Self>>>>,
58    ) -> SerializationResult<arrow::array::ArrayRef>
59    where
60        Self: Clone + 'a,
61    {
62        #![allow(clippy::manual_is_variant_and)]
63        use ::re_types_core::{Loggable as _, ResultExt as _, arrow_helpers::as_array_ref};
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        use ::re_types_core::{Loggable as _, ResultExt as _, arrow_zip_validity::ZipValidity};
97        use arrow::{array::*, buffer::*, datatypes::*};
98        Ok(arrow_data
99            .as_any()
100            .downcast_ref::<UInt8Array>()
101            .ok_or_else(|| {
102                let expected = Self::arrow_datatype();
103                let actual = arrow_data.data_type().clone();
104                DeserializationError::datatype_mismatch(expected, actual)
105            })
106            .with_context("rerun.blueprint.components.PanelState#enum")?
107            .into_iter()
108            .map(|typ| match typ {
109                Some(1) => Ok(Some(Self::Hidden)),
110                Some(2) => Ok(Some(Self::Collapsed)),
111                Some(3) => Ok(Some(Self::Expanded)),
112                None => Ok(None),
113                Some(invalid) => Err(DeserializationError::missing_union_arm(
114                    Self::arrow_datatype(),
115                    "<invalid>",
116                    invalid as _,
117                )),
118            })
119            .collect::<DeserializationResult<Vec<Option<_>>>>()
120            .with_context("rerun.blueprint.components.PanelState")?)
121    }
122}
123
124impl std::fmt::Display for PanelState {
125    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
126        match self {
127            Self::Hidden => write!(f, "Hidden"),
128            Self::Collapsed => write!(f, "Collapsed"),
129            Self::Expanded => write!(f, "Expanded"),
130        }
131    }
132}
133
134impl ::re_types_core::reflection::Enum for PanelState {
135    #[inline]
136    fn variants() -> &'static [Self] {
137        &[Self::Hidden, Self::Collapsed, Self::Expanded]
138    }
139
140    #[inline]
141    fn docstring_md(self) -> &'static str {
142        match self {
143            Self::Hidden => "Completely hidden.",
144            Self::Collapsed => "Visible, but as small as possible on its shorter axis.",
145            Self::Expanded => "Fully expanded.",
146        }
147    }
148}
149
150impl ::re_byte_size::SizeBytes for PanelState {
151    #[inline]
152    fn heap_size_bytes(&self) -> u64 {
153        0
154    }
155
156    #[inline]
157    fn is_pod() -> bool {
158        true
159    }
160}