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