re_types/components/
tensor_data.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/tensor_data.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**: An N-dimensional array of numbers.
23///
24/// The number of dimensions and their respective lengths is specified by the `shape` field.
25/// The dimensions are ordered from outermost to innermost. For example, in the common case of
26/// a 2D RGB Image, the shape would be `[height, width, channel]`.
27///
28/// These dimensions are combined with an index to look up values from the `buffer` field,
29/// which stores a contiguous array of typed values.
30#[derive(Clone, Debug, Default, PartialEq)]
31#[repr(transparent)]
32pub struct TensorData(pub crate::datatypes::TensorData);
33
34impl ::re_types_core::Component for TensorData {
35    #[inline]
36    fn name() -> ComponentType {
37        "rerun.components.TensorData".into()
38    }
39}
40
41::re_types_core::macros::impl_into_cow!(TensorData);
42
43impl ::re_types_core::Loggable for TensorData {
44    #[inline]
45    fn arrow_datatype() -> arrow::datatypes::DataType {
46        crate::datatypes::TensorData::arrow_datatype()
47    }
48
49    fn to_arrow_opt<'a>(
50        data: impl IntoIterator<Item = Option<impl Into<::std::borrow::Cow<'a, Self>>>>,
51    ) -> SerializationResult<arrow::array::ArrayRef>
52    where
53        Self: Clone + 'a,
54    {
55        crate::datatypes::TensorData::to_arrow_opt(data.into_iter().map(|datum| {
56            datum.map(|datum| match datum.into() {
57                ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0),
58                ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0),
59            })
60        }))
61    }
62
63    fn from_arrow_opt(
64        arrow_data: &dyn arrow::array::Array,
65    ) -> DeserializationResult<Vec<Option<Self>>>
66    where
67        Self: Sized,
68    {
69        crate::datatypes::TensorData::from_arrow_opt(arrow_data)
70            .map(|v| v.into_iter().map(|v| v.map(Self)).collect())
71    }
72}
73
74impl<T: Into<crate::datatypes::TensorData>> From<T> for TensorData {
75    fn from(v: T) -> Self {
76        Self(v.into())
77    }
78}
79
80impl std::borrow::Borrow<crate::datatypes::TensorData> for TensorData {
81    #[inline]
82    fn borrow(&self) -> &crate::datatypes::TensorData {
83        &self.0
84    }
85}
86
87impl std::ops::Deref for TensorData {
88    type Target = crate::datatypes::TensorData;
89
90    #[inline]
91    fn deref(&self) -> &crate::datatypes::TensorData {
92        &self.0
93    }
94}
95
96impl std::ops::DerefMut for TensorData {
97    #[inline]
98    fn deref_mut(&mut self) -> &mut crate::datatypes::TensorData {
99        &mut self.0
100    }
101}
102
103impl ::re_byte_size::SizeBytes for TensorData {
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::TensorData>::is_pod()
112    }
113}