re_types/components/
show_labels.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/show_labels.fbs".
3
4#![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/// **Component**: Whether the entity's [`components::Text`][crate::components::Text] label is shown.
22///
23/// The main purpose of this component existing separately from the labels themselves
24/// is to be overridden when desired, to allow hiding and showing from the viewer and
25/// blueprints.
26#[derive(Clone, Debug, Copy, PartialEq, Eq)]
27pub struct ShowLabels(
28    /// Whether the entity's [`components::Text`][crate::components::Text] label is shown.
29    pub crate::datatypes::Bool,
30);
31
32impl ::re_types_core::Component for ShowLabels {
33    #[inline]
34    fn descriptor() -> ComponentDescriptor {
35        ComponentDescriptor::new("rerun.components.ShowLabels")
36    }
37}
38
39::re_types_core::macros::impl_into_cow!(ShowLabels);
40
41impl ::re_types_core::Loggable for ShowLabels {
42    #[inline]
43    fn arrow_datatype() -> arrow::datatypes::DataType {
44        crate::datatypes::Bool::arrow_datatype()
45    }
46
47    fn to_arrow_opt<'a>(
48        data: impl IntoIterator<Item = Option<impl Into<::std::borrow::Cow<'a, Self>>>>,
49    ) -> SerializationResult<arrow::array::ArrayRef>
50    where
51        Self: Clone + 'a,
52    {
53        crate::datatypes::Bool::to_arrow_opt(data.into_iter().map(|datum| {
54            datum.map(|datum| match datum.into() {
55                ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0),
56                ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0),
57            })
58        }))
59    }
60
61    fn from_arrow_opt(
62        arrow_data: &dyn arrow::array::Array,
63    ) -> DeserializationResult<Vec<Option<Self>>>
64    where
65        Self: Sized,
66    {
67        crate::datatypes::Bool::from_arrow_opt(arrow_data)
68            .map(|v| v.into_iter().map(|v| v.map(Self)).collect())
69    }
70}
71
72impl<T: Into<crate::datatypes::Bool>> From<T> for ShowLabels {
73    fn from(v: T) -> Self {
74        Self(v.into())
75    }
76}
77
78impl std::borrow::Borrow<crate::datatypes::Bool> for ShowLabels {
79    #[inline]
80    fn borrow(&self) -> &crate::datatypes::Bool {
81        &self.0
82    }
83}
84
85impl std::ops::Deref for ShowLabels {
86    type Target = crate::datatypes::Bool;
87
88    #[inline]
89    fn deref(&self) -> &crate::datatypes::Bool {
90        &self.0
91    }
92}
93
94impl std::ops::DerefMut for ShowLabels {
95    #[inline]
96    fn deref_mut(&mut self) -> &mut crate::datatypes::Bool {
97        &mut self.0
98    }
99}
100
101impl ::re_byte_size::SizeBytes for ShowLabels {
102    #[inline]
103    fn heap_size_bytes(&self) -> u64 {
104        self.0.heap_size_bytes()
105    }
106
107    #[inline]
108    fn is_pod() -> bool {
109        <crate::datatypes::Bool>::is_pod()
110    }
111}