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_imports)]
5#![allow(unused_parens)]
6#![allow(clippy::clone_on_copy)]
7#![allow(clippy::cloned_instead_of_copied)]
8#![allow(clippy::map_flatten)]
9#![allow(clippy::needless_question_mark)]
10#![allow(clippy::new_without_default)]
11#![allow(clippy::redundant_closure)]
12#![allow(clippy::too_many_arguments)]
13#![allow(clippy::too_many_lines)]
14#![allow(non_camel_case_types)]
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, ComponentName};
20use ::re_types_core::{DeserializationError, DeserializationResult};
21
22/// **Component**: Tri-state for panel controls.
23#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Default)]
24#[repr(u8)]
25pub enum PanelState {
26    /// Completely hidden.
27    Hidden = 1,
28
29    /// Visible, but as small as possible on its shorter axis.
30    Collapsed = 2,
31
32    /// Fully expanded.
33    #[default]
34    Expanded = 3,
35}
36
37impl ::re_types_core::Component for PanelState {
38    #[inline]
39    fn descriptor() -> ComponentDescriptor {
40        ComponentDescriptor::new("rerun.blueprint.components.PanelState")
41    }
42}
43
44::re_types_core::macros::impl_into_cow!(PanelState);
45
46impl ::re_types_core::Loggable for PanelState {
47    #[inline]
48    fn arrow_datatype() -> arrow::datatypes::DataType {
49        #![allow(clippy::wildcard_imports)]
50        use arrow::datatypes::*;
51        DataType::UInt8
52    }
53
54    fn to_arrow_opt<'a>(
55        data: impl IntoIterator<Item = Option<impl Into<::std::borrow::Cow<'a, Self>>>>,
56    ) -> SerializationResult<arrow::array::ArrayRef>
57    where
58        Self: Clone + 'a,
59    {
60        #![allow(clippy::wildcard_imports)]
61        #![allow(clippy::manual_is_variant_and)]
62        use ::re_types_core::{arrow_helpers::as_array_ref, Loggable as _, ResultExt as _};
63        use arrow::{array::*, buffer::*, datatypes::*};
64        Ok({
65            let (somes, data0): (Vec<_>, Vec<_>) = data
66                .into_iter()
67                .map(|datum| {
68                    let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into);
69                    let datum = datum.map(|datum| *datum as u8);
70                    (datum.is_some(), datum)
71                })
72                .unzip();
73            let data0_validity: Option<arrow::buffer::NullBuffer> = {
74                let any_nones = somes.iter().any(|some| !*some);
75                any_nones.then(|| somes.into())
76            };
77            as_array_ref(PrimitiveArray::<UInt8Type>::new(
78                ScalarBuffer::from(
79                    data0
80                        .into_iter()
81                        .map(|v| v.unwrap_or_default())
82                        .collect::<Vec<_>>(),
83                ),
84                data0_validity,
85            ))
86        })
87    }
88
89    fn from_arrow_opt(
90        arrow_data: &dyn arrow::array::Array,
91    ) -> DeserializationResult<Vec<Option<Self>>>
92    where
93        Self: Sized,
94    {
95        #![allow(clippy::wildcard_imports)]
96        use ::re_types_core::{arrow_zip_validity::ZipValidity, Loggable as _, ResultExt as _};
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}