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