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