re_types/blueprint/components/
link_axis.rs1#![allow(unused_braces)]
5#![allow(unused_imports)]
6#![allow(unused_parens)]
7#![allow(clippy::allow_attributes)]
8#![allow(clippy::clone_on_copy)]
9#![allow(clippy::cloned_instead_of_copied)]
10#![allow(clippy::map_flatten)]
11#![allow(clippy::needless_question_mark)]
12#![allow(clippy::new_without_default)]
13#![allow(clippy::redundant_closure)]
14#![allow(clippy::too_many_arguments)]
15#![allow(clippy::too_many_lines)]
16#![allow(clippy::wildcard_imports)]
17#![allow(non_camel_case_types)]
18
19use ::re_types_core::SerializationResult;
20use ::re_types_core::try_serialize_field;
21use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
22use ::re_types_core::{ComponentDescriptor, ComponentType};
23use ::re_types_core::{DeserializationError, DeserializationResult};
24
25#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Default)]
27#[repr(u8)]
28pub enum LinkAxis {
29 #[default]
31 Independent = 1,
32
33 LinkToGlobal = 2,
35}
36
37impl ::re_types_core::Component for LinkAxis {
38 #[inline]
39 fn name() -> ComponentType {
40 "rerun.blueprint.components.LinkAxis".into()
41 }
42}
43
44::re_types_core::macros::impl_into_cow!(LinkAxis);
45
46impl ::re_types_core::Loggable for LinkAxis {
47 #[inline]
48 fn arrow_datatype() -> arrow::datatypes::DataType {
49 use arrow::datatypes::*;
50 DataType::UInt8
51 }
52
53 fn to_arrow_opt<'a>(
54 data: impl IntoIterator<Item = Option<impl Into<::std::borrow::Cow<'a, Self>>>>,
55 ) -> SerializationResult<arrow::array::ArrayRef>
56 where
57 Self: Clone + 'a,
58 {
59 #![allow(clippy::manual_is_variant_and)]
60 use ::re_types_core::{Loggable as _, ResultExt as _, arrow_helpers::as_array_ref};
61 use arrow::{array::*, buffer::*, datatypes::*};
62 Ok({
63 let (somes, data0): (Vec<_>, Vec<_>) = data
64 .into_iter()
65 .map(|datum| {
66 let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into);
67 let datum = datum.map(|datum| *datum as u8);
68 (datum.is_some(), datum)
69 })
70 .unzip();
71 let data0_validity: Option<arrow::buffer::NullBuffer> = {
72 let any_nones = somes.iter().any(|some| !*some);
73 any_nones.then(|| somes.into())
74 };
75 as_array_ref(PrimitiveArray::<UInt8Type>::new(
76 ScalarBuffer::from(
77 data0
78 .into_iter()
79 .map(|v| v.unwrap_or_default())
80 .collect::<Vec<_>>(),
81 ),
82 data0_validity,
83 ))
84 })
85 }
86
87 fn from_arrow_opt(
88 arrow_data: &dyn arrow::array::Array,
89 ) -> DeserializationResult<Vec<Option<Self>>>
90 where
91 Self: Sized,
92 {
93 use ::re_types_core::{Loggable as _, ResultExt as _, arrow_zip_validity::ZipValidity};
94 use arrow::{array::*, buffer::*, datatypes::*};
95 Ok(arrow_data
96 .as_any()
97 .downcast_ref::<UInt8Array>()
98 .ok_or_else(|| {
99 let expected = Self::arrow_datatype();
100 let actual = arrow_data.data_type().clone();
101 DeserializationError::datatype_mismatch(expected, actual)
102 })
103 .with_context("rerun.blueprint.components.LinkAxis#enum")?
104 .into_iter()
105 .map(|typ| match typ {
106 Some(1) => Ok(Some(Self::Independent)),
107 Some(2) => Ok(Some(Self::LinkToGlobal)),
108 None => Ok(None),
109 Some(invalid) => Err(DeserializationError::missing_union_arm(
110 Self::arrow_datatype(),
111 "<invalid>",
112 invalid as _,
113 )),
114 })
115 .collect::<DeserializationResult<Vec<Option<_>>>>()
116 .with_context("rerun.blueprint.components.LinkAxis")?)
117 }
118}
119
120impl std::fmt::Display for LinkAxis {
121 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
122 match self {
123 Self::Independent => write!(f, "Independent"),
124 Self::LinkToGlobal => write!(f, "LinkToGlobal"),
125 }
126 }
127}
128
129impl ::re_types_core::reflection::Enum for LinkAxis {
130 #[inline]
131 fn variants() -> &'static [Self] {
132 &[Self::Independent, Self::LinkToGlobal]
133 }
134
135 #[inline]
136 fn docstring_md(self) -> &'static str {
137 match self {
138 Self::Independent => "The axis is independent from all other plots.",
139 Self::LinkToGlobal => "Link to all other plots that also have this options set.",
140 }
141 }
142}
143
144impl ::re_byte_size::SizeBytes for LinkAxis {
145 #[inline]
146 fn heap_size_bytes(&self) -> u64 {
147 0
148 }
149
150 #[inline]
151 fn is_pod() -> bool {
152 true
153 }
154}