re_types/components/
draw_order.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/draw_order.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
15use ::re_types_core::try_serialize_field;
16use ::re_types_core::SerializationResult;
17use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
18use ::re_types_core::{ComponentDescriptor, ComponentName};
19use ::re_types_core::{DeserializationError, DeserializationResult};
20
21/// **Component**: Draw order of 2D elements. Higher values are drawn on top of lower values.
22///
23/// An entity can have only a single draw order component.
24/// Within an entity draw order is governed by the order of the components.
25///
26/// Draw order for entities with the same draw order is generally undefined.
27#[derive(Clone, Debug, Copy)]
28#[repr(transparent)]
29pub struct DrawOrder(pub crate::datatypes::Float32);
30
31impl ::re_types_core::Component for DrawOrder {
32    #[inline]
33    fn descriptor() -> ComponentDescriptor {
34        ComponentDescriptor::new("rerun.components.DrawOrder")
35    }
36}
37
38::re_types_core::macros::impl_into_cow!(DrawOrder);
39
40impl ::re_types_core::Loggable for DrawOrder {
41    #[inline]
42    fn arrow_datatype() -> arrow::datatypes::DataType {
43        crate::datatypes::Float32::arrow_datatype()
44    }
45
46    fn to_arrow_opt<'a>(
47        data: impl IntoIterator<Item = Option<impl Into<::std::borrow::Cow<'a, Self>>>>,
48    ) -> SerializationResult<arrow::array::ArrayRef>
49    where
50        Self: Clone + 'a,
51    {
52        crate::datatypes::Float32::to_arrow_opt(data.into_iter().map(|datum| {
53            datum.map(|datum| match datum.into() {
54                ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0),
55                ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0),
56            })
57        }))
58    }
59
60    fn from_arrow_opt(
61        arrow_data: &dyn arrow::array::Array,
62    ) -> DeserializationResult<Vec<Option<Self>>>
63    where
64        Self: Sized,
65    {
66        crate::datatypes::Float32::from_arrow_opt(arrow_data)
67            .map(|v| v.into_iter().map(|v| v.map(Self)).collect())
68    }
69
70    #[inline]
71    fn from_arrow(arrow_data: &dyn arrow::array::Array) -> DeserializationResult<Vec<Self>>
72    where
73        Self: Sized,
74    {
75        crate::datatypes::Float32::from_arrow(arrow_data).map(|v| v.into_iter().map(Self).collect())
76    }
77}
78
79impl<T: Into<crate::datatypes::Float32>> From<T> for DrawOrder {
80    fn from(v: T) -> Self {
81        Self(v.into())
82    }
83}
84
85impl std::borrow::Borrow<crate::datatypes::Float32> for DrawOrder {
86    #[inline]
87    fn borrow(&self) -> &crate::datatypes::Float32 {
88        &self.0
89    }
90}
91
92impl std::ops::Deref for DrawOrder {
93    type Target = crate::datatypes::Float32;
94
95    #[inline]
96    fn deref(&self) -> &crate::datatypes::Float32 {
97        &self.0
98    }
99}
100
101impl std::ops::DerefMut for DrawOrder {
102    #[inline]
103    fn deref_mut(&mut self) -> &mut crate::datatypes::Float32 {
104        &mut self.0
105    }
106}
107
108impl ::re_byte_size::SizeBytes for DrawOrder {
109    #[inline]
110    fn heap_size_bytes(&self) -> u64 {
111        self.0.heap_size_bytes()
112    }
113
114    #[inline]
115    fn is_pod() -> bool {
116        <crate::datatypes::Float32>::is_pod()
117    }
118}