rust-embed
rust-embed copied to clipboard
Axum 0.7.1 - no function or associated item named `get` found for struct `Asset` in the current scope
Using Rust 1.74 and Axum 0.7.1 i get the following with the Axum example. Is there something I missed?
error[E0599]: no function or associated item named `get` found for struct `Asset` in the current scope
--> src\routes\mod.rs:63:22
|
51 | struct Asset;
| ------------ function or associated item `get` not found for this struct
...
63 | match Asset::get(path.as_str()) {
| ^^^ function or associated item not found in `Asset`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following traits define an item `get`, perhaps you need to implement one of them:
candidate #1: `SliceIndex`
candidate #2: `Row`
candidate #3: `rustls::server::server_conn::StoresServerSessions`
candidate #4: `RustEmbed`
Make sure that the directory you're using for static files is in the right place; it should be under the project directory, sibling to src/. Example from my program:
#[derive(RustEmbed)]
#[folder = "static/"]
struct Asset;
.
├── Cargo.toml
├── src
│ ├── lib.rs
│ ├── main.rs
│ └── static_routes.rs
└── static
├── css
└── js