Skip to content

Simple rust asset handling derive macro for enums, and a proc-macro learning resource!

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

Shadorain/asset-derive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

asset-derive

Docs Crate License TODOs

SummaryTodosDocs


Summary

Simple Rust asset loading derive macro for Enums, and a resource for learning proc-macros!

Please feel free to offer any advice or create a pull request.

The original intent of this library was for compile time loading assets into a binary. This will eventually allow for run-time loading as well, but as for now that will be a future expansion.

TODOs

List of ideas I have at the moment for this project's expansion. Please create an issue for a new item to add to this list, using todo label.

  • Filename prefix
  • Run-time Loading
    • Static (Once on init)
    • Dynamic (Fluid loading)
  • Compile-time Loading

Structure

Since asset-derive is meant to be a procedural macro crate, while also housing a trait implementation as well (to be derived), there is a somewhat complex project structue. This is because of the current annoyance of proc-macro crates having to be defined completely separate to normal crates.

The external API shall stay the same fortunately, asset-derive will now be stuck as the trait implementation crate which depends on asset-derive-macro which houses the actual macro implementation. This is unavoidable for the time being, but I did the best I could to not have the external API change and make it as simple as can be.

Code Tree

asset-derive/       <-- Crate to use (trait implementation)
    src/
    examples/       <-- Houses examples using the trait and macro itself.
    asset-derive/   <-- Actual internal derive macro crate. Will be pulled in by main crate.
        src/

Example

use asset_derive::Asset;

#[derive(Asset)]
#[asset(basepath = "./icons/", ext = "svg")]
enum Icon {
    #[asset(ext = "png")]
    Select,
    Folder,
    #[asset(filename = "folder-dim")]
    FolderDim,
}

Icon::Select.fetch()
Icon::FolderDim.fetch_static()

About

Simple rust asset handling derive macro for enums, and a proc-macro learning resource!

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages