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