Skip to main content

Module template

Module template 

Source
Expand description

Functionality that relates to the Template trait.

Structs§

FnTemplate
A Template driven by a function that returns an output. This is used to create “free floating” templates without defining a new type. See template for usage.
InnerSceneEntityReference
The inner struct actually storing the unique index
SceneEntityReference
A unique reference for a named entity in a scene. Usually used by bevy_scene in generated code
SceneEntityReferences
Struct to store a mapping from SceneEntityReference to Entity which are used for resolving #Name entity references in bsn! macros
TemplateContext
The context used to apply the current Template. This contains a reference to the entity that the template is being applied to (via an EntityWorldMut).
TemplateTuple
A wrapper over a tuple of Template implementations, which also implements Template. This exists because Template cannot be directly implemented for tuples of Template implementations.
VecTemplate
A Template for Vec.

Enums§

EntityTemplate
A Template reference to an Entity.
OptionTemplate
A Template for Option.

Traits§

BuiltInTemplate
Roughly equivalent to FromTemplate, but does not have a blanket implementation for Default + Clone types. This is generally used for common generic collection types like Option and Vec, which have Default + Clone impls and therefore also pick up the FromTemplate behavior. This is fine when the T in Option<T> is not “templated” (ex: does not have an explicit FromTemplate derive). But if T is “templated”, such as Option<Handle<T>>, then it would require a manual #[template(OptionTemplate<HandleTemplate<T>>)] field annotation. This isn’t fun to type out.
FromTemplate
FromTemplate is implemented for types that can be produced by a specific, canonical Template. This creates a way to correlate to the Template using the desired template output type. This is used by Bevy’s scene system.
SpecializeFromTemplate
This is used to help improve error messages related to FromTemplate specialization. Developers should generally just ignore this trait and read the error message when they encounter it.
Template
A Template is something that, given a spawn context (target Entity, World, etc), can produce a Template::Output.

Functions§

template
Returns a “free floating” template for a given func. This prevents the need to define a custom type for one-off templates.

Derive Macros§

FromTemplate
Derives FromTemplate.