Coder Social home page Coder Social logo

goods's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

goods's Issues

you not an engineer

Hel lo

@zakarumych Please do not call yourself an "Engineer", you are not an engineer.
There is no such thing as engineering in software. Engineering is much more serious and complex and real. Engineering means building real things like turbines and buildings. It is not about sitting behind a keyboard and writing code. Engineering is real, it is not fake and petty like software development.

Prefabs

Similar concept to Asset, but each time Prefab is requested a new instance must be created.
In some cases it can be simply cloned, but oftentimes Prefab should be built again from its data representation.
For example this is the case for entities in ECS. Each time given Prefab is requested a new entity should be created with all required components. As an Asset it would be cached and the same entity id will be returned in the Handle.

Panic when loading more than one processable asset

This example will unexpectedly panic at this unwrap when obtaining the second handle:

use futures_executor::ThreadPool;
use goods::{AssetDefaultFormat, Cache, FileSource, Registry, RonFormat, SyncAsset};
use serde::Deserialize;
use std::{error, fmt, path::Path};

#[derive(Clone, Deserialize)]
struct StringAsset(String);

#[derive(Debug)]
struct Error;

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        fmt::Debug::fmt(self, f)
    }
}

impl error::Error for Error {}

impl SyncAsset for StringAsset {
    type Error = Error;
    type Context = ();
    type Repr = StringAsset;

    fn build(repr: Self::Repr, _: &mut Self::Context) -> Result<Self, Self::Error> {
        Ok(repr)
    }
}

impl AssetDefaultFormat<&'static str> for StringAsset {
    type DefaultFormat = RonFormat;
}

fn main() {
    let registry = Registry::<&'static str>::builder()
        .with(FileSource::new(
            Path::new(env!("CARGO_MANIFEST_DIR")).to_path_buf(),
        ))
        .build();
    let cache = Cache::new(registry, ThreadPool::new().unwrap());
    let handle_1 = cache.load::<StringAsset>("string1.txt");
    let handle_2 = cache.load::<StringAsset>("string2.txt");
}

"string1.txt":

("string 1")

"string2.txt":

("string 2")

Unloading assets

From what I was able to gather, there is currently no way to drop an asset without dropping the whole Cache it's in. Is it possible to implement this functionality in some way?

It would enable manual reloading of assets (alleviating somewhat the need for full-on hot reloading) and freeing of resources taken up by assets no longer needed by the application (e.g., unloading old level on level change in a game).

It might be possible to do this by having the cache hold onto weak references to assets, meaning that if there are no Handles to an asset it should be unloaded.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.