pub struct Handle<A: Asset + ?Sized> { /* private fields */ }Expand description
Resource read-only handle
Implementations§
Source§impl<A: Asset> Handle<A>
impl<A: Asset> Handle<A>
Sourcepub fn read(&self) -> AssetRead<'_, A>
pub fn read(&self) -> AssetRead<'_, A>
Get a reading lock from the asset
Examples found in repository?
examples/assets.rs (line 39)
30fn main() {
31 let mut asset_server = AssetServer::with_root("assets");
32 asset_server.register_loader::<Texture>(Box::new(TextureLoader));
33 asset_server.register_loader::<Audio>(Box::new(AudioLoader));
34 asset_server.load::<Texture>("example.png").unwrap();
35 asset_server.load::<Audio>("music.ogg").unwrap();
36 println!("{asset_server:#?}");
37
38 let audio = asset_server.get_named::<Audio>("music").unwrap();
39 println!("{:?}", audio.read().0);
40 audio.write().0 = 1.0;
41 println!("{:?}", audio.read().0);
42}Sourcepub fn write(&self) -> AssetWrite<'_, A>
pub fn write(&self) -> AssetWrite<'_, A>
Get a writing lock into the asset
Examples found in repository?
examples/assets.rs (line 40)
30fn main() {
31 let mut asset_server = AssetServer::with_root("assets");
32 asset_server.register_loader::<Texture>(Box::new(TextureLoader));
33 asset_server.register_loader::<Audio>(Box::new(AudioLoader));
34 asset_server.load::<Texture>("example.png").unwrap();
35 asset_server.load::<Audio>("music.ogg").unwrap();
36 println!("{asset_server:#?}");
37
38 let audio = asset_server.get_named::<Audio>("music").unwrap();
39 println!("{:?}", audio.read().0);
40 audio.write().0 = 1.0;
41 println!("{:?}", audio.read().0);
42}Trait Implementations§
Auto Trait Implementations§
impl<A> Freeze for Handle<A>where
A: ?Sized,
impl<A> RefUnwindSafe for Handle<A>where
A: ?Sized,
impl<A> Send for Handle<A>where
A: ?Sized,
impl<A> Sync for Handle<A>where
A: ?Sized,
impl<A> Unpin for Handle<A>where
A: ?Sized,
impl<A> UnsafeUnpin for Handle<A>where
A: ?Sized,
impl<A> UnwindSafe for Handle<A>where
A: ?Sized,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more