re_types/components/
texcoord2d.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/components/texcoord2d.fbs".
3
4#![allow(unused_imports)]
5#![allow(unused_parens)]
6#![allow(clippy::clone_on_copy)]
7#![allow(clippy::cloned_instead_of_copied)]
8#![allow(clippy::map_flatten)]
9#![allow(clippy::needless_question_mark)]
10#![allow(clippy::new_without_default)]
11#![allow(clippy::redundant_closure)]
12#![allow(clippy::too_many_arguments)]
13#![allow(clippy::too_many_lines)]
14
15use ::re_types_core::try_serialize_field;
16use ::re_types_core::SerializationResult;
17use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
18use ::re_types_core::{ComponentDescriptor, ComponentName};
19use ::re_types_core::{DeserializationError, DeserializationResult};
20
21/// **Component**: A 2D texture UV coordinate.
22///
23/// Texture coordinates specify a position on a 2D texture.
24/// A range from 0-1 covers the entire texture in the respective dimension.
25/// Unless configured otherwise, the texture repeats outside of this range.
26/// Rerun uses top-left as the origin for UV coordinates.
27///
28///   0     U     1
29/// 0 + --------- →
30///   |           .
31/// V |           .
32///   |           .
33/// 1 ↓ . . . . . .
34///
35/// This is the same convention as in Vulkan/Metal/DX12/WebGPU, but (!) unlike OpenGL,
36/// which places the origin at the bottom-left.
37#[derive(Clone, Debug, Default, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable)]
38#[repr(transparent)]
39pub struct Texcoord2D(pub crate::datatypes::Vec2D);
40
41impl ::re_types_core::Component for Texcoord2D {
42    #[inline]
43    fn descriptor() -> ComponentDescriptor {
44        ComponentDescriptor::new("rerun.components.Texcoord2D")
45    }
46}
47
48::re_types_core::macros::impl_into_cow!(Texcoord2D);
49
50impl ::re_types_core::Loggable for Texcoord2D {
51    #[inline]
52    fn arrow_datatype() -> arrow::datatypes::DataType {
53        crate::datatypes::Vec2D::arrow_datatype()
54    }
55
56    fn to_arrow_opt<'a>(
57        data: impl IntoIterator<Item = Option<impl Into<::std::borrow::Cow<'a, Self>>>>,
58    ) -> SerializationResult<arrow::array::ArrayRef>
59    where
60        Self: Clone + 'a,
61    {
62        crate::datatypes::Vec2D::to_arrow_opt(data.into_iter().map(|datum| {
63            datum.map(|datum| match datum.into() {
64                ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0),
65                ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0),
66            })
67        }))
68    }
69
70    fn from_arrow_opt(
71        arrow_data: &dyn arrow::array::Array,
72    ) -> DeserializationResult<Vec<Option<Self>>>
73    where
74        Self: Sized,
75    {
76        crate::datatypes::Vec2D::from_arrow_opt(arrow_data)
77            .map(|v| v.into_iter().map(|v| v.map(Self)).collect())
78    }
79
80    #[inline]
81    fn from_arrow(arrow_data: &dyn arrow::array::Array) -> DeserializationResult<Vec<Self>>
82    where
83        Self: Sized,
84    {
85        crate::datatypes::Vec2D::from_arrow(arrow_data).map(bytemuck::cast_vec)
86    }
87}
88
89impl<T: Into<crate::datatypes::Vec2D>> From<T> for Texcoord2D {
90    fn from(v: T) -> Self {
91        Self(v.into())
92    }
93}
94
95impl std::borrow::Borrow<crate::datatypes::Vec2D> for Texcoord2D {
96    #[inline]
97    fn borrow(&self) -> &crate::datatypes::Vec2D {
98        &self.0
99    }
100}
101
102impl std::ops::Deref for Texcoord2D {
103    type Target = crate::datatypes::Vec2D;
104
105    #[inline]
106    fn deref(&self) -> &crate::datatypes::Vec2D {
107        &self.0
108    }
109}
110
111impl std::ops::DerefMut for Texcoord2D {
112    #[inline]
113    fn deref_mut(&mut self) -> &mut crate::datatypes::Vec2D {
114        &mut self.0
115    }
116}
117
118impl ::re_byte_size::SizeBytes for Texcoord2D {
119    #[inline]
120    fn heap_size_bytes(&self) -> u64 {
121        self.0.heap_size_bytes()
122    }
123
124    #[inline]
125    fn is_pod() -> bool {
126        <crate::datatypes::Vec2D>::is_pod()
127    }
128}