re_types/blueprint/archetypes/
time_axis.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/time_axis.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 for the time (Y) axis of a plot.
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 TimeAxis {
27    /// How should the horizontal/X/time axis be linked across multiple plots?
28    pub link: Option<SerializedComponentBatch>,
29}
30
31impl TimeAxis {
32    /// Returns the [`ComponentDescriptor`] for [`Self::link`].
33    ///
34    /// The corresponding component is [`crate::blueprint::components::LinkAxis`].
35    #[inline]
36    pub fn descriptor_link() -> ComponentDescriptor {
37        ComponentDescriptor {
38            archetype: Some("rerun.blueprint.archetypes.TimeAxis".into()),
39            component: "TimeAxis:link".into(),
40            component_type: Some("rerun.blueprint.components.LinkAxis".into()),
41        }
42    }
43}
44
45static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
46    once_cell::sync::Lazy::new(|| []);
47
48static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
49    once_cell::sync::Lazy::new(|| []);
50
51static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
52    once_cell::sync::Lazy::new(|| [TimeAxis::descriptor_link()]);
53
54static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
55    once_cell::sync::Lazy::new(|| [TimeAxis::descriptor_link()]);
56
57impl TimeAxis {
58    /// The total number of components in the archetype: 0 required, 0 recommended, 1 optional
59    pub const NUM_COMPONENTS: usize = 1usize;
60}
61
62impl ::re_types_core::Archetype for TimeAxis {
63    #[inline]
64    fn name() -> ::re_types_core::ArchetypeName {
65        "rerun.blueprint.archetypes.TimeAxis".into()
66    }
67
68    #[inline]
69    fn display_name() -> &'static str {
70        "Time axis"
71    }
72
73    #[inline]
74    fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
75        REQUIRED_COMPONENTS.as_slice().into()
76    }
77
78    #[inline]
79    fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
80        RECOMMENDED_COMPONENTS.as_slice().into()
81    }
82
83    #[inline]
84    fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
85        OPTIONAL_COMPONENTS.as_slice().into()
86    }
87
88    #[inline]
89    fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
90        ALL_COMPONENTS.as_slice().into()
91    }
92
93    #[inline]
94    fn from_arrow_components(
95        arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
96    ) -> DeserializationResult<Self> {
97        re_tracing::profile_function!();
98        use ::re_types_core::{Loggable as _, ResultExt as _};
99        let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
100        let link = arrays_by_descr
101            .get(&Self::descriptor_link())
102            .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_link()));
103        Ok(Self { link })
104    }
105}
106
107impl ::re_types_core::AsComponents for TimeAxis {
108    #[inline]
109    fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
110        use ::re_types_core::Archetype as _;
111        std::iter::once(self.link.clone()).flatten().collect()
112    }
113}
114
115impl ::re_types_core::ArchetypeReflectionMarker for TimeAxis {}
116
117impl TimeAxis {
118    /// Create a new `TimeAxis`.
119    #[inline]
120    pub fn new() -> Self {
121        Self { link: None }
122    }
123
124    /// Update only some specific fields of a `TimeAxis`.
125    #[inline]
126    pub fn update_fields() -> Self {
127        Self::default()
128    }
129
130    /// Clear all the fields of a `TimeAxis`.
131    #[inline]
132    pub fn clear_fields() -> Self {
133        use ::re_types_core::Loggable as _;
134        Self {
135            link: Some(SerializedComponentBatch::new(
136                crate::blueprint::components::LinkAxis::arrow_empty(),
137                Self::descriptor_link(),
138            )),
139        }
140    }
141
142    /// How should the horizontal/X/time axis be linked across multiple plots?
143    #[inline]
144    pub fn with_link(mut self, link: impl Into<crate::blueprint::components::LinkAxis>) -> Self {
145        self.link = try_serialize_field(Self::descriptor_link(), [link]);
146        self
147    }
148}
149
150impl ::re_byte_size::SizeBytes for TimeAxis {
151    #[inline]
152    fn heap_size_bytes(&self) -> u64 {
153        self.link.heap_size_bytes()
154    }
155}