pub struct LoadFrom<U, L>(_);
Expand description

Loads assets from another type.

An example case for this is to easily load wrapper types, which are needed when the wrapped type is defined in another crate.

Example

use assets_manager::{Asset, loader::{LoadFrom, ParseLoader}};
use std::net::IpAddr;

struct Ip(IpAddr);

impl From<IpAddr> for Ip {
    fn from(ip: IpAddr) -> Ip {
        Ip(ip)
    }
}

impl Asset for Ip {
    const EXTENSION: &'static str = "ip";
    type Loader = LoadFrom<IpAddr, ParseLoader>;
}

Trait Implementations§

Formats the value using the given formatter. Read more
Loads an asset from its raw bytes representation. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.