re_types/blueprint/components/
container_kind.rs1#![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#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Default)]
27#[repr(u8)]
28pub enum ContainerKind {
29 Tabs = 1,
31
32 Horizontal = 2,
34
35 Vertical = 3,
37
38 #[default]
40 Grid = 4,
41}
42
43impl ::re_types_core::Component for ContainerKind {
44 #[inline]
45 fn name() -> ComponentType {
46 "rerun.blueprint.components.ContainerKind".into()
47 }
48}
49
50::re_types_core::macros::impl_into_cow!(ContainerKind);
51
52impl ::re_types_core::Loggable for ContainerKind {
53 #[inline]
54 fn arrow_datatype() -> arrow::datatypes::DataType {
55 use arrow::datatypes::*;
56 DataType::UInt8
57 }
58
59 fn to_arrow_opt<'a>(
60 data: impl IntoIterator<Item = Option<impl Into<::std::borrow::Cow<'a, Self>>>>,
61 ) -> SerializationResult<arrow::array::ArrayRef>
62 where
63 Self: Clone + 'a,
64 {
65 #![allow(clippy::manual_is_variant_and)]
66 use ::re_types_core::{Loggable as _, ResultExt as _, arrow_helpers::as_array_ref};
67 use arrow::{array::*, buffer::*, datatypes::*};
68 Ok({
69 let (somes, data0): (Vec<_>, Vec<_>) = data
70 .into_iter()
71 .map(|datum| {
72 let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into);
73 let datum = datum.map(|datum| *datum as u8);
74 (datum.is_some(), datum)
75 })
76 .unzip();
77 let data0_validity: Option<arrow::buffer::NullBuffer> = {
78 let any_nones = somes.iter().any(|some| !*some);
79 any_nones.then(|| somes.into())
80 };
81 as_array_ref(PrimitiveArray::<UInt8Type>::new(
82 ScalarBuffer::from(
83 data0
84 .into_iter()
85 .map(|v| v.unwrap_or_default())
86 .collect::<Vec<_>>(),
87 ),
88 data0_validity,
89 ))
90 })
91 }
92
93 fn from_arrow_opt(
94 arrow_data: &dyn arrow::array::Array,
95 ) -> DeserializationResult<Vec<Option<Self>>>
96 where
97 Self: Sized,
98 {
99 use ::re_types_core::{Loggable as _, ResultExt as _, arrow_zip_validity::ZipValidity};
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}