I am learning rust, now tried to import a struct, this is the source file path app_root/src/model/response/playlist_response.rs
, I am import another struct like this:
#[path = "../../models.rs"]
mod models;
use models::QueryPlaylist;
the model.rs
path is app_root/src/models.rs
, the models.rs
file look like this:
use super::schema::posts;
use super::schema::playing_record;
use super::schema::favorites;
use super::schema::songs;
use super::schema::playlist;
use super::schema::album;
use rocket::serde::Serialize;
#[derive(Insertable,Serialize,Queryable)]
#[table_name="playlist"]
pub struct QueryPlaylist {
pub id: i64,
pub creator: i64,
pub name: String,
pub cover_url: Option<String>,
pub description: Option<String>,
pub subscribed: Option<i32>,
pub subscribed_count: Option<i64>,
pub comment_count: Option<i64>,
pub share_count: Option<i32>,
pub play_count: Option<i32>
}
when I compile the project, shows error like this:
$ cargo build ‹ruby-2.7.2›
Compiling reddwarf_music v0.1.0 (/Users/dolphin/Documents/GitHub/reddwarf_music)
error[E0432]: unresolved import `super::schema`
--> src/biz/music/../../model/response/../../models.rs:1:12
|
1 | use super::schema::posts;
| ^^^^^^ could not find `schema` in `super`
error[E0432]: unresolved import `super::schema`
--> src/biz/music/../../model/response/../../models.rs:2:12
|
2 | use super::schema::playing_record;
| ^^^^^^ could not find `schema` in `super`
error[E0432]: unresolved import `super::schema`
--> src/biz/music/../../model/response/../../models.rs:3:12
|
3 | use super::schema::favorites;
| ^^^^^^ could not find `schema` in `super`
error[E0432]: unresolved import `super::schema`
--> src/biz/music/../../model/response/../../models.rs:4:12
|
4 | use super::schema::songs;
| ^^^^^^ could not find `schema` in `super`
error[E0432]: unresolved import `super::schema`
--> src/biz/music/../../model/response/../../models.rs:5:12
|
5 | use super::schema::playlist;
| ^^^^^^ could not find `schema` in `super`
error[E0432]: unresolved import `super::schema`
--> src/biz/music/../../model/response/../../models.rs:6:12
|
6 | use super::schema::album;
| ^^^^^^ could not find `schema` in `super`
the schema.rs
file path is app_root/src/schema.rs
. I am import using the wrong way? what is the problem like this way? what should I do to make it work? This is the main.rs
:
#[macro_use]
extern crate rocket;
#[macro_use]
extern crate diesel;
// #[macro_use]
// extern crate redis;
#[path="biz/music/music.rs"] mod music;
#[path="config/db/config.rs"] mod config;
#[path="biz/music/songs.rs"] mod songs;
#[path="biz/music/test.rs"] mod test;
#[path="biz/user/user.rs"] mod user;
#[path="biz/music/playlist.rs"] mod playlist;
#[launch]
fn rocket() -> _ {
rocket::build()
.mount("/music/music", routes![music::play_record,music::save_play_record,music::like,music::dislike])
.mount("/music/songs",routes![songs::detail])
.mount("/music/user",routes![user::recent_found])
.mount("/music/playlist",routes![playlist::user_playlist])
.mount("/music/test", routes![test::detail])
}