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_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**: Whether the entity's [`components::Text`][crate::components::Text] label is shown.
23///
24/// The main purpose of this component existing separately from the labels themselves
25/// is to be overridden when desired, to allow hiding and showing from the viewer and
26/// blueprints.
27#[derive(Clone, Debug, Copy, PartialEq, Eq)]
28pub struct ShowLabels(
29    /// Whether the entity's [`components::Text`][crate::components::Text] label is shown.
30    pub crate::datatypes::Bool,
31);
32
33impl ::re_types_core::Component for ShowLabels {
34    #[inline]
35    fn name() -> ComponentType {
36        "rerun.components.ShowLabels".into()
37    }
38}
39
40::re_types_core::macros::impl_into_cow!(ShowLabels);
41
42impl ::re_types_core::Loggable for ShowLabels {
43    #[inline]
44    fn arrow_datatype() -> arrow::datatypes::DataType {
45        crate::datatypes::Bool::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::Bool::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::Bool::from_arrow_opt(arrow_data)
69            .map(|v| v.into_iter().map(|v| v.map(Self)).collect())
70    }
71}
72
73impl<T: Into<crate::datatypes::Bool>> From<T> for ShowLabels {
74    fn from(v: T) -> Self {
75        Self(v.into())
76    }
77}
78
79impl std::borrow::Borrow<crate::datatypes::Bool> for ShowLabels {
80    #[inline]
81    fn borrow(&self) -> &crate::datatypes::Bool {
82        &self.0
83    }
84}
85
86impl std::ops::Deref for ShowLabels {
87    type Target = crate::datatypes::Bool;
88
89    #[inline]
90    fn deref(&self) -> &crate::datatypes::Bool {
91        &self.0
92    }
93}
94
95impl std::ops::DerefMut for ShowLabels {
96    #[inline]
97    fn deref_mut(&mut self) -> &mut crate::datatypes::Bool {
98        &mut self.0
99    }
100}
101
102impl ::re_byte_size::SizeBytes for ShowLabels {
103    #[inline]
104    fn heap_size_bytes(&self) -> u64 {
105        self.0.heap_size_bytes()
106    }
107
108    #[inline]
109    fn is_pod() -> bool {
110        <crate::datatypes::Bool>::is_pod()
111    }
112}