Code Monkey home page Code Monkey logo

rust-embed's People

Contributors

alexw-gh avatar alyti avatar apognu avatar azuremarker avatar bbaovanc avatar billyb2 avatar buckram123 avatar cad97 avatar cuviper avatar djmarcin avatar dusterthefirst avatar frederikhors avatar gowee avatar hongquan avatar hwittenborn avatar ignatenkobrain avatar jaztec avatar lazywalker avatar lopopolo avatar lukad avatar mbme avatar msmith491 avatar orhun avatar osiewicz avatar paolobarbolini avatar pyrossh avatar renovate-bot avatar smoelius avatar tangent128 avatar vemoo avatar

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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

rust-embed's Issues

Compiles very slowly when including large files

When I use the macro in release mode to include a large file (I first tried with ~500 kB) it takes a very long time to compile. The culprit here is the huge vec![..] literal which seems to be very expensive.

Using include_bytes! would solve the problem because it's a compiler built-in that doesn't create a Vector and push one Byte at a time into it.

See my PR #16.

To reproduce run

dd if=/dev/urandom of=examples/public/index.html bs=1k count=500; time cargo run --release --example basic

Rocket example doesn't compile: can't find crate for `rocket_codegen`

D:\3rdparty\rust-embed [master ≡]> cargo run --example rocket
←[0m←[0m←[1m←[32m    Updating←[0m registry `https://github.com/rust-lang/crates.io-index`
←[0m←[0m←[1m←[32m   Compiling←[0m winapi v0.3.5
←[0m←[0m←[1m←[32m   Compiling←[0m unicode-xid v0.0.4
←[0m←[0m←[1m←[32m   Compiling←[0m quote v0.3.15
←[0m←[0m←[1m←[32m   Compiling←[0m synom v0.11.3
←[0m←[0m←[1m←[32m   Compiling←[0m syn v0.11.11
←[0m←[0m←[1m←[32m   Compiling←[0m same-file v1.0.2
←[0m←[0m←[1m←[32m   Compiling←[0m walkdir v2.1.4
←[0m←[0m←[1m←[32m   Compiling←[0m rust-embed v3.0.0 (file:///D:/3rdparty/rust-embed)
←[0m←[1m←[38;5;9merror[E0463]←[0m←[0m←[1m←[38;5;15m: can't find crate for `rocket_codegen`←[0m
←[0m ←[0m←[0m←[1m←[38;5;14m--> ←[0m←[0mexamples\rocket.rs:2:11←[0m
←[0m  ←[0m←[0m←[1m←[38;5;14m|←[0m
←[0m←[1m←[38;5;14m2←[0m←[0m ←[0m←[0m←[1m←[38;5;14m| ←[0m←[0m#![plugin(rocket_codegen)]←[0m
←[0m  ←[0m←[0m←[1m←[38;5;14m| ←[0m←[0m          ←[0m←[0m←[1m←[38;5;9m^^^^^^^^^^^^^^←[0m←[0m ←[0m←[0m←[1m←[38;5;9mcan't f
ind crate←[0m

←[0m←[1m←[38;5;9merror←[0m←[0m←[1m←[38;5;15m: aborting due to previous error←[0m

←[0m←[1m←[38;5;15mFor more information about this error, try `rustc --explain E0463`.←[0m
←[0m←[0m←[1m←[31merror:←[0m Could not compile `rust-embed`.

To learn more, run the command again with --verbose.

Changelog Misses Some Changes And Versions

Not included in the changelog are these PRs:

  • #2 - Use file of the same name.
  • #4 - Fix bug in filenames with dashes.
  • #5 - Add asset listing function.
  • #7 - Ignore some clippy lints in generated code.
  • #9 - Use $crate to improve macro hygiene.
  • #11 - Removes Cargo.lock so the library can be used on the latest nightlies
  • #12 - Removes the log macros in debug mode. This caused errors if you didn't include the log macro in your crate, or if you used Rocket (they have some macros with the same names).
  • #13 - Moves the use statements in the debug code to not conflict with the other use statements of the file the macro is used in.

These are all useful to see in a changelog so that people can see what bugs each release fixed. Besides PRs, there are probably some missed changes you directly made without going through a PR.

Also missing are these versions:

  • 0.3.0
  • 0.3.2
  • 0.3.4
  • 0.3.5
  • 0.4.0
  • 0.5.1
  • 0.5.2
  • 1.0.0
  • 1.1.0

Caching of decompressed assets for lowest latency reading

Building on #90:
A common use case of rust-embed is web servers (e.g. desktop apps that embed a web server to render their UI in a browser view).
For web servers or anything that needs to read the embedded files as fast as possible and multiple times over the lifetime of the process, it makes sense to decompress each asset only once and then cache the result, so that further calls for the same path can return the cached/decompressed value immediately.
This could be another feature, e.g. cached-compression which also enables the compression feature when it is enabled.
For the memoization/caching of each asset we could use OnceCell/Lazy (or an Option).

@Mcat12 What do you think? :)

Binary mode should be controlled by a feature not by debug mode

User should be able to specify a feature flag to control whether the resources should be embedded in binary or read from fs.

It would be nice with the default feature enable the binary mode in both debug and release version. After all this crate's purpose is embed resource into binary.

Docs for get() function

It would be useful to know which methods can be called on the Asset struct and which signatures they have. E.g. can get only be called with a &str or also with a Path?

EDIT: I looked at the source and it looks like get can only be called with a &str, why not with a P: AsRef<Path> (called with relative paths)?

Doc comments cause RustEmbed derive to panic

Doc comments on the struct the derive is applied to cause rust-embed to panic

Sample code: https://github.com/lopopolo/rust-embed-panic

▶ cargo build
   Compiling rust-embed-panic v0.1.0 (/Users/lopopolo/Desktop/rust-embed-panic)
error: proc-macro derive panicked
 --> src/main.rs:7:10
  |
7 | #[derive(RustEmbed)]
  |          ^^^^^^^^^
  |
  = help: message: #[derive(RustEmbed)] should contain one attribute like this #[folder = "examples/public/"]

error: aborting due to previous error

error: Could not compile `rust-embed-panic`.

To learn more, run the command again with --verbose.

Define an actual RustEmbed trait

The current macro only generates an impl {} block; that is useful as it avoids a need to use any traits to access the get and iter methods, but the lack of a trait prevents any generic extensions.

Defining & exporting a RustEmbed trait, and implementing it as part of the derive, could allow things like extension crates to handle the boilerplate of binding assets to different frameworks, path globbing extension methods, etc.

Windows path release build `\` should be `/`

I noticed that subpaths on my Rocket projects that uses similar code to https://github.com/pyros2097/rust-embed/blob/master/examples/rocket.rs did not work on windows in release build (when files get embedded).

I fixed this by changing:
https://github.com/pyros2097/rust-embed/blob/3b1ac9f4d671af9cf2aa87a8cfd7f76dfa9b7641/examples/rocket.rs#L27
to

let filename = file.display().to_string().replace("\\", "/");

It now works on linux and windows in both release builds.

I also found this issue which looked similar but PR did not seem to solve this.

proc-macro derive panicked

I wrote this code:

#[derive(RustEmbed)]
#[folder = "/$CARGO_MANIFEST_DIR/static"]
struct Asset;

fn main(){
   let index_html = Asset::get("index.html").unwrap();
}

And got the below:

error: proc-macro derive panicked
 --> src\main.rs:8:10
  |
8 | #[derive(RustEmbed)]
  |          ^^^^^^^^^
  |
  = help: message: #[derive(RustEmbed)] folder 'C:/$CARGO_MANIFEST_DIR/static' does not exist. cwd: 'C:\Users\Yara Yousef\PycharmProjects\wv'
          A variable has been detected. RustEmbed can expand variables when the `interpolate-folder-path` feature is enabled.

error[E0599]: no function or associated item named `get` found for struct `Asset` in the current scope
  --> src\main.rs:13:29
   |
10 | struct Asset;
   | ------------- function or associated item `get` not found for this

Compile error with 'debug-embed'

I have a base library which embeds some icons using rust-embed. When using the library from another project the embedded resources can only be found when running the binary in release mode. Trying to run the application in debug mode where the resources are read from the file system yields run-time errors.
So I would like to turn on the debug-embed feature to always embed the resource like in the release build.
However by doing this

rust-embed = { version = "4.2", features = ["debug-embed"] }

I get the following compile errors

  |
9 | #[derive(RustEmbed)]
  |          ^^^^^^^^^ could not find `utils` in `rust_embed`

Any help would be greatly appreciated.

When rust-embed is used in a lib, the folder_path is relative to the lib, not the binary using it.

  1. I made a library crate "pypack" that uses rust-embed.
  2. I made a binary crate that uses that library crate.
  3. I would expect the folder used for the Asset folder path to be relative to the binary cargo.toml, is that not the case?

example:

error: proc-macro derive panicked
  --> C:\Users\LUNA\.cargo\git\checkouts\pypack-071d8f8d2bc34e74\06f6da1\src\lib.rs:13:10
   |
13 | #[derive(RustEmbed)]
   |          ^^^^^^^^^
   |
   = help: message: #[derive(RustEmbed)] folder 'dist/' does not exist. cwd: 'C:\Users\LUNA\.cargo\git\checkouts\pypack-071d8f8d2bc34e74\06f6da1'

Rocket dependency broken

From https://ci.appveyor.com/project/pyros2097/rust-embed/builds/21541868/job/xnkec8tem3kqw8bn :

cargo test --test lib
    Updating crates.io index
error: failed to select a version for the requirement `ring = "^0.11.0"`
  candidate versions found which didn't match: 0.14.0, 0.13.5, 0.8.1
  location searched: crates.io index
required by package `cookie v0.9.1`
    ... which is depended on by `rocket v0.3.6`
    ... which is depended on by `rust-embed v4.3.0 (C:\projects\rust-embed)`
Command exited with code 101

Pretty sure this is not rust-embed's fault at all, but it interferes with the AppVeyor test.

appveyor windows compile

I noticed something when trying to use the git repo directly in Cargo.toml.

rust-embed = { git = "https://github.com/pyros2097/rust-embed" }

Compiling with Appveyor, the build errored out with this message:

Compiling rust-embed-impl v4.4.0 (https://github.com/pyros2097/rust-embed#de8e97fe)
error: expected item, found `..`
 --> C:\Users\appveyor\.cargo\git\checkouts\rust-embed-88640eaf411660a2\de8e97f\impl\src\utils.rs:1:1
  |
1 | ../../src/utils.rs
  | ^^ expected item
error: aborting due to previous error
error: Could not compile `rust-embed-impl`.

The latest released version (v4.4.0) was building successfully.

doesn't work with files generated by `nuxt.js`

Hello, I tried to use nuxt.js and generated some static pages using nuxt generate, while I load these files using a static file server it works perfectly but while I load it using rust-embed it doesn't work anymore.

Do you have some ideas why it happens? I'll try to make a repro.

How to make it work in workspace with cargo test?

I want to embed the folder workspace/crate_foo/bar, so I do:

#[derive(RustEmbed)]
#[folder = "crate_foo/bar"] // relative to workspace root
pub struct Assets;

But when I do cargo test, it fails when the doc-tests are run:

# cargo test -p crate_foo
   Compiling crate_foo v0.1.0 (/usr/src/workspace/crate_foo)
    Finished dev [unoptimized + debuginfo] target(s) in 4.14s
     Running target/debug/deps/crate_foo-ba8abb39df8832bd

running 2 tests
test [..] ... ok
test [..] ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

   Doc-tests crate_foo
error: proc-macro derive panicked
  --> /usr/src/workspace/crate_foo/src/templates.rs:50:14
   |
50 |     #[derive(RustEmbed)]
   |              ^^^^^^^^^
   |
   = help: message: #[derive(RustEmbed)] folder 'crate_foo/bar' does not exist. cwd: '/usr/src/workspace/crate_foo'

error: test failed, to rerun pass '--doc'

Because apparently, for normal tests, it uses cwd workspace but for doc-tests, it uses cwd workspace/crate_foo, so it will try to embed workspace/crate_foo/crate_foo/bar when running doc-tests, but why?

I tried to use #[cfg(not(test))] on a wrapper module to only conditionally embed the dir, but it doesn't work..
How can I make it work?
Is there a #[cfg(not(doc_tests))] or something? How can I embed only when doc-tests aren't run?

Fill in changelog from 5.0.1 to 5.1.0

There were a lot of versions published between 5.0.1 (last documented in changelog) to 5.1.0. The changelog should be updated with the changes these versions made.

Is there a way to just instantiate an Asset struct?

This would let me work around #34 like so:

  1. Enter the main () function
  2. Figure out what directory I want to load assets from (e.g. the project root)
  3. Pass that directory, and the assets directory to some new () func (e.g. Asset::new ("/myproject", "public/html")
  4. The new () func returns an Asset which I can pass to other functions by shared reference. I could even create multiple instances if I want to swap between two folders while the program is running.

The existing global functions could be implemented on top, by creating a global object that has the two directories fixed at compile time.

If I can find a way to do that, would you take a PR?

empty file list when asset directory is in nested folder

Hi,

Given:

\ (the root of cargo workspace)
\Cargo.toml
\assets\ (a simple folder)
\component-a\ (a crate within the workspace)
\component-a\Cargo.toml
\component-a\assets
\static\ (a simple folder)
\static\assets

where each "\assets" directory is a copy with at least a.txt in, then #[folder = "assets/"] is the only one that works when used within \component-a.

Observations:

  • #[folder = "component-a/assets"] compiles but lists no files
  • #[folder = "static/assets"] compiles but lists no files

this is regardless of whether cargo run is run within \ or \component-a.

What I am trying to achieve is either component-a/assets/ or static/assets/.

Help :-)

Create a Changelog

I haven't found any place which documents the changes in each version, so I assume the changes have never been documented besides the commit messages. It would be helpful to create a changelog file or use GitHub Releases to document the changes in each version.

Saving Rocket static and template files

I'd a look at rocket example but my issue is different, I've the below code:

#![feature(decl_macro, proc_macro_hygiene)]
use rocket_contrib::templates::Template;
use rocket_contrib::serve::StaticFiles;
mod routes;

use rust_embed::RustEmbed;

#[derive(RustEmbed)]
#[folder = "static"]
struct Static;

#[derive(RustEmbed)]
#[folder = "templates"]
struct Templates;

fn main() {
        rocket::ignite()
        .attach(Template::fairing())
        .mount("/static",
                StaticFiles::from("static"))
        .mount("/", rocket::routes![routes::root::root])
        .launch();
}

And the app structure is as shown:
image

And my Cargo.toml is:

[dependencies]
rust-embed = {version = "5.5.1", features = ["interpolate-folder-path"]}
rocket = "0.4.4"
[dependencies.rocket_contrib]
version = "0.4.4"
defaullt-features = "false"
features = ["tera_templates", "serve"]

Once I got the .exe file generated at Win 10 it did not work without copying the static and templates folder in the same directory of the executable, am I missing something to get them embed in the binary itself?

Feature Request: `#[exclude = "example/some_big_directory"]`

I was just about to open a bug about how slow rust-embed was performing in release mode...

... then I found that I was accidentally embedding a 70Mb+ node_modules directory. Oops. (Still, it did seem rather slow for a mere 70MB but maybe that's because it's a lot of small files?)

It would be nice if I could embed some directory, but exclude some large subdirectories from that embed. Ex:

#[derive(RustEmbed)]
#[folder = "examples/"]
#[exclude = "examples/big_dir"]

Or, you could make it respect .gitignores? I already had that node_modules directory ignored, which is part of the reason I'd forgotten about it.

Otherwise, thanks for a great crate!

Method for getting a list of the available files

It would be nice to have a method such as fn list(&self) -> Vec<Path> or fn list(&self) -> Vec<String> to get a list of the available files. My use case is that I want to have a few specifications for different models of TVs, and rather than typing out the names of the models twice, I would just name the file describing the TV after the appropriate display option, and then retrieve that list in the program.

Can I get the separate files after embedding them

After building the .exe file, assume I want to extract/get the JS file I used, is there a way to extract it back?

i tried in Windows changing the extension from .exe to .zip but could not extract the generated file, i know some applications use this trip but did not work with me!

image

cargo build fails on Fedora

error[E0433]: failed to resolve: use of undeclared type or module `actix_web`
 --> examples/actix.rs:1:5
  |
1 | use actix_web::body::Body;
  |     ^^^^^^^^^ use of undeclared type or module `actix_web`

error[E0433]: failed to resolve: use of undeclared type or module `warp`
 --> examples/warp.rs:2:5
  |
2 | use warp::{http::header::HeaderValue, path::Tail, reply::Response, Filter, Rejection, Reply};
  |     ^^^^ use of undeclared type or module `warp`

error[E0432]: unresolved import `actix_web`
 --> examples/actix.rs:2:5
  |
2 | use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer};
  |     ^^^^^^^^^ use of undeclared type or module `actix_web`

error[E0432]: unresolved import `mime_guess`
 --> examples/actix.rs:3:5
  |
3 | use mime_guess::from_path;
  |     ^^^^^^^^^^ use of undeclared type or module `mime_guess`

error[E0433]: failed to resolve: use of undeclared type or module `actix_rt`
  --> examples/actix.rs:34:3
   |
34 | #[actix_rt::main]
   |   ^^^^^^^^ use of undeclared type or module `actix_rt`

error[E0412]: cannot find type `Body` in this scope
  --> examples/actix.rs:15:17
   |
15 |       let body: Body = match content {
   |                 ^^^^ not found in this scope

error[E0432]: unresolved import `warp`
 --> examples/warp.rs:2:5
  |
2 | use warp::{http::header::HeaderValue, path::Tail, reply::Response, Filter, Rejection, Reply};
  |     ^^^^ use of undeclared type or module `warp`

error[E0433]: failed to resolve: use of undeclared type or module `tokio`
 --> examples/warp.rs:8:3
  |
8 | #[tokio::main]
  |   ^^^^^ use of undeclared type or module `tokio`

error[E0433]: failed to resolve: use of undeclared type or module `warp`
  --> examples/warp.rs:10:20
   |
10 |   let index_html = warp::path::end().and_then(serve_index);
   |                    ^^^^ use of undeclared type or module `warp`

error[E0433]: failed to resolve: use of undeclared type or module `warp`
  --> examples/warp.rs:11:14
   |
11 |   let dist = warp::path("dist").and(warp::path::tail()).and_then(serve);
   |              ^^^^ use of undeclared type or module `warp`

error[E0433]: failed to resolve: use of undeclared type or module `warp`
  --> examples/warp.rs:11:37
   |
11 |   let dist = warp::path("dist").and(warp::path::tail()).and_then(serve);
   |                                     ^^^^ use of undeclared type or module `warp`

error[E0433]: failed to resolve: use of undeclared type or module `warp`
  --> examples/warp.rs:14:3
   |
14 |   warp::serve(routes).run(([127, 0, 0, 1], 8080)).await;
   |   ^^^^ use of undeclared type or module `warp`

error[E0433]: failed to resolve: use of undeclared type or module `warp`
  --> examples/warp.rs:26:43
   |
26 |   let asset = Asset::get(path).ok_or_else(warp::reject::not_found)?;
   |                                           ^^^^ use of undeclared type or module `warp`

error[E0433]: failed to resolve: use of undeclared type or module `mime_guess`
  --> examples/warp.rs:27:14
   |
27 |   let mime = mime_guess::from_path(path).first_or_octet_stream();
   |              ^^^^^^^^^^ use of undeclared type or module `mime_guess`

error[E0433]: failed to resolve: use of undeclared type or module `Response`
  --> examples/warp.rs:29:17
   |
29 |   let mut res = Response::new(asset.into());
   |                 ^^^^^^^^ use of undeclared type or module `Response`

error[E0433]: failed to resolve: use of undeclared type or module `HeaderValue`
  --> examples/warp.rs:30:44
   |
30 |   res.headers_mut().insert("content-type", HeaderValue::from_str(mime.as_ref()).unwrap());
   |                                            ^^^^^^^^^^^ use of undeclared type or module `HeaderValue`

error[E0412]: cannot find type `Tail` in this scope
  --> examples/warp.rs:21:22
   |
21 | async fn serve(path: Tail) -> Result<impl Reply, Rejection> {
   |                      ^^^^ not found in this scope

error: aborting due to 12 previous errors

Some errors have detailed explanations: E0412, E0432, E0433.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `rust-embed`.

Caused by:
  process didn't exit successfully: `/usr/bin/rustc --crate-name warp --edition=2018 examples/warp.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C opt-level=3 -C metadata=2deb8416ae26f1cb -C extra-filename=-2deb8416ae26f1cb --out-dir /home/brain/rpmbuild/BUILD/rust-embed-5.5.1/target/release/examples -L dependency=/home/brain/rpmbuild/BUILD/rust-embed-5.5.1/target/release/deps --extern rust_embed=/home/brain/rpmbuild/BUILD/rust-embed-5.5.1/target/release/deps/librust_embed-83b19ecfa2dd0123.rlib --extern rust_embed_impl=/home/brain/rpmbuild/BUILD/rust-embed-5.5.1/target/release/deps/librust_embed_impl-bf0e64a0f34f7c27.so --extern rust_embed_utils=/home/brain/rpmbuild/BUILD/rust-embed-5.5.1/target/release/deps/librust_embed_utils-48390f5cd9c5c672.rlib --extern walkdir=/home/brain/rpmbuild/BUILD/rust-embed-5.5.1/target/release/deps/libwalkdir-5b6b43cef122a702.rlib -Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now -Ccodegen-units=1 --cap-lints=warn` (exit code: 1)
warning: build failed, waiting for other jobs to finish...
error[E0277]: `main` has invalid return type `impl std::future::Future`
  --> examples/actix.rs:35:20
   |
35 | async fn main() -> std::io::Result<()> {
   |                    ^^^^^^^^^^^^^^^^^^^ `main` can only return types that implement `std::process::Termination`
   |
   = help: consider using `()`, or a `Result`

error: aborting due to 6 previous errors

I did not try to reproduce this with upstream yet, but this is happening on Fedora with simple cargo test.

actix example doesn't work (resolved)

Hi,

I'm trying to get the actix example working in it's own new project.

But I get the following error:

no method named as_ref found for type mime_guess::Mime in the current scope
src/main.rs:22:61

$ cargo build 
Compiling embed_actix v0.1.0 (/home/rj/src/embed_actix)
error[E0599]: no method named `as_ref` found for type `mime_guess::Mime` in the current scope
--> src/main.rs:22:61
   |
22 |       HttpResponse::Ok().content_type(guess_mime_type(path).as_ref()).body(body)`
   |                                                             ^^^^^

cargo.toml:

[package]
name = "embed_actix"
version = "0.1.0"
authors = ["me <[email protected]>"]
edition = "2018"

[dependencies]
actix-web = "0.7.19"
rust-embed = "4.4.0"
mime_guess = "1.8.7"

src/main.rs is copy of (with no changes):
examples/actix.rs

Mime is defined as

#[derive(Clone, Debug, Eq, Hash, Ord, PartialOrd)]
pub struct Mime<T: AsRef<[Param]> = Vec<Param>>(pub TopLevel, pub SubLevel, pub T);

so should have the as_ref trait?

Any help to get this working would be great - thanks!

Doesn't work in release mode

When I run the sample application from the readme in release mode it doesn't work. when I put the folder example/public/ next to the release binary, it works

[fretn@machine embed]$ rustup show
Default host: x86_64-apple-darwin

installed toolchains
--------------------

stable-x86_64-apple-darwin
nightly-x86_64-apple-darwin

installed targets for active toolchain
--------------------------------------

x86_64-apple-darwin
x86_64-unknown-linux-musl

active toolchain
----------------

stable-x86_64-apple-darwin (default)
rustc 1.24.1 (d3ae9a9e0 2018-02-27)

[fretn@machine embed]$

`OUT_DIR` says it "does not exist"

I have the following code:

#[derive(RustEmbed)]
#[folder = "$OUT_DIR/gui/"]
struct GuiAsset;

And when I try to compile this I get the following error:

error: proc-macro derive panicked
  --> src\gui.rs:47:10
   |
47 | #[derive(RustEmbed)]
   |          ^^^^^^^^^
   |
   = help: message: #[derive(RustEmbed)] folder '$OUT_DIR/gui/' does not exist. cwd: 'E:\Repo\castle-game'

It looks like $OUT_DIR isn't resolved properly, even though PR #67 should have fixed this.

Debug mode sometimes retrieves incomplete files

Hi, and thanks for developing this invaluable tool :)

I've got a bit of a problem. I'm serving the content of the embedded folder via actix-web, and running a parcel watch job for frontend development. This frontend tooling has autoreloading, so when the watch job builds a new version of my frontend the page gets reloaded. This almost always results in only half of the javascript file getting served and the reload aborting because of it.

I don't know how rust-embed works internally, but I'm assuming this is because rust-embed reads the file at a time where it's not done being written?

Make it work on Stable Rust

It seems many useful libraries like serde, diesel are working in stable rust right now. We should also move this to use stable rust so that it could be more in tune to work in production environments.

Here is the list of changes I can think of,

  • Remove #![feature(attr_literals)]

Error after updating to 5.0.0

After updating to verision 5.0.0 I get the following error, in multiple different codebases

error[E0463]: can't find crate for `rust_embed_utils`
  --> src/main.rs:59:10
   |
59 | #[derive(RustEmbed)]
   |          ^^^^^^^^^ can't find crate

The error is fixed by adding the following to Cargo.toml so it seems like something is missing a dependency.

rust-embed-utils = "5.0.0"

rustc 1.36.0 (a53f9df32 2019-07-03)
cargo 1.36.0 (c4fcfb725 2019-05-15)

panic when struct with the derive has fields

Attempting to compile the following code results in a panic. If structs that derive RustEmbed cannot have fields, the compiler should spit out an error message to help me fix the issue 😄

#[derive(RustEmbed)]
#[folder = "spec-runner/spec/mspec/"]
struct Sources {
    v: bool,
}
$ cargo build
   Compiling spec-runner v0.1.0 (/Users/lopopolo/dev/repos/ferrocarril/spec-runner)
error: proc-macro derive panicked
  --> spec-runner/src/mspec.rs:22:10
   |
22 | #[derive(RustEmbed)]
   |          ^^^^^^^^^
   |
   = help: message: #[derive(RustEmbed)] should contain one attribute like this #[folder = "examples/public/"]

error: aborting due to previous error

error: Could not compile `spec-runner`.

To learn more, run the command again with --verbose.

Release a new version

It would be nice to release a new version now that rust-embed got updated to use syn 1.x so that downstream users can get rid of syn 0.11 from their crate graph.

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.