pub trait MultiResourceComponent {
type Output;
// Required method
fn render_multi(&self, resources: &ResourceContext) -> Option<Self::Output>;
}Expand description
Multi-resource component that depends on multiple resource types
This trait is for components that need access to multiple resources. It provides a more flexible rendering interface.
§Example
ⓘ
impl MultiResourceComponent for StatisticsComponent {
type Output = Paragraph<'static>;
fn render_multi(&self, resources: &ResourceContext) -> Option<Self::Output> {
let ctx = resources.try_get::<GameContext>()?;
let city = resources.try_get::<CityMap>()?;
Some(Paragraph::new(format!("Pop: {}", city.population)))
}
}Required Associated Types§
Required Methods§
Sourcefn render_multi(&self, resources: &ResourceContext) -> Option<Self::Output>
fn render_multi(&self, resources: &ResourceContext) -> Option<Self::Output>
Render the component using multiple resources
This method provides access to the full ResourceContext, allowing the component to fetch multiple resource types.
§Arguments
resources- The resource context to access game state
§Returns
Some(widget)- Successfully rendered widgetNone- Required resources not found
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".