pub struct ResourceRegistry<'a> { /* private fields */ }Expand description
Resource registration facade for user code.
Resource handles are stable, cheap to copy, and safe to store in widget state. Register resources during app construction and pass handles through UI state instead of moving raw image/font blobs through render paths.
Implementations§
Source§impl ResourceRegistry<'_>
impl ResourceRegistry<'_>
Sourcepub fn register_font(
&mut self,
handle: FontHandle,
font: RegisteredFont,
) -> Result<()>
pub fn register_font( &mut self, handle: FontHandle, font: RegisteredFont, ) -> Result<()>
Register a font with an explicit stable handle.
Sourcepub fn font_bytes(&mut self, data: impl Into<Vec<u8>>) -> Result<FontHandle>
pub fn font_bytes(&mut self, data: impl Into<Vec<u8>>) -> Result<FontHandle>
Register a TrueType, OpenType, WOFF, or WOFF2 font and allocate a stable handle. Fails when the data is not such a font.
Sourcepub fn image(
&mut self,
handle: ImageHandle,
image: RegisteredImage,
) -> Result<()>
pub fn image( &mut self, handle: ImageHandle, image: RegisteredImage, ) -> Result<()>
Register an image with an explicit stable handle.
Sourcepub fn rgba_image(
&mut self,
width: u32,
height: u32,
data: impl Into<Vec<u8>>,
) -> Result<ImageHandle>
pub fn rgba_image( &mut self, width: u32, height: u32, data: impl Into<Vec<u8>>, ) -> Result<ImageHandle>
Register RGBA8 pixels and allocate an image handle.
Sourcepub fn svg_image(&mut self, data: impl AsRef<[u8]>) -> Result<ImageHandle>
pub fn svg_image(&mut self, data: impl AsRef<[u8]>) -> Result<ImageHandle>
Register SVG bytes at their intrinsic size and allocate an image handle.
Sourcepub fn svg_image_with_handle(
&mut self,
handle: ImageHandle,
data: impl AsRef<[u8]>,
) -> Result<()>
pub fn svg_image_with_handle( &mut self, handle: ImageHandle, data: impl AsRef<[u8]>, ) -> Result<()>
Register SVG bytes at their intrinsic size with an explicit handle.
Sourcepub fn svg_image_at_size(
&mut self,
width: u32,
height: u32,
data: impl AsRef<[u8]>,
) -> Result<ImageHandle>
pub fn svg_image_at_size( &mut self, width: u32, height: u32, data: impl AsRef<[u8]>, ) -> Result<ImageHandle>
Rasterize SVG bytes at an explicit size and allocate an image handle.
Sourcepub fn svg_image_at_size_with_handle(
&mut self,
handle: ImageHandle,
width: u32,
height: u32,
data: impl AsRef<[u8]>,
) -> Result<()>
pub fn svg_image_at_size_with_handle( &mut self, handle: ImageHandle, width: u32, height: u32, data: impl AsRef<[u8]>, ) -> Result<()>
Rasterize SVG bytes at an explicit size and handle.
Sourcepub fn embedded_svg_image(
&mut self,
resource: EmbeddedSvgImageResource,
) -> Result<()>
pub fn embedded_svg_image( &mut self, resource: EmbeddedSvgImageResource, ) -> Result<()>
Register one compile-time embedded SVG resource.
Sourcepub fn embedded_svg_images(
&mut self,
resources: impl IntoIterator<Item = EmbeddedSvgImageResource>,
) -> Result<()>
pub fn embedded_svg_images( &mut self, resources: impl IntoIterator<Item = EmbeddedSvgImageResource>, ) -> Result<()>
Register multiple compile-time embedded SVG resources.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for ResourceRegistry<'a>
impl<'a> !Send for ResourceRegistry<'a>
impl<'a> !Sync for ResourceRegistry<'a>
impl<'a> !UnwindSafe for ResourceRegistry<'a>
impl<'a> Forget for ResourceRegistry<'a>
impl<'a> Freeze for ResourceRegistry<'a>
impl<'a> Move for ResourceRegistry<'a>
impl<'a> Unpin for ResourceRegistry<'a>
impl<'a> UnsafeUnpin for ResourceRegistry<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.