re_types/components/
opacity.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/opacity.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**: Degree of transparency ranging from 0.0 (fully transparent) to 1.0 (fully opaque).
22///
23/// The final opacity value may be a result of multiplication with alpha values as specified by other color sources.
24/// Unless otherwise specified, the default value is 1.
25#[derive(Clone, Debug, Copy, PartialEq, PartialOrd, bytemuck::Pod, bytemuck::Zeroable)]
26#[repr(transparent)]
27pub struct Opacity(pub crate::datatypes::Float32);
28
29impl ::re_types_core::Component for Opacity {
30    #[inline]
31    fn descriptor() -> ComponentDescriptor {
32        ComponentDescriptor::new("rerun.components.Opacity")
33    }
34}
35
36::re_types_core::macros::impl_into_cow!(Opacity);
37
38impl ::re_types_core::Loggable for Opacity {
39    #[inline]
40    fn arrow_datatype() -> arrow::datatypes::DataType {
41        crate::datatypes::Float32::arrow_datatype()
42    }
43
44    fn to_arrow_opt<'a>(
45        data: impl IntoIterator<Item = Option<impl Into<::std::borrow::Cow<'a, Self>>>>,
46    ) -> SerializationResult<arrow::array::ArrayRef>
47    where
48        Self: Clone + 'a,
49    {
50        crate::datatypes::Float32::to_arrow_opt(data.into_iter().map(|datum| {
51            datum.map(|datum| match datum.into() {
52                ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0),
53                ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0),
54            })
55        }))
56    }
57
58    fn from_arrow_opt(
59        arrow_data: &dyn arrow::array::Array,
60    ) -> DeserializationResult<Vec<Option<Self>>>
61    where
62        Self: Sized,
63    {
64        crate::datatypes::Float32::from_arrow_opt(arrow_data)
65            .map(|v| v.into_iter().map(|v| v.map(Self)).collect())
66    }
67
68    #[inline]
69    fn from_arrow(arrow_data: &dyn arrow::array::Array) -> DeserializationResult<Vec<Self>>
70    where
71        Self: Sized,
72    {
73        crate::datatypes::Float32::from_arrow(arrow_data).map(bytemuck::cast_vec)
74    }
75}
76
77impl<T: Into<crate::datatypes::Float32>> From<T> for Opacity {
78    fn from(v: T) -> Self {
79        Self(v.into())
80    }
81}
82
83impl std::borrow::Borrow<crate::datatypes::Float32> for Opacity {
84    #[inline]
85    fn borrow(&self) -> &crate::datatypes::Float32 {
86        &self.0
87    }
88}
89
90impl std::ops::Deref for Opacity {
91    type Target = crate::datatypes::Float32;
92
93    #[inline]
94    fn deref(&self) -> &crate::datatypes::Float32 {
95        &self.0
96    }
97}
98
99impl std::ops::DerefMut for Opacity {
100    #[inline]
101    fn deref_mut(&mut self) -> &mut crate::datatypes::Float32 {
102        &mut self.0
103    }
104}
105
106impl ::re_byte_size::SizeBytes for Opacity {
107    #[inline]
108    fn heap_size_bytes(&self) -> u64 {
109        self.0.heap_size_bytes()
110    }
111
112    #[inline]
113    fn is_pod() -> bool {
114        <crate::datatypes::Float32>::is_pod()
115    }
116}