1
- use rerun:: {
2
- external:: arrow2, ChunkStore , ChunkStoreConfig , Component , ComponentDescriptor , VersionPolicy ,
3
- } ;
4
-
5
- #[ derive( Debug , Clone , Copy ) ]
6
- struct CustomPosition3D ( rerun:: components:: Position3D ) ;
7
-
8
- impl rerun:: SizeBytes for CustomPosition3D {
9
- #[ inline]
10
- fn heap_size_bytes ( & self ) -> u64 {
11
- 0
12
- }
13
- }
14
-
15
- impl rerun:: Loggable for CustomPosition3D {
16
- #[ inline]
17
- fn arrow2_datatype ( ) -> arrow2:: datatypes:: DataType {
18
- rerun:: components:: Position3D :: arrow2_datatype ( )
19
- }
20
-
21
- #[ inline]
22
- fn to_arrow2_opt < ' a > (
23
- data : impl IntoIterator < Item = Option < impl Into < std:: borrow:: Cow < ' a , Self > > > > ,
24
- ) -> rerun:: SerializationResult < Box < dyn arrow2:: array:: Array > >
25
- where
26
- Self : ' a ,
27
- {
28
- rerun:: components:: Position3D :: to_arrow2_opt (
29
- data. into_iter ( ) . map ( |opt| opt. map ( Into :: into) . map ( |c| c. 0 ) ) ,
30
- )
31
- }
32
- }
33
-
34
- impl rerun:: Component for CustomPosition3D {
35
- #[ inline]
36
- fn descriptor ( ) -> ComponentDescriptor {
37
- ComponentDescriptor :: new ( "user.CustomPosition3D" )
38
- }
39
- }
1
+ use rerun:: { ChunkStore , ChunkStoreConfig , ComponentBatch , ComponentDescriptor , VersionPolicy } ;
40
2
41
3
struct CustomPoints3D {
42
- positions : Vec < CustomPosition3D > ,
4
+ positions : Vec < rerun :: components :: Position3D > ,
43
5
colors : Option < Vec < rerun:: components:: Color > > ,
44
6
}
45
7
@@ -49,13 +11,15 @@ impl CustomPoints3D {
49
11
}
50
12
51
13
fn overridden_position_descriptor ( ) -> ComponentDescriptor {
52
- CustomPosition3D :: descriptor ( )
53
- . or_with_archetype_name ( || "user.CustomPoints3D" . into ( ) )
54
- . or_with_archetype_field_name ( || "custom_positions" . into ( ) )
14
+ ComponentDescriptor {
15
+ archetype_name : Some ( "user.CustomPoints3D" . into ( ) ) ,
16
+ archetype_field_name : Some ( "custom_positions" . into ( ) ) ,
17
+ component_name : "user.CustomPosition3D" . into ( ) ,
18
+ }
55
19
}
56
20
57
21
fn overridden_color_descriptor ( ) -> ComponentDescriptor {
58
- rerun:: components:: Color :: descriptor ( )
22
+ < rerun:: components:: Color as rerun :: Component > :: descriptor ( )
59
23
. or_with_archetype_name ( || "user.CustomPoints3D" . into ( ) )
60
24
. or_with_archetype_field_name ( || "colors" . into ( ) )
61
25
}
@@ -66,15 +30,12 @@ impl rerun::AsComponents for CustomPoints3D {
66
30
[
67
31
Some ( Self :: indicator ( ) . to_batch ( ) ) ,
68
32
Some (
69
- rerun:: ComponentBatchCowWithDescriptor :: new (
70
- & self . positions as & dyn rerun:: ComponentBatch ,
71
- )
72
- . with_descriptor_override ( Self :: overridden_position_descriptor ( ) ) ,
33
+ self . positions
34
+ . with_descriptor ( Self :: overridden_position_descriptor ( ) ) ,
73
35
) ,
74
- self . colors . as_ref ( ) . map ( |colors| {
75
- rerun:: ComponentBatchCowWithDescriptor :: new ( colors as & dyn rerun:: ComponentBatch )
76
- . with_descriptor_override ( Self :: overridden_color_descriptor ( ) )
77
- } ) ,
36
+ self . colors
37
+ . as_ref ( )
38
+ . map ( |colors| colors. with_descriptor ( Self :: overridden_color_descriptor ( ) ) ) ,
78
39
]
79
40
. into_iter ( )
80
41
. flatten ( )
@@ -83,12 +44,12 @@ impl rerun::AsComponents for CustomPoints3D {
83
44
}
84
45
85
46
fn example ( rec : & rerun:: RecordingStream ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
86
- let position = CustomPosition3D ( rerun:: components:: Position3D :: new ( 1.0 , 2.0 , 3.0 ) ) ;
87
- let color = rerun:: components:: Color :: new ( 0xFF00FFFF ) ;
47
+ let positions = rerun:: components:: Position3D :: new ( 1.0 , 2.0 , 3.0 ) ;
48
+ let colors = rerun:: components:: Color :: new ( 0xFF00FFFF ) ;
88
49
89
50
let points = CustomPoints3D {
90
- positions : vec ! [ position ] ,
91
- colors : Some ( vec ! [ color ] ) ,
51
+ positions : vec ! [ positions ] ,
52
+ colors : Some ( vec ! [ colors ] ) ,
92
53
} ;
93
54
94
55
rec. log_static ( "data" , & points as _ ) ?;
@@ -152,7 +113,7 @@ fn check_tags(rec: &rerun::RecordingStream) {
152
113
ComponentDescriptor {
153
114
archetype_name: Some ( "user.CustomPoints3D" . into( ) ) ,
154
115
archetype_field_name: Some ( "colors" . into( ) ) ,
155
- component_name: rerun:: components:: Color :: name ( ) ,
116
+ component_name: " rerun. components. Color" . into ( ) ,
156
117
} ,
157
118
ComponentDescriptor {
158
119
archetype_name: Some ( "user.CustomPoints3D" . into( ) ) ,
0 commit comments