re_types/components/
keypoint_id.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/keypoint_id.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**: A 16-bit ID representing a type of semantic keypoint within a class.
23///
24/// `KeypointId`s are only meaningful within the context of a [`crate::datatypes::ClassDescription`].
25///
26/// Used to look up an [`crate::datatypes::AnnotationInfo`] for a Keypoint within the [`crate::components::AnnotationContext`].
27#[derive(
28    Clone,
29    Debug,
30    Default,
31    Copy,
32    PartialEq,
33    Eq,
34    PartialOrd,
35    Ord,
36    Hash,
37    bytemuck::Pod,
38    bytemuck::Zeroable,
39)]
40#[repr(transparent)]
41#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
42pub struct KeypointId(pub crate::datatypes::KeypointId);
43
44impl ::re_types_core::Component for KeypointId {
45    #[inline]
46    fn name() -> ComponentType {
47        "rerun.components.KeypointId".into()
48    }
49}
50
51::re_types_core::macros::impl_into_cow!(KeypointId);
52
53impl ::re_types_core::Loggable for KeypointId {
54    #[inline]
55    fn arrow_datatype() -> arrow::datatypes::DataType {
56        crate::datatypes::KeypointId::arrow_datatype()
57    }
58
59    fn to_arrow_opt<'a>(
60        data: impl IntoIterator<Item = Option<impl Into<::std::borrow::Cow<'a, Self>>>>,
61    ) -> SerializationResult<arrow::array::ArrayRef>
62    where
63        Self: Clone + 'a,
64    {
65        crate::datatypes::KeypointId::to_arrow_opt(data.into_iter().map(|datum| {
66            datum.map(|datum| match datum.into() {
67                ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0),
68                ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0),
69            })
70        }))
71    }
72
73    fn from_arrow_opt(
74        arrow_data: &dyn arrow::array::Array,
75    ) -> DeserializationResult<Vec<Option<Self>>>
76    where
77        Self: Sized,
78    {
79        crate::datatypes::KeypointId::from_arrow_opt(arrow_data)
80            .map(|v| v.into_iter().map(|v| v.map(Self)).collect())
81    }
82
83    #[inline]
84    fn from_arrow(arrow_data: &dyn arrow::array::Array) -> DeserializationResult<Vec<Self>>
85    where
86        Self: Sized,
87    {
88        crate::datatypes::KeypointId::from_arrow(arrow_data).map(bytemuck::cast_vec)
89    }
90}
91
92impl<T: Into<crate::datatypes::KeypointId>> From<T> for KeypointId {
93    fn from(v: T) -> Self {
94        Self(v.into())
95    }
96}
97
98impl std::borrow::Borrow<crate::datatypes::KeypointId> for KeypointId {
99    #[inline]
100    fn borrow(&self) -> &crate::datatypes::KeypointId {
101        &self.0
102    }
103}
104
105impl std::ops::Deref for KeypointId {
106    type Target = crate::datatypes::KeypointId;
107
108    #[inline]
109    fn deref(&self) -> &crate::datatypes::KeypointId {
110        &self.0
111    }
112}
113
114impl std::ops::DerefMut for KeypointId {
115    #[inline]
116    fn deref_mut(&mut self) -> &mut crate::datatypes::KeypointId {
117        &mut self.0
118    }
119}
120
121impl ::re_byte_size::SizeBytes for KeypointId {
122    #[inline]
123    fn heap_size_bytes(&self) -> u64 {
124        self.0.heap_size_bytes()
125    }
126
127    #[inline]
128    fn is_pod() -> bool {
129        <crate::datatypes::KeypointId>::is_pod()
130    }
131}