Skip to main content

Loader

Struct Loader 

Source
pub struct Loader { /* private fields */ }
Expand description

One background worker with a bounded request queue and a private AudioCache.

Submission never waits for queue space, but may allocate/free memory and uses std channels. All methods, polling and destruction belong off the audio thread. Dropping the loader closes its queue and waits for accepted requests to finish; their handles remain usable. A dropped handle does not cancel its decode/cache admission. No async runtime or mixer feature is required.

Implementations§

Source§

impl Loader

Source

pub fn new(config: LoaderConfig) -> Result<Self>

Spawn the worker. Thread creation failures return Io.

Source

pub fn load_bytes( &self, name: impl Into<String>, bytes: Vec<u8>, ) -> Result<LoadHandle>

Queue owned encoded bytes under a name. Reusing a cached name returns its original sound. Input size is checked even on cache hits; bytes are not copied.

Source

pub fn load_file(&self, path: impl AsRef<Path>) -> Result<LoadHandle>

Queue a file by its absolute path. Resolving a relative path uses the current directory now; file I/O and size/decode errors arrive through the handle.

Trait Implementations§

Source§

impl Drop for Loader

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.