pub struct SharedResources(/* private fields */);Expand description
A window’s handle to the session’s resource registry — Core’s
resources field. A font, image or sound registered through one is
registered for every window in the session, and draws in all of them.
Implementations§
Sourcepub fn add_image(&self, width: u32, height: u32, rgba: Vec<u8>) -> ImageId
pub fn add_image(&self, width: u32, height: u32, rgba: Vec<u8>) -> ImageId
Registers an RGBA image (width * height * 4 bytes).
Sourcepub fn remove_image(&self, id: ImageId) -> bool
pub fn remove_image(&self, id: ImageId) -> bool
Drops an image from the registry. Every window’s atlas forgets its blit at that window’s next frame, and a texture-backed one is dropped from the device by the next frame any window draws.
Sourcepub fn image_size(&self, id: ImageId) -> Option<(u32, u32)>
pub fn image_size(&self, id: ImageId) -> Option<(u32, u32)>
The pixel dimensions behind an image handle, if it is live.
Sourcepub fn add_sound(&self, bytes: Vec<u8>) -> SoundId
pub fn add_sound(&self, bytes: Vec<u8>) -> SoundId
Registers a sound from its encoded file bytes.
Sourcepub fn has_sounds(&self) -> bool
pub fn has_sounds(&self) -> bool
Whether any sound is registered (see Resources::has_sounds).
Sourcepub fn sound(&self, id: SoundId) -> Option<Arc<[u8]>>
pub fn sound(&self, id: SoundId) -> Option<Arc<[u8]>>
The encoded bytes behind a sound handle, if it is live. Cloning the
Arc rather than lending it is what lets the registry be shared:
the caller (an audio backend) holds the bytes, not the borrow.
Sourcepub fn font_family(&self, id: FontId) -> Option<String>
pub fn font_family(&self, id: FontId) -> Option<String>
The registered family name behind a font handle, if it is live.
Trait Implementations§
Source§fn clone(&self) -> SharedResources
fn clone(&self) -> SharedResources
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.