re_types/blueprint/components/
map_provider.rs1#![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#![allow(non_camel_case_types)]
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, ComponentName};
20use ::re_types_core::{DeserializationError, DeserializationResult};
21
22#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Default)]
24#[repr(u8)]
25pub enum MapProvider {
26 #[default]
28 OpenStreetMap = 1,
29
30 MapboxStreets = 2,
32
33 MapboxDark = 3,
35
36 MapboxSatellite = 4,
38}
39
40impl ::re_types_core::Component for MapProvider {
41 #[inline]
42 fn descriptor() -> ComponentDescriptor {
43 ComponentDescriptor::new("rerun.blueprint.components.MapProvider")
44 }
45}
46
47::re_types_core::macros::impl_into_cow!(MapProvider);
48
49impl ::re_types_core::Loggable for MapProvider {
50 #[inline]
51 fn arrow_datatype() -> arrow::datatypes::DataType {
52 #![allow(clippy::wildcard_imports)]
53 use arrow::datatypes::*;
54 DataType::UInt8
55 }
56
57 fn to_arrow_opt<'a>(
58 data: impl IntoIterator<Item = Option<impl Into<::std::borrow::Cow<'a, Self>>>>,
59 ) -> SerializationResult<arrow::array::ArrayRef>
60 where
61 Self: Clone + 'a,
62 {
63 #![allow(clippy::wildcard_imports)]
64 #![allow(clippy::manual_is_variant_and)]
65 use ::re_types_core::{arrow_helpers::as_array_ref, Loggable as _, ResultExt as _};
66 use arrow::{array::*, buffer::*, datatypes::*};
67 Ok({
68 let (somes, data0): (Vec<_>, Vec<_>) = data
69 .into_iter()
70 .map(|datum| {
71 let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into);
72 let datum = datum.map(|datum| *datum as u8);
73 (datum.is_some(), datum)
74 })
75 .unzip();
76 let data0_validity: Option<arrow::buffer::NullBuffer> = {
77 let any_nones = somes.iter().any(|some| !*some);
78 any_nones.then(|| somes.into())
79 };
80 as_array_ref(PrimitiveArray::<UInt8Type>::new(
81 ScalarBuffer::from(
82 data0
83 .into_iter()
84 .map(|v| v.unwrap_or_default())
85 .collect::<Vec<_>>(),
86 ),
87 data0_validity,
88 ))
89 })
90 }
91
92 fn from_arrow_opt(
93 arrow_data: &dyn arrow::array::Array,
94 ) -> DeserializationResult<Vec<Option<Self>>>
95 where
96 Self: Sized,
97 {
98 #![allow(clippy::wildcard_imports)]
99 use ::re_types_core::{arrow_zip_validity::ZipValidity, Loggable as _, ResultExt as _};
100 use arrow::{array::*, buffer::*, datatypes::*};
101 Ok(arrow_data
102 .as_any()
103 .downcast_ref::<UInt8Array>()
104 .ok_or_else(|| {
105 let expected = Self::arrow_datatype();
106 let actual = arrow_data.data_type().clone();
107 DeserializationError::datatype_mismatch(expected, actual)
108 })
109 .with_context("rerun.blueprint.components.MapProvider#enum")?
110 .into_iter()
111 .map(|typ| match typ {
112 Some(1) => Ok(Some(Self::OpenStreetMap)),
113 Some(2) => Ok(Some(Self::MapboxStreets)),
114 Some(3) => Ok(Some(Self::MapboxDark)),
115 Some(4) => Ok(Some(Self::MapboxSatellite)),
116 None => Ok(None),
117 Some(invalid) => Err(DeserializationError::missing_union_arm(
118 Self::arrow_datatype(),
119 "<invalid>",
120 invalid as _,
121 )),
122 })
123 .collect::<DeserializationResult<Vec<Option<_>>>>()
124 .with_context("rerun.blueprint.components.MapProvider")?)
125 }
126}
127
128impl std::fmt::Display for MapProvider {
129 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
130 match self {
131 Self::OpenStreetMap => write!(f, "OpenStreetMap"),
132 Self::MapboxStreets => write!(f, "MapboxStreets"),
133 Self::MapboxDark => write!(f, "MapboxDark"),
134 Self::MapboxSatellite => write!(f, "MapboxSatellite"),
135 }
136 }
137}
138
139impl ::re_types_core::reflection::Enum for MapProvider {
140 #[inline]
141 fn variants() -> &'static [Self] {
142 &[
143 Self::OpenStreetMap,
144 Self::MapboxStreets,
145 Self::MapboxDark,
146 Self::MapboxSatellite,
147 ]
148 }
149
150 #[inline]
151 fn docstring_md(self) -> &'static str {
152 match self {
153 Self::OpenStreetMap => "`OpenStreetMap` is the default map provider.",
154 Self::MapboxStreets => "Mapbox Streets is a minimalistic map designed by Mapbox.",
155 Self::MapboxDark => "Mapbox Dark is a dark-themed map designed by Mapbox.",
156 Self::MapboxSatellite => "Mapbox Satellite is a satellite map designed by Mapbox.",
157 }
158 }
159}
160
161impl ::re_byte_size::SizeBytes for MapProvider {
162 #[inline]
163 fn heap_size_bytes(&self) -> u64 {
164 0
165 }
166
167 #[inline]
168 fn is_pod() -> bool {
169 true
170 }
171}