#![allow(unused_braces)]
#![allow(unused_imports)]
#![allow(unused_parens)]
#![allow(clippy::allow_attributes)]
#![allow(clippy::clone_on_copy)]
#![allow(clippy::cloned_instead_of_copied)]
#![allow(clippy::map_flatten)]
#![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::wildcard_imports)]
use ::re_types_core::SerializationResult;
use ::re_types_core::try_serialize_field;
use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
use ::re_types_core::{ComponentDescriptor, ComponentType};
use ::re_types_core::{DeserializationError, DeserializationResult};
#[derive(Clone, Debug, PartialEq, Default)]
pub struct Image {
pub buffer: Option<SerializedComponentBatch>,
pub format: Option<SerializedComponentBatch>,
pub opacity: Option<SerializedComponentBatch>,
pub draw_order: Option<SerializedComponentBatch>,
}
impl Image {
#[inline]
pub fn descriptor_buffer() -> ComponentDescriptor {
ComponentDescriptor {
archetype: Some("rerun.archetypes.Image".into()),
component: "Image:buffer".into(),
component_type: Some("rerun.components.ImageBuffer".into()),
}
}
#[inline]
pub fn descriptor_format() -> ComponentDescriptor {
ComponentDescriptor {
archetype: Some("rerun.archetypes.Image".into()),
component: "Image:format".into(),
component_type: Some("rerun.components.ImageFormat".into()),
}
}
#[inline]
pub fn descriptor_opacity() -> ComponentDescriptor {
ComponentDescriptor {
archetype: Some("rerun.archetypes.Image".into()),
component: "Image:opacity".into(),
component_type: Some("rerun.components.Opacity".into()),
}
}
#[inline]
pub fn descriptor_draw_order() -> ComponentDescriptor {
ComponentDescriptor {
archetype: Some("rerun.archetypes.Image".into()),
component: "Image:draw_order".into(),
component_type: Some("rerun.components.DrawOrder".into()),
}
}
}
static REQUIRED_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 2usize]> =
std::sync::LazyLock::new(|| [Image::descriptor_buffer(), Image::descriptor_format()]);
static RECOMMENDED_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 0usize]> =
std::sync::LazyLock::new(|| []);
static OPTIONAL_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 2usize]> =
std::sync::LazyLock::new(|| [Image::descriptor_opacity(), Image::descriptor_draw_order()]);
static ALL_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 4usize]> =
std::sync::LazyLock::new(|| {
[
Image::descriptor_buffer(),
Image::descriptor_format(),
Image::descriptor_opacity(),
Image::descriptor_draw_order(),
]
});
impl Image {
pub const NUM_COMPONENTS: usize = 4usize;
}
impl ::re_types_core::Archetype for Image {
#[inline]
fn name() -> ::re_types_core::ArchetypeName {
"rerun.archetypes.Image".into()
}
#[inline]
fn display_name() -> &'static str {
"Image"
}
#[inline]
fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
REQUIRED_COMPONENTS.as_slice().into()
}
#[inline]
fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
RECOMMENDED_COMPONENTS.as_slice().into()
}
#[inline]
fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
OPTIONAL_COMPONENTS.as_slice().into()
}
#[inline]
fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
ALL_COMPONENTS.as_slice().into()
}
#[inline]
fn from_arrow_components(
arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
) -> DeserializationResult<Self> {
re_tracing::profile_function!();
use ::re_types_core::{Loggable as _, ResultExt as _};
let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
let buffer = arrays_by_descr
.get(&Self::descriptor_buffer())
.map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_buffer()));
let format = arrays_by_descr
.get(&Self::descriptor_format())
.map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_format()));
let opacity = arrays_by_descr
.get(&Self::descriptor_opacity())
.map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_opacity()));
let draw_order = arrays_by_descr
.get(&Self::descriptor_draw_order())
.map(|array| {
SerializedComponentBatch::new(array.clone(), Self::descriptor_draw_order())
});
Ok(Self {
buffer,
format,
opacity,
draw_order,
})
}
}
impl ::re_types_core::AsComponents for Image {
#[inline]
fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
use ::re_types_core::Archetype as _;
[
self.buffer.clone(),
self.format.clone(),
self.opacity.clone(),
self.draw_order.clone(),
]
.into_iter()
.flatten()
.collect()
}
}
impl ::re_types_core::ArchetypeReflectionMarker for Image {}
impl Image {
#[inline]
pub fn new(
buffer: impl Into<crate::components::ImageBuffer>,
format: impl Into<crate::components::ImageFormat>,
) -> Self {
Self {
buffer: try_serialize_field(Self::descriptor_buffer(), [buffer]),
format: try_serialize_field(Self::descriptor_format(), [format]),
opacity: None,
draw_order: None,
}
}
#[inline]
pub fn update_fields() -> Self {
Self::default()
}
#[inline]
pub fn clear_fields() -> Self {
use ::re_types_core::Loggable as _;
Self {
buffer: Some(SerializedComponentBatch::new(
crate::components::ImageBuffer::arrow_empty(),
Self::descriptor_buffer(),
)),
format: Some(SerializedComponentBatch::new(
crate::components::ImageFormat::arrow_empty(),
Self::descriptor_format(),
)),
opacity: Some(SerializedComponentBatch::new(
crate::components::Opacity::arrow_empty(),
Self::descriptor_opacity(),
)),
draw_order: Some(SerializedComponentBatch::new(
crate::components::DrawOrder::arrow_empty(),
Self::descriptor_draw_order(),
)),
}
}
#[inline]
pub fn columns<I>(
self,
_lengths: I,
) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
where
I: IntoIterator<Item = usize> + Clone,
{
let columns = [
self.buffer
.map(|buffer| buffer.partitioned(_lengths.clone()))
.transpose()?,
self.format
.map(|format| format.partitioned(_lengths.clone()))
.transpose()?,
self.opacity
.map(|opacity| opacity.partitioned(_lengths.clone()))
.transpose()?,
self.draw_order
.map(|draw_order| draw_order.partitioned(_lengths.clone()))
.transpose()?,
];
Ok(columns.into_iter().flatten())
}
#[inline]
pub fn columns_of_unit_batches(
self,
) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
let len_buffer = self.buffer.as_ref().map(|b| b.array.len());
let len_format = self.format.as_ref().map(|b| b.array.len());
let len_opacity = self.opacity.as_ref().map(|b| b.array.len());
let len_draw_order = self.draw_order.as_ref().map(|b| b.array.len());
let len = None
.or(len_buffer)
.or(len_format)
.or(len_opacity)
.or(len_draw_order)
.unwrap_or(0);
self.columns(std::iter::repeat_n(1, len))
}
#[inline]
pub fn with_buffer(mut self, buffer: impl Into<crate::components::ImageBuffer>) -> Self {
self.buffer = try_serialize_field(Self::descriptor_buffer(), [buffer]);
self
}
#[inline]
pub fn with_many_buffer(
mut self,
buffer: impl IntoIterator<Item = impl Into<crate::components::ImageBuffer>>,
) -> Self {
self.buffer = try_serialize_field(Self::descriptor_buffer(), buffer);
self
}
#[inline]
pub fn with_format(mut self, format: impl Into<crate::components::ImageFormat>) -> Self {
self.format = try_serialize_field(Self::descriptor_format(), [format]);
self
}
#[inline]
pub fn with_many_format(
mut self,
format: impl IntoIterator<Item = impl Into<crate::components::ImageFormat>>,
) -> Self {
self.format = try_serialize_field(Self::descriptor_format(), format);
self
}
#[inline]
pub fn with_opacity(mut self, opacity: impl Into<crate::components::Opacity>) -> Self {
self.opacity = try_serialize_field(Self::descriptor_opacity(), [opacity]);
self
}
#[inline]
pub fn with_many_opacity(
mut self,
opacity: impl IntoIterator<Item = impl Into<crate::components::Opacity>>,
) -> Self {
self.opacity = try_serialize_field(Self::descriptor_opacity(), opacity);
self
}
#[inline]
pub fn with_draw_order(mut self, draw_order: impl Into<crate::components::DrawOrder>) -> Self {
self.draw_order = try_serialize_field(Self::descriptor_draw_order(), [draw_order]);
self
}
#[inline]
pub fn with_many_draw_order(
mut self,
draw_order: impl IntoIterator<Item = impl Into<crate::components::DrawOrder>>,
) -> Self {
self.draw_order = try_serialize_field(Self::descriptor_draw_order(), draw_order);
self
}
}
impl ::re_byte_size::SizeBytes for Image {
#[inline]
fn heap_size_bytes(&self) -> u64 {
self.buffer.heap_size_bytes()
+ self.format.heap_size_bytes()
+ self.opacity.heap_size_bytes()
+ self.draw_order.heap_size_bytes()
}
}