re_types/blueprint/archetypes/
map_zoom.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/archetypes/map_zoom.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/// **Archetype**: Configuration of the map view zoom level.
23///
24/// ⚠️ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
25#[derive(Clone, Debug, Default)]
26pub struct MapZoom {
27    /// Zoom level for the map.
28    ///
29    /// Zoom level follow the [`OpenStreetMap` definition](https://wiki.openstreetmap.org/wiki/Zoom_levels).
30    pub zoom: Option<SerializedComponentBatch>,
31}
32
33impl MapZoom {
34    /// Returns the [`ComponentDescriptor`] for [`Self::zoom`].
35    ///
36    /// The corresponding component is [`crate::blueprint::components::ZoomLevel`].
37    #[inline]
38    pub fn descriptor_zoom() -> ComponentDescriptor {
39        ComponentDescriptor {
40            archetype: Some("rerun.blueprint.archetypes.MapZoom".into()),
41            component: "MapZoom:zoom".into(),
42            component_type: Some("rerun.blueprint.components.ZoomLevel".into()),
43        }
44    }
45}
46
47static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
48    once_cell::sync::Lazy::new(|| []);
49
50static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
51    once_cell::sync::Lazy::new(|| []);
52
53static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
54    once_cell::sync::Lazy::new(|| [MapZoom::descriptor_zoom()]);
55
56static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
57    once_cell::sync::Lazy::new(|| [MapZoom::descriptor_zoom()]);
58
59impl MapZoom {
60    /// The total number of components in the archetype: 0 required, 0 recommended, 1 optional
61    pub const NUM_COMPONENTS: usize = 1usize;
62}
63
64impl ::re_types_core::Archetype for MapZoom {
65    #[inline]
66    fn name() -> ::re_types_core::ArchetypeName {
67        "rerun.blueprint.archetypes.MapZoom".into()
68    }
69
70    #[inline]
71    fn display_name() -> &'static str {
72        "Map zoom"
73    }
74
75    #[inline]
76    fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
77        REQUIRED_COMPONENTS.as_slice().into()
78    }
79
80    #[inline]
81    fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
82        RECOMMENDED_COMPONENTS.as_slice().into()
83    }
84
85    #[inline]
86    fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
87        OPTIONAL_COMPONENTS.as_slice().into()
88    }
89
90    #[inline]
91    fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
92        ALL_COMPONENTS.as_slice().into()
93    }
94
95    #[inline]
96    fn from_arrow_components(
97        arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
98    ) -> DeserializationResult<Self> {
99        re_tracing::profile_function!();
100        use ::re_types_core::{Loggable as _, ResultExt as _};
101        let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
102        let zoom = arrays_by_descr
103            .get(&Self::descriptor_zoom())
104            .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_zoom()));
105        Ok(Self { zoom })
106    }
107}
108
109impl ::re_types_core::AsComponents for MapZoom {
110    #[inline]
111    fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
112        use ::re_types_core::Archetype as _;
113        std::iter::once(self.zoom.clone()).flatten().collect()
114    }
115}
116
117impl ::re_types_core::ArchetypeReflectionMarker for MapZoom {}
118
119impl MapZoom {
120    /// Create a new `MapZoom`.
121    #[inline]
122    pub fn new(zoom: impl Into<crate::blueprint::components::ZoomLevel>) -> Self {
123        Self {
124            zoom: try_serialize_field(Self::descriptor_zoom(), [zoom]),
125        }
126    }
127
128    /// Update only some specific fields of a `MapZoom`.
129    #[inline]
130    pub fn update_fields() -> Self {
131        Self::default()
132    }
133
134    /// Clear all the fields of a `MapZoom`.
135    #[inline]
136    pub fn clear_fields() -> Self {
137        use ::re_types_core::Loggable as _;
138        Self {
139            zoom: Some(SerializedComponentBatch::new(
140                crate::blueprint::components::ZoomLevel::arrow_empty(),
141                Self::descriptor_zoom(),
142            )),
143        }
144    }
145
146    /// Zoom level for the map.
147    ///
148    /// Zoom level follow the [`OpenStreetMap` definition](https://wiki.openstreetmap.org/wiki/Zoom_levels).
149    #[inline]
150    pub fn with_zoom(mut self, zoom: impl Into<crate::blueprint::components::ZoomLevel>) -> Self {
151        self.zoom = try_serialize_field(Self::descriptor_zoom(), [zoom]);
152        self
153    }
154}
155
156impl ::re_byte_size::SizeBytes for MapZoom {
157    #[inline]
158    fn heap_size_bytes(&self) -> u64 {
159        self.zoom.heap_size_bytes()
160    }
161}