pub trait Widget:
Sized
+ Send
+ Sync
+ 'static {
// Required methods
fn name() -> &'static str;
fn parser_tag() -> &'static str;
fn spawn(entity: Entity, attrs: &Attributes, world: &mut World);
}Expand description
Thin surface implemented by #[derive(Widget)].
The derive emits the plugin struct + the parser-glue impl; widget authors only fill in the per-widget systems.
Required Methods§
Sourcefn parser_tag() -> &'static str
fn parser_tag() -> &'static str
Markup tag handled by the widget. The derive picks this up from
#[widget(tag = "...")]. <Type>::register() publishes it into
the registry behind is_widget_tag_registered, which is what
makes the lumenc parser accept the tag.
Sourcefn spawn(entity: Entity, attrs: &Attributes, world: &mut World)
fn spawn(entity: Entity, attrs: &Attributes, world: &mut World)
Make entity this widget, reading its props out of attrs.
The spawner calls this for every element whose tag the widget was
registered for (register_widget), once the element’s own
components are in place and before its children spawn: entity is
that element and attrs every attribute it was written with. The
derive emits a body that parses the #[widget(prop)] fields out of
attrs over the struct’s Default and inserts the component on
entity. Outside markup, spawn the entity first
(world.spawn_empty().id()) and hand it in.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.