re_types/components/
pinhole_projection.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/pinhole_projection.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**: Camera projection, from image coordinates to view coordinates.
23///
24/// Child from parent.
25/// Image coordinates from camera view coordinates.
26///
27/// Example:
28/// ```text
29/// 1496.1     0.0  980.5
30///    0.0  1496.1  744.5
31///    0.0     0.0    1.0
32/// ```
33#[derive(Clone, Debug, Copy, PartialEq, PartialOrd)]
34pub struct PinholeProjection(pub crate::datatypes::Mat3x3);
35
36impl ::re_types_core::Component for PinholeProjection {
37    #[inline]
38    fn name() -> ComponentType {
39        "rerun.components.PinholeProjection".into()
40    }
41}
42
43::re_types_core::macros::impl_into_cow!(PinholeProjection);
44
45impl ::re_types_core::Loggable for PinholeProjection {
46    #[inline]
47    fn arrow_datatype() -> arrow::datatypes::DataType {
48        crate::datatypes::Mat3x3::arrow_datatype()
49    }
50
51    fn to_arrow_opt<'a>(
52        data: impl IntoIterator<Item = Option<impl Into<::std::borrow::Cow<'a, Self>>>>,
53    ) -> SerializationResult<arrow::array::ArrayRef>
54    where
55        Self: Clone + 'a,
56    {
57        crate::datatypes::Mat3x3::to_arrow_opt(data.into_iter().map(|datum| {
58            datum.map(|datum| match datum.into() {
59                ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0),
60                ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0),
61            })
62        }))
63    }
64
65    fn from_arrow_opt(
66        arrow_data: &dyn arrow::array::Array,
67    ) -> DeserializationResult<Vec<Option<Self>>>
68    where
69        Self: Sized,
70    {
71        crate::datatypes::Mat3x3::from_arrow_opt(arrow_data)
72            .map(|v| v.into_iter().map(|v| v.map(Self)).collect())
73    }
74
75    #[inline]
76    fn from_arrow(arrow_data: &dyn arrow::array::Array) -> DeserializationResult<Vec<Self>>
77    where
78        Self: Sized,
79    {
80        crate::datatypes::Mat3x3::from_arrow(arrow_data).map(|v| v.into_iter().map(Self).collect())
81    }
82}
83
84impl<T: Into<crate::datatypes::Mat3x3>> From<T> for PinholeProjection {
85    fn from(v: T) -> Self {
86        Self(v.into())
87    }
88}
89
90impl std::borrow::Borrow<crate::datatypes::Mat3x3> for PinholeProjection {
91    #[inline]
92    fn borrow(&self) -> &crate::datatypes::Mat3x3 {
93        &self.0
94    }
95}
96
97impl std::ops::Deref for PinholeProjection {
98    type Target = crate::datatypes::Mat3x3;
99
100    #[inline]
101    fn deref(&self) -> &crate::datatypes::Mat3x3 {
102        &self.0
103    }
104}
105
106impl std::ops::DerefMut for PinholeProjection {
107    #[inline]
108    fn deref_mut(&mut self) -> &mut crate::datatypes::Mat3x3 {
109        &mut self.0
110    }
111}
112
113impl ::re_byte_size::SizeBytes for PinholeProjection {
114    #[inline]
115    fn heap_size_bytes(&self) -> u64 {
116        self.0.heap_size_bytes()
117    }
118
119    #[inline]
120    fn is_pod() -> bool {
121        <crate::datatypes::Mat3x3>::is_pod()
122    }
123}