re_types/blueprint/components/
map_provider.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/blueprint/components/map_provider.fbs".
3
4#![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/// **Component**: Name of the map provider to be used in Map views.
26#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Default)]
27#[repr(u8)]
28pub enum MapProvider {
29    /// `OpenStreetMap` is the default map provider.
30    #[default]
31    OpenStreetMap = 1,
32
33    /// Mapbox Streets is a minimalistic map designed by Mapbox.
34    MapboxStreets = 2,
35
36    /// Mapbox Dark is a dark-themed map designed by Mapbox.
37    MapboxDark = 3,
38
39    /// Mapbox Satellite is a satellite map designed by Mapbox.
40    MapboxSatellite = 4,
41}
42
43impl ::re_types_core::Component for MapProvider {
44    #[inline]
45    fn name() -> ComponentType {
46        "rerun.blueprint.components.MapProvider".into()
47    }
48}
49
50::re_types_core::macros::impl_into_cow!(MapProvider);
51
52impl ::re_types_core::Loggable for MapProvider {
53    #[inline]
54    fn arrow_datatype() -> arrow::datatypes::DataType {
55        use arrow::datatypes::*;
56        DataType::UInt8
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        #![allow(clippy::manual_is_variant_and)]
66        use ::re_types_core::{Loggable as _, ResultExt as _, arrow_helpers::as_array_ref};
67        use arrow::{array::*, buffer::*, datatypes::*};
68        Ok({
69            let (somes, data0): (Vec<_>, Vec<_>) = data
70                .into_iter()
71                .map(|datum| {
72                    let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into);
73                    let datum = datum.map(|datum| *datum as u8);
74                    (datum.is_some(), datum)
75                })
76                .unzip();
77            let data0_validity: Option<arrow::buffer::NullBuffer> = {
78                let any_nones = somes.iter().any(|some| !*some);
79                any_nones.then(|| somes.into())
80            };
81            as_array_ref(PrimitiveArray::<UInt8Type>::new(
82                ScalarBuffer::from(
83                    data0
84                        .into_iter()
85                        .map(|v| v.unwrap_or_default())
86                        .collect::<Vec<_>>(),
87                ),
88                data0_validity,
89            ))
90        })
91    }
92
93    fn from_arrow_opt(
94        arrow_data: &dyn arrow::array::Array,
95    ) -> DeserializationResult<Vec<Option<Self>>>
96    where
97        Self: Sized,
98    {
99        use ::re_types_core::{Loggable as _, ResultExt as _, arrow_zip_validity::ZipValidity};
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}