{"id":21214925,"url":"https://github.com/hadronized/warmy","last_synced_at":"2025-12-12T14:53:28.284Z","repository":{"id":26582389,"uuid":"109268092","full_name":"hadronized/warmy","owner":"hadronized","description":"Hot-reloading loadable and reloadable resources","archived":false,"fork":false,"pushed_at":"2020-05-12T15:05:27.000Z","size":215,"stargazers_count":215,"open_issues_count":5,"forks_count":14,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-10T20:19:08.528Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hadronized.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-02T13:25:29.000Z","updated_at":"2024-09-11T06:04:58.000Z","dependencies_parsed_at":"2022-07-27T05:46:21.516Z","dependency_job_id":null,"html_url":"https://github.com/hadronized/warmy","commit_stats":null,"previous_names":["hadronized/warmy","phaazon/warmy"],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hadronized%2Fwarmy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hadronized%2Fwarmy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hadronized%2Fwarmy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hadronized%2Fwarmy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hadronized","download_url":"https://codeload.github.com/hadronized/warmy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225633241,"owners_count":17499936,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T21:32:21.428Z","updated_at":"2025-12-12T14:53:28.249Z","avatar_url":"https://github.com/hadronized.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# warmy, hot-reloading loadable and reloadable resources\n\n[![Build Status](https://travis-ci.org/phaazon/warmy.svg?branch=master)](https://travis-ci.org/phaazon/warmy)\n[![dependency status](https://deps.rs/repo/github/phaazon/warmy/status.svg)](https://deps.rs/repo/github/phaazon/warmy)\n[![crates.io](https://img.shields.io/crates/v/warmy.svg)](https://crates.io/crates/warmy)\n[![docs.rs](https://docs.rs/warmy/badge.svg)](https://docs.rs/warmy)\n![License](https://img.shields.io/badge/license-BSD3-blue.svg?style=flat)\n\n\u003c!-- cargo-sync-readme start --\u003e\n\nHot-reloading, loadable and reloadable resources.\n\n# Foreword\n\nResources are objects that live in a store and can be hot-reloaded – i.e. they can change\nwithout you interacting with them. There are currently two types of resources supported:\n\n  - **Filesystem resources**, which are resources that live on the filesystem and have a real\n    representation (i.e. a *file* for short).\n  - **Logical resources**, which are resources that are computed and don’t directly require any\n    I/O.\n\nResources are referred to by *keys*. A *key* is a typed index that contains enough information\nto uniquely identify a resource living in a store.\n\nThis small introduction will give you enough information and examples to get your feet wet with\n`warmy`. If you want to know more, feel free to visit the documentation of submodules.\n\n## Feature-gates\n\nHere’s an exhaustive list of feature-gates available:\n\n  - `\"arc\"`: changes the internal representation of resources in order to use [`Arc`] and\n    [`Mutex`], allowing for cross-thread sharing of resources. This is a current patch in the\n    waiting of a better asynchronous solution.\n  - `\"json\"`: provides a [`Json`] type that you can use as loading method to automatically load\n    any type that implements [`serde::Deserialize`] and encoded as [JSON]. You don’t even have\n    to implement [`Load`] by your own! **Enabled by default**\n  - `\"ron-impl\"`: provides a [`Ron`] type that you can use as loading method to automatically\n    load any type that implemetns [`serde::Deserialize`] and encoded as [RON].\n  - `\"toml-impl\"`: provides a [`Toml`] type that you can use as loading method to automatically\n    load any type that implements [`serde::Deserialize`] and encoded as [TOML].\n\n# Loading a resource\n\n*Loading* is the action of getting an object out of a given location. That location is often\nyour filesystem but it can also be a memory area – mapped files or memory parsing. In `warmy`,\nloading is implemented *per-type*: this means you have to implement a trait on a type so that\nany object of that type can be loaded. The trait to implement is [`Load`]. We’re interested in\nfour items:\n\n  - The [`Store`], which holds and caches resources.\n  - The [`Key`] type variable, used to tell `warmy` which kind of resource your store knows how\n    to represent and what information the key must contain.\n  - The [`Load::Error`] associated type, that is the error type used when loading fails.\n  - The [`Load::load`] method, which is the method called to load your resource in a given\n    store.\n\n## Store\n\nA [`Store`] is responsible for holding and caching resources. Each [`Store`] is associated with a\n*root*, which is a path on the filesystem all filesystem resources will come from. You create a\n[`Store`] by giving it a [`StoreOpt`], which is used to customize the [`Store`] – if you don’t\nneed it nor care about it for the moment, just use `Store::default`.\n\n```rust\nuse warmy::{SimpleKey, Store, StoreOpt};\n\nlet res = Store::\u003c(), SimpleKey\u003e::new(StoreOpt::default());\n\nmatch res {\n  Err(e) =\u003e {\n    eprintln!(\"unable to create the store: {}\", e);\n  }\n\n  Ok(store) =\u003e ()\n}\n```\n\nAs you can see, the [`Store`] has two type variables. These type variables refer to the types of\n*context* you want to use with your resources and the type of keys. For now we’ll use `()` for\nthe context as we don’t want contexts – but more to come – and the common [`SimpleKey`] type\nfor keys. Keep on reading.\n\n## The `Key` type variable\n\nThe key type must implement [`Key`], which is the class of types recognized as keys by\n`warmy`. In theory, you shouldn’t worry about that trait because `warmy` already ships with some\nkey types.\n\n\u003e If you really want to implement [`Key`], have a look at its documentation for further details.\n\nKeys are a core concept in `warmy` as they are objects that uniquely represent resources –\nshould they be on a filesystem or in memory. You will refer to your resources with those keys.\n\n### Special case: simple keys\n\nA *simple key* (a.k.a. [`SimpleKey`]) is a key used to express common situations in which you\nmight have resources from the filesystem and from logical locations. It’s provided for\nconvenience, so that you don’t have to write that type and implement [`Key`]. In most\nsituations, it should be enough for you – of course, if you need more details, feel free to\ndefine your own key type.\n\n## The `Load::Error` associated type\n\nThis associated type must be set to the type of error your loading implementation might\ngenerate. For instance, if you load something with [serde-json], you might want to set it to\n°serde_json::Error`. This way of doing is very common in Rust; you shouldn’t feel uncomfortable\nwith it.\n\n\u003e On a general note, you should always try to stick to precise and accurate errors types. Avoid\n\u003e simple types such as `String` or `u64` and prefer to use detailed, algebraic datatypes.\n\n## The [`Load::load`] method\n\nThis is the entry-point method. [`Load::load`] must be implemented in order for `warmy` to know\nhow to read the resource. Let’s implement it for two types: one that represents a resource on\nthe filesystem, one computed from memory.\n\n```rust\nuse std::fmt;\nuse std::fs::File;\nuse std::io::{self, Read};\nuse warmy::{Load, Loaded, SimpleKey, Storage};\n\n// Possible errors that might happen.\n#[derive(Debug)]\nenum Error {\n  CannotLoadFromFS,\n  CannotLoadFromLogical,\n  IOError(io::Error)\n}\n\nimpl fmt::Display for Error {\n  fn fmt(\u0026self, f: \u0026mut fmt::Formatter) -\u003e Result\u003c(), fmt::Error\u003e {\n    match *self {\n      Error::CannotLoadFromFS =\u003e f.write_str(\"cannot load from file system\"),\n      Error::CannotLoadFromLogical =\u003e f.write_str(\"cannot load from logical\"),\n      Error::IOError(ref e) =\u003e write!(f, \"IO error: {}\", e),\n    }\n  }\n}\n\n// The resource we want to take from a file.\nstruct FromFS(String);\n\n// The resource we want to compute from memory.\nstruct FromMem(usize);\n\nimpl\u003cC\u003e Load\u003cC, SimpleKey\u003e for FromFS {\n  type Error = Error;\n\n  fn load(\n    key: SimpleKey,\n    storage: \u0026mut Storage\u003cC, SimpleKey\u003e,\n    _: \u0026mut C\n  ) -\u003e Result\u003cLoaded\u003cSelf, SimpleKey\u003e, Self::Error\u003e {\n    // as we only accept filesystem here, we’ll ensure the key is a filesystem one\n    match key {\n      SimpleKey::Path(path) =\u003e {\n        let mut fh = File::open(path).map_err(Error::IOError)?;\n        let mut s = String::new();\n        fh.read_to_string(\u0026mut s);\n\n        Ok(FromFS(s).into())\n      }\n\n      SimpleKey::Logical(_) =\u003e Err(Error::CannotLoadFromLogical)\n    }\n  }\n}\n\nimpl\u003cC\u003e Load\u003cC, SimpleKey\u003e for FromMem {\n  type Error = Error;\n\n  fn load(\n    key: SimpleKey,\n    storage: \u0026mut Storage\u003cC, SimpleKey\u003e,\n    _: \u0026mut C\n  ) -\u003e Result\u003cLoaded\u003cSelf, SimpleKey\u003e, Self::Error\u003e {\n    // ensure we only accept logical resources\n    match key {\n      SimpleKey::Logical(key) =\u003e {\n        // this is a bit dummy, but why not?\n        Ok(FromMem(key.len()).into())\n      }\n\n      SimpleKey::Path(_) =\u003e Err(Error::CannotLoadFromFS)\n    }\n  }\n}\n```\n\nAs you can see here, there’re a few new concepts:\n\n  - [`Loaded`]: A type you have to wrap your object in to express dependencies. Because it\n    implements `From\u003cT\u003e for Loaded\u003cT\u003e`, you can use `.into()` to state you don’t have any\n    dependencies.\n  - [`Storage`]: This is the minimal structure that holds and caches your resources. A [`Store`]\n    is actually the *interface structure* you will handle in your client code.\n\n## Express your dependencies with Loaded\n\nAn object of type [`Loaded`] gives information to `warmy` about your dependencies. Upon loading –\ni.e. your resource is successfully *loaded* – you can tell `warmy` which resources your loaded\nresource depends on. This is a bit tricky, though, because a difference is important to make\nthere.\n\nWhen you implement [`Load::load`], you are handed a [`Storage`]. You can use that [`Storage`]\nto load additional resources and gather them in your resources. When those additional resources\nget reloaded, if you directly embed the resources in your object, you will automatically see the\nautomated resources – that is the whole point of this crate! However, if you don’t express a\n*dependency relationship* to those resources, your former resource will not reload – it will\njust use automatically-synced resources, but it will not reload itself. This is a bit touchy\nbut let’s take an example of a typical situation where you might want to use dependencies and\nthen dependency graphs:\n\n  1. You want to load an object that is represented by aggregation of several values /\n     resources.\n  2. You choose to use a *logical resource* and guess all the files to load from.\n  3. When you implement [`Load::load`], you open several files, load them into memory, compose\n     them and finally end up with your object.\n  4. You return your object from [`Load::load`] with no dependencies (i.e. you use `.into()` on\n     it).\n\nWhat is going to happen here is that if any file your resource depends on changes, since they\ndon’t have a proper resource in the store, your object will see nothing. A typical\nsolution there is to load those files as proper resources and put those keys in the returned\n[`Loaded`] object to express that you *depend on the reloading of the objects referred by these\nkeys*. It’s a bit touchy but you will eventually find yourself in a situation when this\n[`Loaded`] thing will help you. You will then use [`Loaded::with_deps`]. See the documentation of\n[`Loaded`] for further information.\n\n\u003e Fun fact: logical resources were introduced to solve that problem along with dependency\n\u003e graphs.\n\n## Let’s get some things!\n\nWhen you have implemented [`Load`], you’re set and ready to get (cached) resources. You have\nseveral functions to achieve that goal:\n\n  - [`Store::get`], used to get a resource. This will effectively load it if it’s the first time\n    it’s asked. If it’s not, it will use a cached version.\n  - [`Store::get_proxied`], a special version of [`Store::get`]. If the initial loading\n    (non-cached) fails to load (missing resource, fail to parse, whatever), a *proxy* will be\n    used – passed in to [`Store::get_proxied`]. This value is lazy though, so if the loading\n    succeeds, that value won’t ever be evaluated.\n\nLet’s focus on [`Store::get`] for this tutorial.\n\n```rust\nuse std::fmt;\nuse std::fs::File;\nuse std::io::{self, Read};\nuse std::path::Path;\nuse warmy::{Load, Loaded, SimpleKey, Store, StoreOpt, Storage};\n\n// Possible errors that might happen.\n#[derive(Debug)]\nenum Error {\n  CannotLoadFromFS,\n  CannotLoadFromLogical,\n  IOError(io::Error)\n}\n\nimpl fmt::Display for Error {\n  fn fmt(\u0026self, f: \u0026mut fmt::Formatter) -\u003e Result\u003c(), fmt::Error\u003e {\n    match *self {\n      Error::CannotLoadFromFS =\u003e f.write_str(\"cannot load from file system\"),\n      Error::CannotLoadFromLogical =\u003e f.write_str(\"cannot load from logical\"),\n      Error::IOError(ref e) =\u003e write!(f, \"IO error: {}\", e),\n    }\n  }\n}\n\n// The resource we want to take from a file.\nstruct FromFS(String);\n\nimpl\u003cC\u003e Load\u003cC, SimpleKey\u003e for FromFS {\n  type Error = Error;\n\n  fn load(\n    key: SimpleKey,\n    storage: \u0026mut Storage\u003cC, SimpleKey\u003e,\n    _: \u0026mut C\n  ) -\u003e Result\u003cLoaded\u003cSelf, SimpleKey\u003e, Self::Error\u003e {\n    // as we only accept filesystem here, we’ll ensure the key is a filesystem one\n    match key {\n      SimpleKey::Path(path) =\u003e {\n        let mut fh = File::open(path).map_err(Error::IOError)?;\n        let mut s = String::new();\n        fh.read_to_string(\u0026mut s);\n\n        Ok(FromFS(s).into())\n      }\n\n      SimpleKey::Logical(_) =\u003e Err(Error::CannotLoadFromLogical)\n    }\n  }\n}\n\nfn main() {\n  // we don’t need a context, so we’re using this mutable reference to unit\n  let ctx = \u0026mut ();\n  let mut store: Store\u003c(), SimpleKey\u003e = Store::new(StoreOpt::default()).expect(\"store creation\");\n\n  let my_resource = store.get::\u003cFromFS\u003e(\u0026Path::new(\"/foo/bar/zoo.json\").into(), ctx);\n\n  // …\n\n  // imagine that you’re in an event loop now and the resource has changed\n  store.sync(ctx); // synchronize all resources (e.g. my_resource)\n}\n```\n\n# Reloading a resource\n\nMost of the interesting concept of `warmy` is to enable you to hot-reload resources without\nhaving to re-run your application. This is done via two items:\n\n  - [`Load::reload`], a method called whenever an object must be reloaded.\n  - [`Store::sync`], a method to synchronize a [`Store`].\n\nThe [`Load::reload`] function is very straight-forward: it’s called when the resource changes.\nThis situation happens:\n\n  - Either when the resource is on the filesystem (the file changes).\n  - Or if it’s a dependent resource of one that has reloaded.\n\nSee the documentation of [`Load::reload`] for further details.\n\n# Context inspection\n\nA context is a special value you can access to via a mutable reference when loading or\nreloading. If you don’t need any, it’s highly recommended not to use `()` when implementing\n`Load\u003cC\u003e` but leave it as type variable so that it compose better – i.e. `impl\u003cC\u003e Load\u003cC\u003e`.\n\nIf you’re writing a library and need to have access to a specific value in a context, it’s also\nrecommended not to set the context type variable to the type of your context directly. If you do\nthat, no one will be able to use your library because types won’t match – or people will accept\nto be restrained to your only types. A typical way to deal with that is by constraining a\ntype variable. The [`Inspect`] trait was introduced for this very purpose. For\ninstance:\n\n```rust\nuse std::fmt;\nuse std::io;\nuse warmy::{Inspect, Load, Loaded, SimpleKey, Store, StoreOpt, Storage};\n\n// Possible errors that might happen.\n#[derive(Debug)]\nenum Error {\n  CannotLoadFromFS,\n  CannotLoadFromLogical,\n  IOError(io::Error)\n}\n\nimpl fmt::Display for Error {\n  fn fmt(\u0026self, f: \u0026mut fmt::Formatter) -\u003e Result\u003c(), fmt::Error\u003e {\n    match *self {\n      Error::CannotLoadFromFS =\u003e f.write_str(\"cannot load from file system\"),\n      Error::CannotLoadFromLogical =\u003e f.write_str(\"cannot load from logical\"),\n      Error::IOError(ref e) =\u003e write!(f, \"IO error: {}\", e),\n    }\n  }\n}\n\nstruct Foo;\n\nstruct Ctx {\n  nb_res_loaded: usize\n}\n\nimpl\u003cC\u003e Load\u003cC, SimpleKey\u003e for Foo where Foo: for\u003c'a\u003e Inspect\u003c'a, C, \u0026'a mut Ctx\u003e {\n  type Error = Error;\n\n  fn load(\n    key: SimpleKey,\n    storage: \u0026mut Storage\u003cC, SimpleKey\u003e,\n    ctx: \u0026mut C\n  ) -\u003e Result\u003cLoaded\u003cSelf, SimpleKey\u003e, Self::Error\u003e {\n    Self::inspect(ctx).nb_res_loaded += 1; // magic happens here!\n\n    Ok(Foo.into())\n  }\n}\n\nfn main() {\n  use warmy::{Res, Store, StoreOpt};\n\n  let mut store: Store\u003cCtx, SimpleKey\u003e = Store::new(StoreOpt::default()).unwrap();\n  let mut ctx = Ctx { nb_res_loaded: 0 };\n\n  let r: Res\u003cFoo\u003e = store.get(\u0026\"test-0\".into(), \u0026mut ctx).unwrap();\n}\n```\n\nIn this example, because the context value we want is the same as the [`Store`]’s context, a\nuniversal implementor of [`Inspect`] enables you to directly [`inspect`] the context. However,\nif you wanted to inspect it more precisely, like with `\u0026mut usize`, you would need to write an\nimplementation of [`Inspect`] for your types:\n\n```rust\nuse std::fmt;\nuse std::io;\nuse warmy::{Inspect, Load, Loaded, SimpleKey, Store, StoreOpt, Storage};\n\n// Possible errors that might happen.\n#[derive(Debug)]\nenum Error {\n  CannotLoadFromFS,\n  CannotLoadFromLogical,\n  IOError(io::Error)\n}\n\nimpl fmt::Display for Error {\n  fn fmt(\u0026self, f: \u0026mut fmt::Formatter) -\u003e Result\u003c(), fmt::Error\u003e {\n    match *self {\n      Error::CannotLoadFromFS =\u003e f.write_str(\"cannot load from file system\"),\n      Error::CannotLoadFromLogical =\u003e f.write_str(\"cannot load from logical\"),\n      Error::IOError(ref e) =\u003e write!(f, \"IO error: {}\", e),\n    }\n  }\n}\n\nstruct Foo;\n\nstruct Ctx {\n  nb_res_loaded: usize\n}\n\n// this implementor states how the inspection should occur for Foo when the context has type\n// Ctx: by targetting a mutable reference on a usize (i.e. the counter)\nimpl\u003c'a\u003e Inspect\u003c'a, Ctx, \u0026'a mut usize\u003e for Foo {\n  fn inspect(ctx: \u0026mut Ctx) -\u003e \u0026mut usize {\n    \u0026mut ctx.nb_res_loaded\n  }\n}\n\n// notice the usize instead of Ctx here\nimpl\u003cC\u003e Load\u003cC, SimpleKey\u003e for Foo where Foo: for\u003c'a\u003e Inspect\u003c'a, C, \u0026'a mut usize\u003e {\n  type Error = Error;\n\n  fn load(\n    key: SimpleKey,\n    storage: \u0026mut Storage\u003cC, SimpleKey\u003e,\n    ctx: \u0026mut C\n  ) -\u003e Result\u003cLoaded\u003cSelf, SimpleKey\u003e, Self::Error\u003e {\n    *Self::inspect(ctx) += 1; // direct access to the counter\n\n    Ok(Foo.into())\n  }\n}\n```\n\n# Load methods\n\n`warmy` supports load methods. Those are used to specify several ways to load an object of a\ngiven type. By default, [`Load`] is implemented with the *default method* – which is `()`. If\nyou want more methods, you can set the type parameter to something else when implementing\n[`Load`].\n\nYou can also find several *methods* centralized in here, but you definitely don’t have to use\nthem.\n\n## Universal JSON support\n\nThe crate supports *universal JSON implementation*. You can use it via the\n[`Json`] type.\n\n\u003e Universal JSON support is feature-gated with `\"json\"`.\n\nUniversal JSON can help and make your life and implementations easier. Basically, it means that\nany type that implements [`serde::Deserialize`] can be loaded and hot-reloaded by `warmy`\nwith zero boilerplate from your side, just by asking `warmy` to get the given scarse resource.\nThis is done with the [`Store::get_by`] or [`Store::get_proxied_by`] methods.\n\n```rust\nuse serde::Deserialize;\nuse warmy::{Res, SimpleKey, Store, StoreOpt};\nuse warmy::json::Json;\nuse std::thread::sleep;\nuse std::time::Duration;\n\n#[derive(Debug, Deserialize)]\n#[serde(rename_all = \"snake_case\")]\nstruct Dog {\n  name: String,\n  gender: Gender\n}\n\nimpl Default for Dog {\n  fn default() -\u003e Self {\n    Dog {\n      name: \"Norbert\".to_owned(),\n      gender: Gender::Male\n    }\n  }\n}\n\n#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq)]\n#[serde(rename_all = \"snake_case\")]\nenum Gender {\n  Female,\n  Male\n}\n\nfn main() {\n  let mut store: Store\u003c(), SimpleKey\u003e = Store::new(StoreOpt::default()).unwrap();\n  let ctx = \u0026mut ();\n\n  let resource: Result\u003cRes\u003cDog\u003e, _\u003e = store.get_by(\u0026SimpleKey::from_path(\"/dog.json\"), ctx, Json);\n\n  match resource {\n    Ok(dog) =\u003e {\n      loop {\n        store.sync(ctx);\n\n        println!(\"Dog is {} and is a {:?}\", dog.borrow().name, dog.borrow().gender);\n        sleep(Duration::from_millis(1000));\n      }\n    }\n\n    Err(e) =\u003e eprintln!(\"{}\", e)\n  }\n}\n```\n\n## Universal TOML support\n\nThe crate also supports *universal TOML implementation*. That implementation is available via\nthe [`Toml`] type.\n\n\u003e Universal TOML support is feature-gated with `\"toml-impl\"`.\n\nThe working mechanism is the same as with [universal JSON support](#universal-json-support).\n\n# Resource discovery\n\nResource discovery is available via a simple mechanism: every time a new resource is available\non the filesystem, a closure of your choice is called. This closure is passed the [`Storage`]\nof your [`Store`] along with its associated context, enabling you to insert new resources on\nthe fly.\n\nThis is a bit different than the first option: this enables you to populate the store with\nresources you don’t know yet – e.g. a texture is saved in the store’s root and gets\nautomatically added and reacted to.\n\nThe feature is available via the [`StoreOpt`] object you have to create prior to generating a\nnew [`Store`]. See the [`StoreOpt::set_discovery`] and [`StoreOpt::discovery`] functions for\nfurther details on how to use the resource discovery mechanism.\n\n[serde-json]: https://crates.io/crates/serde_json\n[serde_json::Error]: https://docs.serde.rs/serde_json/struct.Error.html\n[VFS]: https://en.wikipedia.org/wiki/Virtual_file_system\n[`Key`]: crate::load::Key\n[`Load`]: crate::load::Load\n[`Load::Error`]: crate::load::Load::Error\n[`Load::load`]: crate::load::Load::load\n[`Load::reload`]: crate::load::Load::reload\n[`Loaded`]: crate::load::Loaded\n[`Loaded::with_deps`]: crate::load::Loaded::with_deps\n[`Json`]: crate::json::Json\n[`Toml`]: crate::toml::Toml\n[`Ron`]: crate::ron::Ron\n[`Storage`]: crate::load::Storage\n[`Store`]: crate::load::Store\n[`Store::get`]: crate::load::Storage::get\n[`Store::get_by`]: crate::load::Storage::get_by\n[`Store::get_proxied`]: crate::load::Storage::get_proxied\n[`Store::get_proxied_by`]: crate::load::Storage::get_proxied_by\n[`Store::sync`]: crate::load::Store::sync\n[`StoreOpt`]: crate::load::StoreOpt\n[`StoreOpt::set_discovery`]: crate::load::StoreOpt::set_discovery\n[`StoreOpt::discovery`]: crate::load::StoreOpt::discovery\n[`SimpleKey`]: crate::key::SimpleKey\n[`Inspect`]: crate::context::Inspect\n[`inspect`]: crate::context::Inspect::inspect\n[`serde::Deserialize`]: https://docs.rs/serde/1.0.85/serde/trait.Deserialize.html\n[`Arc`]: std::sync::Arc\n[`Mutex`]: std::sync::Mutex\n[JSON]: https://www.json.org\n[TOML]: https://github.com/toml-lang/toml\n[RON]: https://github.com/ron-rs/ron\n\n\u003c!-- cargo-sync-readme end --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhadronized%2Fwarmy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhadronized%2Fwarmy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhadronized%2Fwarmy/lists"}