Skip to main content

SharedResources

Struct SharedResources 

Source
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§

Source§

impl SharedResources

Source

pub fn add_image(&self, width: u32, height: u32, rgba: Vec<u8>) -> ImageId

Registers an RGBA image (width * height * 4 bytes).

Source

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.

Source

pub fn image_size(&self, id: ImageId) -> Option<(u32, u32)>

The pixel dimensions behind an image handle, if it is live.

Source

pub fn add_sound(&self, bytes: Vec<u8>) -> SoundId

Registers a sound from its encoded file bytes.

Source

pub fn has_sounds(&self) -> bool

Whether any sound is registered (see Resources::has_sounds).

Source

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.

Source

pub fn font_family(&self, id: FontId) -> Option<String>

The registered family name behind a font handle, if it is live.

Trait Implementations§

Source§

impl Clone for SharedResources

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.