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