pub fn load_from<A, F, N, P, S>(
        &self,
        name: N,
        format: F,
        options: F::Options,
        source: &S,
        mut progress: P,
        storage: &AssetStorage<A>,
    ) -> Handle<A>
    where
        A: Asset,
        F: Format<A> + 'static,
        N: Into<String>,
        P: Progress,
        S: AsRef<str> + Eq + Hash + ?Sized,
        String: Borrow<S>,
    {
        #[cfg(feature = "profiler")]
        profile_scope!("load_asset_from");
        use progress::Tracker;

        let name = name.into();
        let source = source.as_ref();

        let format_name = F::NAME;
        let source_name = match source {
            "" => "[default source]",
            other => other,
        };

        let handle = storage.allocate();

        debug!(
            "{:?}: Loading asset {:?} with format {:?} from source {:?} (handle id: {:?})",
            A::NAME,
            name,
            format_name,
            source_name,
            handle,
        );

        let source = match source {
            "" => self.directory.clone(),
            source => self.source(source),
        };

        progress.add_assets(1);
        let tracker = progress.create_tracker();

        let handle_clone = handle.clone();
        let processed = storage.processed.clone();

        let hot_reload = self.hot_reload;

        let cl = move || {
            #[cfg(feature = "profiler")]
            profile_scope!("load_asset_from_worker");
            let data = format
                .import(name.clone(), source, options, hot_reload)
                .chain_err(|| ErrorKind::Format(F::NAME));
            let tracker = Box::new(tracker) as Box<Tracker>;

            processed.push(Processed::NewAsset {
                data,
                handle,
                name,
                tracker,
            });
        };
        self.pool.spawn(cl);

        handle_clone
    }
/// Loads an asset with a given id and format from a custom source.
/// The actual work is done in a worker thread, thus this method immediately returns a handle.
///
/// ## Parameters
///
/// * `name`: this is just an identifier for the asset, most likely a file name e.g.
///   `"meshes/a.obj"`
/// * `format`: A format struct which loads bytes from a `source` and produces `Asset::Data`
///   with them
/// * `options`: Additional parameter to `format` to configure how exactly the data will
///   be created. This could e.g. be mipmap levels for textures.
/// * `source`: An identifier for a source which has previously been added using `with_source`
/// * `progress`: A tracker which will be notified of assets which have been imported
/// * `storage`: The asset storage which can be fetched from the ECS `World` using
///   `read_resource`.
Loads an asset with a given id and format from a custom source.
The actual work is done in a worker thread, thus this method immediately returns a handle.
Loads an asset with a given id and format from a custom source . The actual work is done in a worker thread thus this method immediately returns a handle .
pub fn load_from<A, F, N, P, S>(
        &self,
        name: N,
        format: F,
        options: F::Options,
        source: &S,
        mut progress: P,
        storage: &AssetStorage<A>,
    ) -> Handle<A>
    where
        A: Asset,
        F: Format<A> + 'static,
        N: Into<String>,
        P: Progress,
        S: AsRef<str> + Eq + Hash + ?Sized,
        String: Borrow<S>,
    {
        #[cfg(feature = "profiler")]
        profile_scope!("load_asset_from");
        use progress::Tracker;
        let name = name.into();
        let source = source.as_ref();
        let format_name = F::NAME;
        let source_name = match source {
            "" => "[default source]",
            other => other,
        };
        let handle = storage.allocate();
        debug!(
            "{:?}: Loading asset {:?} with format {:?} from source {:?} (handle id: {:?})",
            A::NAME,
            name,
            format_name,
            source_name,
            handle,
        );
        let source = match source {
            "" => self.directory.clone(),
            source => self.source(source),
        };
        progress.add_assets(1);
        let tracker = progress.create_tracker();
        let handle_clone = handle.clone();
        let processed = storage.processed.clone();
        let hot_reload = self.hot_reload;
        let cl = move || {
            #[cfg(feature = "profiler")]
            profile_scope!("load_asset_from_worker");
            let data = format
                .import(name.clone(), source, options, hot_reload)
                .chain_err(|| ErrorKind::Format(F::NAME));
            let tracker = Box::new(tracker) as Box<Tracker>;
            processed.push(Processed::NewAsset {
                data,
                handle,
                name,
                tracker,
            });
        };
        self.pool.spawn(cl);
        handle_clone
    }
pub fn load_from < A , F , N , P , S > ( & self , name : N , format : F , options : F :: Options , source : & S , mut progress : P , storage : & AssetStorage < A > , ) -> Handle < A > where A : Asset , F : Format < A > + ' static , N : Into < String > , P : Progress , S : AsRef < str > + Eq + Hash + ? Sized , String : Borrow < S > , { # [ cfg ( feature " " ) ] profile_scope ! ( " " ) ; use progress :: Tracker ; let name = name . into ( ) ; let source = source . as_ref ( ) ; let format_name = F :: NAME ; let source_name = match source { " " => " " , other => other , } ; let handle = storage . allocate ( ) ; debug ! ( " " A NAME name format_name source_name handle ) ; let source = match source { " " => self . directory . clone ( ) , source => self . source ( source ) , } ; progress . add_assets ( 1 ) ; let tracker = progress . create_tracker ( ) ; let handle_clone = handle . clone ( ) ; let processed = storage . processed . clone ( ) ; let hot_reload = self . hot_reload ; let cl = move | | { # [ cfg ( feature " " ) ] profile_scope ! ( " " ) ; let data = format . import ( name . clone ( ) , source , options , hot_reload ) . chain_err ( | | ErrorKind :: Format ( F :: NAME ) ) ; let tracker = Box :: new ( tracker ) as Box < Tracker > ; processed . push ( Processed :: NewAsset { data , handle , name , tracker , } ) ; } ; self . pool . spawn ( cl ) ; handle_clone }
Loads an asset with a given id and format from a custom source.
Loads an asset with a given id and format from a custom source .
&self
name
N
format
F
options
F::Options
source
&S
progress
P
storage
&AssetStorage<A>
&self
name
N
format
F
options
F::Options
source
&S
progress
P
storage
&AssetStorage<A>