Code Monkey home page Code Monkey logo

Comments (4)

pyrossh avatar pyrossh commented on May 25, 2024

Hmm... we do have test cases that test this feature out though.
https://github.com/pyrossh/rust-embed/blob/master/tests/mime_guess.rs#L28
And this is running in our pipeline,
cargo test --test mime_guess --features "mime-guess"
What could be going wrong?

from rust-embed.

BBaoVanC avatar BBaoVanC commented on May 25, 2024

I'm confused too, it works in my app (https://github.com/BBaoVanC/bobashare, in bobashare-web/src/static_routes.rs), but I don't see Metadata::mimetype listed at all in the rustdoc (although maybe it can't tell it exists), and this simple code fails:

use rust_embed::RustEmbed;

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

fn main() {
    Asset::get("abc").map(|f| f.metadata.mimetype());
}

Not sure what is going on and how it's working fine for me

from rust-embed.

vicanso avatar vicanso commented on May 25, 2024

@pyrossh I find that if I add this dependency, it works.

rust-embed-utils = { version = "7.5.0", features = ["mime-guess"] }

from rust-embed.

pyrossh avatar pyrossh commented on May 25, 2024

@vicanso thanks, that was it. The mime-guess feature didn't include the utils crate feature hence the issue. https://github.com/pyrossh/rust-embed/blob/master/Cargo.toml#L87. I've added it now and released v6.6.1 and it works.

Here is a simple example,

use rust_embed::RustEmbed;

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

fn main() {
    println!("{:?}", Asset::get("main.js").unwrap().metadata.mimetype())
}

from rust-embed.

Related Issues (20)

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.