pub enum Resource {
Audio(AudioBuffer),
F32(Arc<[f32]>),
F64(Arc<[f64]>),
Bytes(Arc<[u8]>),
Text(Arc<str>),
Any(Arc<dyn Any + Send + Sync>),
}Expand description
Rust-native resource registry and resource values. A resource stored in the manager.
Variants§
Audio(AudioBuffer)
Shared decoded audio buffer.
F32(Arc<[f32]>)
Shared floating-point samples.
F64(Arc<[f64]>)
Shared double-precision samples.
Bytes(Arc<[u8]>)
Raw shared bytes.
Text(Arc<str>)
UTF-8 text payload.
Any(Arc<dyn Any + Send + Sync>)
Any custom Rust type wrapped in Arc.
Implementations§
Source§impl Resource
impl Resource
Sourcepub fn audio(buffer: AudioBuffer) -> Self
pub fn audio(buffer: AudioBuffer) -> Self
Wraps a decoded audio buffer.
Sourcepub fn bytes(data: impl Into<Arc<[u8]>>) -> Self
pub fn bytes(data: impl Into<Arc<[u8]>>) -> Self
Wraps a byte slice in an owned shared resource.
Sourcepub fn custom<T>(value: T) -> Self
pub fn custom<T>(value: T) -> Self
Wraps any Send + Sync + 'static Rust value in an opaque resource.
Wraps an already shared Rust value in an opaque resource.
Sourcepub fn as_audio(&self) -> Option<&AudioBuffer>
pub fn as_audio(&self) -> Option<&AudioBuffer>
Attempts to view the resource as a decoded audio buffer.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Resource
impl !RefUnwindSafe for Resource
impl Send for Resource
impl Sync for Resource
impl Unpin for Resource
impl !UnwindSafe for Resource
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