re_component_fallbacks/lib.rs
1//! This crate implements various component fallbacks.
2//!
3//! The only entry point is [`create_component_fallback_registry`], which registers all component type, and
4//! component identifier fallbacks to a new [`FallbackProviderRegistry`].
5//! This should be called by `re_viewer` on startup.
6//!
7//! ## Recommendation for where to put fallbacks
8//!
9//! Component fallbacks should be registered here **if**:
10//! - They're not the same as the `provided_fallback` from
11//! reflection, i.e the default implementation is already what you want.
12//! - And they're used in more than one view.
13//! - And doesn't require specific dependencies from views that makes it not possible to add here without
14//! adding dependencies.
15//!
16//! Otherwise the fallback should be registered in the view class it's used in, on that view classes' `on_register` method.
17
18use re_viewer_context::FallbackProviderRegistry;
19
20mod blueprint_component_fallbacks;
21mod component_fallbacks;
22
23/// Creates a new [`FallbackProviderRegistry`] and registers built-in
24/// type and archetype field fallbacks.
25pub fn create_component_fallback_registry() -> FallbackProviderRegistry {
26 let mut registry = FallbackProviderRegistry::default();
27
28 blueprint_component_fallbacks::type_fallbacks(&mut registry);
29 blueprint_component_fallbacks::archetype_field_fallbacks(&mut registry);
30
31 component_fallbacks::type_fallbacks(&mut registry);
32 component_fallbacks::archetype_field_fallbacks(&mut registry);
33
34 registry
35}