pub fn asset(kind: AssetKind, bytes: &'static [u8]) -> u32Expand description
Registers one picture and returns the id an [crate::Image] draws it by.
ⓘ
static HERO: &[u8] = include_bytes!("../assets/hero.svg");
rsx! { Image { asset_id: asset(AssetKind::Svg, HERO), height: 240.0 } }Call it wherever the picture is drawn, including in a component body that runs every render. The second call with the same bytes returns the first call’s id and queues nothing, so a screen that draws the same picture every frame registers it once.
The bytes are 'static because a registration is carried by whichever batch the
current call produces, which is not always the call this was made in, and because
include_bytes! is what an application almost always has.