1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/rust/api.rs
// Based on "crates/re_types/definitions/rerun/archetypes/clear.fbs".
#![allow(trivial_numeric_casts)]
#![allow(unused_parens)]
#![allow(clippy::clone_on_copy)]
#![allow(clippy::iter_on_single_items)]
#![allow(clippy::map_flatten)]
#![allow(clippy::match_wildcard_for_single_variants)]
#![allow(clippy::needless_question_mark)]
#![allow(clippy::new_without_default)]
#![allow(clippy::redundant_closure)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::too_many_lines)]
#![allow(clippy::unnecessary_cast)]
/// **Archetype**: Empties all the components of an entity.
///
/// ## Example
///
/// ### Flat
/// ```ignore
/// //! Log a batch of 3D arrows.
///
/// use rerun::external::glam;
///
/// fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let (rec, storage) =
/// rerun::RecordingStreamBuilder::new("rerun_example_clear_simple").memory()?;
///
/// #[rustfmt::skip]
/// let (vectors, origins, colors) = (
/// [glam::Vec3::X, glam::Vec3::NEG_Y, glam::Vec3::NEG_X, glam::Vec3::Y],
/// [(-0.5, 0.5, 0.0), (0.5, 0.5, 0.0), (0.5, -0.5, 0.0), (-0.5, -0.5, 0.0)],
/// [(200, 0, 0), (0, 200, 0), (0, 0, 200), (200, 0, 200)],
/// );
///
/// // Log a handful of arrows.
/// for (i, ((vector, origin), color)) in vectors.into_iter().zip(origins).zip(colors).enumerate() {
/// rec.log(
/// format!("arrows/{i}"),
/// &rerun::Arrows3D::from_vectors([vector])
/// .with_origins([origin])
/// .with_colors([rerun::Color::from_rgb(color.0, color.1, color.2)]),
/// )?;
/// }
///
/// // Now clear them, one by one on each tick.
/// for i in 0..vectors.len() {
/// rec.log(format!("arrows/{i}"), &rerun::Clear::flat())?;
/// }
///
/// rerun::native_viewer::show(storage.take())?;
/// Ok(())
/// }
/// ```
/// <center>
/// <picture>
/// <source media="(max-width: 480px)" srcset="https://static.rerun.io/clear_simple/2f5df95fcc53e9f0552f65670aef7f94830c5c1a/480w.png">
/// <source media="(max-width: 768px)" srcset="https://static.rerun.io/clear_simple/2f5df95fcc53e9f0552f65670aef7f94830c5c1a/768w.png">
/// <source media="(max-width: 1024px)" srcset="https://static.rerun.io/clear_simple/2f5df95fcc53e9f0552f65670aef7f94830c5c1a/1024w.png">
/// <source media="(max-width: 1200px)" srcset="https://static.rerun.io/clear_simple/2f5df95fcc53e9f0552f65670aef7f94830c5c1a/1200w.png">
/// <img src="https://static.rerun.io/clear_simple/2f5df95fcc53e9f0552f65670aef7f94830c5c1a/full.png" width="640">
/// </picture>
/// </center>
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Clear {
pub is_recursive: crate::components::ClearIsRecursive,
}
static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> =
once_cell::sync::Lazy::new(|| ["rerun.components.ClearIsRecursive".into()]);
static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> =
once_cell::sync::Lazy::new(|| ["rerun.components.ClearIndicator".into()]);
static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> =
once_cell::sync::Lazy::new(|| ["rerun.components.InstanceKey".into()]);
static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize]> =
once_cell::sync::Lazy::new(|| {
[
"rerun.components.ClearIsRecursive".into(),
"rerun.components.ClearIndicator".into(),
"rerun.components.InstanceKey".into(),
]
});
impl Clear {
pub const NUM_COMPONENTS: usize = 3usize;
}
/// Indicator component for the [`Clear`] [`crate::Archetype`]
pub type ClearIndicator = crate::GenericIndicatorComponent<Clear>;
impl crate::Archetype for Clear {
type Indicator = ClearIndicator;
#[inline]
fn name() -> crate::ArchetypeName {
"rerun.archetypes.Clear".into()
}
#[inline]
fn indicator() -> crate::MaybeOwnedComponentBatch<'static> {
static INDICATOR: ClearIndicator = ClearIndicator::DEFAULT;
crate::MaybeOwnedComponentBatch::Ref(&INDICATOR)
}
#[inline]
fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> {
REQUIRED_COMPONENTS.as_slice().into()
}
#[inline]
fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> {
RECOMMENDED_COMPONENTS.as_slice().into()
}
#[inline]
fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> {
OPTIONAL_COMPONENTS.as_slice().into()
}
#[inline]
fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> {
ALL_COMPONENTS.as_slice().into()
}
#[inline]
fn from_arrow(
arrow_data: impl IntoIterator<
Item = (::arrow2::datatypes::Field, Box<dyn ::arrow2::array::Array>),
>,
) -> crate::DeserializationResult<Self> {
re_tracing::profile_function!();
use crate::{Loggable as _, ResultExt as _};
let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data
.into_iter()
.map(|(field, array)| (field.name, array))
.collect();
let is_recursive = {
let array = arrays_by_name
.get("rerun.components.ClearIsRecursive")
.ok_or_else(crate::DeserializationError::missing_data)
.with_context("rerun.archetypes.Clear#is_recursive")?;
<crate::components::ClearIsRecursive>::from_arrow_opt(&**array)
.with_context("rerun.archetypes.Clear#is_recursive")?
.into_iter()
.next()
.flatten()
.ok_or_else(crate::DeserializationError::missing_data)
.with_context("rerun.archetypes.Clear#is_recursive")?
};
Ok(Self { is_recursive })
}
}
impl crate::AsComponents for Clear {
fn as_component_batches(&self) -> Vec<crate::MaybeOwnedComponentBatch<'_>> {
re_tracing::profile_function!();
use crate::Archetype as _;
[
Some(Self::indicator()),
Some((&self.is_recursive as &dyn crate::ComponentBatch).into()),
]
.into_iter()
.flatten()
.collect()
}
#[inline]
fn num_instances(&self) -> usize {
1
}
}
impl Clear {
pub fn new(is_recursive: impl Into<crate::components::ClearIsRecursive>) -> Self {
Self {
is_recursive: is_recursive.into(),
}
}
}