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