Skip to content

Commit e537874

Browse files
authored
arrow2-convert migration 4: support serde-based types in codegen (#3902)
This introduces the `rust.attr.serde_type` attribute, allowing you to use any `serde`-compatible Rust types in our IDL. ``` table ViewportLayout ( "attr.rust.derive": "PartialEq", "attr.rust.override_crate": "re_viewport" ) { space_view_keys: [ubyte] (order: 100, "attr.rust.serde_type": "std::collections::BTreeSet<re_viewer_context::SpaceViewId>"); tree: [ubyte] (order: 101, "attr.rust.serde_type": "egui_tiles::Tree<re_viewer_context::SpaceViewId>"); auto_layout: bool (order: 102); } ``` This unblocks further blueprint experimentations, and is the last blocker to sunset `arrow2-convert`. - `SpaceViewComponent`, `SpaceViewMaximized` & `ViewportLayout` are now all implemented that way. - `re_viewport` is now free of `arrow2-convert`. --- `arrow2-convert` migration PR series: - #3853 - #3855 - #3897 - #3902 - #3917
1 parent f3a5ae2 commit e537874

File tree

161 files changed

+4855
-2689
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+4855
-2689
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
include "./blueprint/auto_space_views.fbs";
22
include "./blueprint/panel_view.fbs";
3+
include "./blueprint/space_view_component.fbs";
4+
include "./blueprint/space_view_maximized.fbs";
5+
include "./blueprint/viewport_layout.fbs";
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
include "arrow/attributes.fbs";
2+
include "python/attributes.fbs";
3+
include "rust/attributes.fbs";
4+
5+
include "rerun/datatypes.fbs";
6+
include "rerun/attributes.fbs";
7+
8+
namespace rerun.blueprint;
9+
10+
// ---
11+
12+
/// A view of a space.
13+
///
14+
/// Unstable. Used for the ongoing blueprint experimentations.
15+
table SpaceViewComponent (
16+
"attr.rust.derive_only": "Clone",
17+
"attr.rust.override_crate": "re_viewport"
18+
) {
19+
space_view: [ubyte] (order: 100, "attr.rust.serde_type": "crate::SpaceViewBlueprint");
20+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
include "arrow/attributes.fbs";
2+
include "python/attributes.fbs";
3+
include "rust/attributes.fbs";
4+
5+
include "rerun/datatypes.fbs";
6+
include "rerun/attributes.fbs";
7+
8+
namespace rerun.blueprint;
9+
10+
// ---
11+
12+
/// Whether a space view is maximized.
13+
///
14+
/// Unstable. Used for the ongoing blueprint experimentations.
15+
table SpaceViewMaximized (
16+
"attr.arrow.transparent",
17+
"attr.rust.derive": "Copy, Default, PartialEq, Eq",
18+
"attr.rust.override_crate": "re_viewport",
19+
"attr.rust.repr": "transparent",
20+
"attr.rust.tuple_struct"
21+
) {
22+
id: [ubyte] (order: 100, nullable, "attr.rust.serde_type": "re_viewer_context::SpaceViewId");
23+
}
24+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
include "arrow/attributes.fbs";
2+
include "python/attributes.fbs";
3+
include "rust/attributes.fbs";
4+
5+
include "rerun/datatypes.fbs";
6+
include "rerun/attributes.fbs";
7+
8+
namespace rerun.blueprint;
9+
10+
// ---
11+
12+
/// A view of a space.
13+
///
14+
/// Unstable. Used for the ongoing blueprint experimentations.
15+
table ViewportLayout (
16+
"attr.rust.derive": "PartialEq",
17+
"attr.rust.override_crate": "re_viewport"
18+
) {
19+
/// space_view_keys
20+
space_view_keys: [ubyte] (order: 100, "attr.rust.serde_type": "std::collections::BTreeSet<re_viewer_context::SpaceViewId>");
21+
22+
/// tree
23+
tree: [ubyte] (order: 101, "attr.rust.serde_type": "egui_tiles::Tree<re_viewer_context::SpaceViewId>");
24+
25+
/// auto_layout
26+
auto_layout: bool (order: 102);
27+
}

crates/re_types/definitions/rust/attributes.fbs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,11 @@ attribute "attr.rust.new_pub_crate";
4141
/// an object of kind `Blueprint` with `attr.rust.override_crate=re_viewport`, the final
4242
/// object will be generated in `crates/re_viewport/src/blueprint`.
4343
attribute "attr.rust.override_crate";
44+
45+
/// Specify on an object field of type `[ubyte]` in order to (de)serialize using a pre-existing
46+
/// `serde` implementation.
47+
///
48+
/// Everything else works the same, include how module names are derived: e.g. if you define
49+
/// an object of kind `Blueprint` with `attr.rust.override_crate=re_viewport`, the final
50+
/// object will be generated in `crates/re_viewport/src/blueprint`.
51+
attribute "attr.rust.serde_type";

crates/re_types/src/archetypes/annotation_context.rs

Lines changed: 20 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)