Rust Embed
Generates rust code to embed resource files into your rust executable
You can use this to embed your css, js and images into a single executable.
This is similar to go-bindata.
This is similar to pony-embed.
Note:
This is not the same as std macros,
include_bytes!
include_str!
these are macros which generate code at compile time whereas rust-embed generates code when the command is run. And rust-embed works only on folders.
Installation
cargo install rust-embed
Documentation
It exposes a function to serve all files stored in your assets folder which is useful for webservers. So now you can statically compile all your assets i.e. your /static/ or /public/ folders into the rust executable and serve them. So now you don't need to package your assets with your executable.
// This will return the data for the file specified by the file path or an error if it cannot be found.
list // This will return the list of all files which were included
get
Examples
A simple http server which serves its resources directly.
To compile the assets for the examples,
rust-embed examples/public/ examples/assets.rs
To run the examples,
cargo run --example http
extern crate hyper;
use Server;
use Request;
use Response;
use Fresh;
Go Rusketeers! The power is yours!
TODO
rewrite this to use compiler plugins and macro so that we can use that instead