re_types/components/
fill_mode.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 FillMode {
27 #[default]
35 MajorWireframe = 1,
36
37 DenseWireframe = 2,
45
46 Solid = 3,
48}
49
50impl ::re_types_core::Component for FillMode {
51 #[inline]
52 fn name() -> ComponentType {
53 "rerun.components.FillMode".into()
54 }
55}
56
57::re_types_core::macros::impl_into_cow!(FillMode);
58
59impl ::re_types_core::Loggable for FillMode {
60 #[inline]
61 fn arrow_datatype() -> arrow::datatypes::DataType {
62 #![allow(clippy::wildcard_imports)]
63 use arrow::datatypes::*;
64 DataType::UInt8
65 }
66
67 fn to_arrow_opt<'a>(
68 data: impl IntoIterator<Item = Option<impl Into<::std::borrow::Cow<'a, Self>>>>,
69 ) -> SerializationResult<arrow::array::ArrayRef>
70 where
71 Self: Clone + 'a,
72 {
73 #![allow(clippy::wildcard_imports)]
74 #![allow(clippy::manual_is_variant_and)]
75 use ::re_types_core::{arrow_helpers::as_array_ref, Loggable as _, ResultExt as _};
76 use arrow::{array::*, buffer::*, datatypes::*};
77 Ok({
78 let (somes, data0): (Vec<_>, Vec<_>) = data
79 .into_iter()
80 .map(|datum| {
81 let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into);
82 let datum = datum.map(|datum| *datum as u8);
83 (datum.is_some(), datum)
84 })
85 .unzip();
86 let data0_validity: Option<arrow::buffer::NullBuffer> = {
87 let any_nones = somes.iter().any(|some| !*some);
88 any_nones.then(|| somes.into())
89 };
90 as_array_ref(PrimitiveArray::<UInt8Type>::new(
91 ScalarBuffer::from(
92 data0
93 .into_iter()
94 .map(|v| v.unwrap_or_default())
95 .collect::<Vec<_>>(),
96 ),
97 data0_validity,
98 ))
99 })
100 }
101
102 fn from_arrow_opt(
103 arrow_data: &dyn arrow::array::Array,
104 ) -> DeserializationResult<Vec<Option<Self>>>
105 where
106 Self: Sized,
107 {
108 #![allow(clippy::wildcard_imports)]
109 use ::re_types_core::{arrow_zip_validity::ZipValidity, Loggable as _, ResultExt as _};
110 use arrow::{array::*, buffer::*, datatypes::*};
111 Ok(arrow_data
112 .as_any()
113 .downcast_ref::<UInt8Array>()
114 .ok_or_else(|| {
115 let expected = Self::arrow_datatype();
116 let actual = arrow_data.data_type().clone();
117 DeserializationError::datatype_mismatch(expected, actual)
118 })
119 .with_context("rerun.components.FillMode#enum")?
120 .into_iter()
121 .map(|typ| match typ {
122 Some(1) => Ok(Some(Self::MajorWireframe)),
123 Some(2) => Ok(Some(Self::DenseWireframe)),
124 Some(3) => Ok(Some(Self::Solid)),
125 None => Ok(None),
126 Some(invalid) => Err(DeserializationError::missing_union_arm(
127 Self::arrow_datatype(),
128 "<invalid>",
129 invalid as _,
130 )),
131 })
132 .collect::<DeserializationResult<Vec<Option<_>>>>()
133 .with_context("rerun.components.FillMode")?)
134 }
135}
136
137impl std::fmt::Display for FillMode {
138 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
139 match self {
140 Self::MajorWireframe => write!(f, "MajorWireframe"),
141 Self::DenseWireframe => write!(f, "DenseWireframe"),
142 Self::Solid => write!(f, "Solid"),
143 }
144 }
145}
146
147impl ::re_types_core::reflection::Enum for FillMode {
148 #[inline]
149 fn variants() -> &'static [Self] {
150 &[Self::MajorWireframe, Self::DenseWireframe, Self::Solid]
151 }
152
153 #[inline]
154 fn docstring_md(self) -> &'static str {
155 match self {
156 Self::MajorWireframe => {
157 "Lines are drawn around the parts of the shape which directly correspond to the logged data.\n\nExamples of what this means:\n\n* An [`archetypes.Ellipsoids3D`](https://rerun.io/docs/reference/types/archetypes/ellipsoids3d) will draw three axis-aligned ellipses that are cross-sections\n of each ellipsoid, each of which displays two out of three of the sizes of the ellipsoid.\n* For [`archetypes.Boxes3D`](https://rerun.io/docs/reference/types/archetypes/boxes3d), it is the edges of the box, identical to [`components.FillMode#DenseWireframe`](https://rerun.io/docs/reference/types/components/fill_mode)."
158 }
159 Self::DenseWireframe => {
160 "Many lines are drawn to represent the surface of the shape in a see-through fashion.\n\nExamples of what this means:\n\n* An [`archetypes.Ellipsoids3D`](https://rerun.io/docs/reference/types/archetypes/ellipsoids3d) will draw a wireframe triangle mesh that approximates each\n ellipsoid.\n* For [`archetypes.Boxes3D`](https://rerun.io/docs/reference/types/archetypes/boxes3d), it is the edges of the box, identical to [`components.FillMode#MajorWireframe`](https://rerun.io/docs/reference/types/components/fill_mode)."
161 }
162 Self::Solid => {
163 "The surface of the shape is filled in with a solid color. No lines are drawn."
164 }
165 }
166 }
167}
168
169impl ::re_byte_size::SizeBytes for FillMode {
170 #[inline]
171 fn heap_size_bytes(&self) -> u64 {
172 0
173 }
174
175 #[inline]
176 fn is_pod() -> bool {
177 true
178 }
179}