re_types/components/
radius.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, Copy, PartialEq, PartialOrd, bytemuck::Pod, bytemuck::Zeroable)]
30#[repr(transparent)]
31pub struct Radius(pub crate::datatypes::Float32);
32
33impl ::re_types_core::Component for Radius {
34 #[inline]
35 fn descriptor() -> ComponentDescriptor {
36 ComponentDescriptor::new("rerun.components.Radius")
37 }
38}
39
40::re_types_core::macros::impl_into_cow!(Radius);
41
42impl ::re_types_core::Loggable for Radius {
43 #[inline]
44 fn arrow_datatype() -> arrow::datatypes::DataType {
45 crate::datatypes::Float32::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::Float32::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::Float32::from_arrow_opt(arrow_data)
69 .map(|v| v.into_iter().map(|v| v.map(Self)).collect())
70 }
71
72 #[inline]
73 fn from_arrow(arrow_data: &dyn arrow::array::Array) -> DeserializationResult<Vec<Self>>
74 where
75 Self: Sized,
76 {
77 crate::datatypes::Float32::from_arrow(arrow_data).map(bytemuck::cast_vec)
78 }
79}
80
81impl<T: Into<crate::datatypes::Float32>> From<T> for Radius {
82 fn from(v: T) -> Self {
83 Self(v.into())
84 }
85}
86
87impl std::borrow::Borrow<crate::datatypes::Float32> for Radius {
88 #[inline]
89 fn borrow(&self) -> &crate::datatypes::Float32 {
90 &self.0
91 }
92}
93
94impl std::ops::Deref for Radius {
95 type Target = crate::datatypes::Float32;
96
97 #[inline]
98 fn deref(&self) -> &crate::datatypes::Float32 {
99 &self.0
100 }
101}
102
103impl std::ops::DerefMut for Radius {
104 #[inline]
105 fn deref_mut(&mut self) -> &mut crate::datatypes::Float32 {
106 &mut self.0
107 }
108}
109
110impl ::re_byte_size::SizeBytes for Radius {
111 #[inline]
112 fn heap_size_bytes(&self) -> u64 {
113 self.0.heap_size_bytes()
114 }
115
116 #[inline]
117 fn is_pod() -> bool {
118 <crate::datatypes::Float32>::is_pod()
119 }
120}