re_types/components/
half_size3d.rs1#![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#[derive(Clone, Debug, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable)]
28#[repr(transparent)]
29pub struct HalfSize3D(pub crate::datatypes::Vec3D);
30
31impl ::re_types_core::Component for HalfSize3D {
32 #[inline]
33 fn descriptor() -> ComponentDescriptor {
34 ComponentDescriptor::new("rerun.components.HalfSize3D")
35 }
36}
37
38::re_types_core::macros::impl_into_cow!(HalfSize3D);
39
40impl ::re_types_core::Loggable for HalfSize3D {
41 #[inline]
42 fn arrow_datatype() -> arrow::datatypes::DataType {
43 crate::datatypes::Vec3D::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::Vec3D::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::Vec3D::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::Vec3D::from_arrow(arrow_data).map(bytemuck::cast_vec)
76 }
77}
78
79impl<T: Into<crate::datatypes::Vec3D>> From<T> for HalfSize3D {
80 fn from(v: T) -> Self {
81 Self(v.into())
82 }
83}
84
85impl std::borrow::Borrow<crate::datatypes::Vec3D> for HalfSize3D {
86 #[inline]
87 fn borrow(&self) -> &crate::datatypes::Vec3D {
88 &self.0
89 }
90}
91
92impl std::ops::Deref for HalfSize3D {
93 type Target = crate::datatypes::Vec3D;
94
95 #[inline]
96 fn deref(&self) -> &crate::datatypes::Vec3D {
97 &self.0
98 }
99}
100
101impl std::ops::DerefMut for HalfSize3D {
102 #[inline]
103 fn deref_mut(&mut self) -> &mut crate::datatypes::Vec3D {
104 &mut self.0
105 }
106}
107
108impl ::re_byte_size::SizeBytes for HalfSize3D {
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::Vec3D>::is_pod()
117 }
118}