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