I want to call my Call Struct Data type in other files, but I have this error :
--> src/router/router.rs:19:34
|
19 | xml_files::write_xml_getcapa(wmts_info);
| ^^^^^^^^^ expected struct `router::router::xml_files::wmts::Wmts`, found struct `router::router::wmts::Wmts`
error: aborting due to previous error; 1 warning emitted
So i understand the Error, and I read other post for solve the problems, but I don't find answer at my question.
My project architecture :
├── mod.rs
├── router.rs
├── wmts_struct.rs
└── xml_files
└── xml_getcapa.rs
The structure that I want to call is in wmts_struct.rs
pub struct Wmts {
pub title: String,
pub service: String,
pub version: String,
}
impl Wmts {
pub fn new() -> Wmts {
Wmts {
title: String::from("Test"),
service: String::from("WMS"),
version: String::from("0.0.1"),
}
}
}
in router.rs
#[path = "./wmts_struct.rs"] mod wmts;
#[get("/0.1/WMTSCapabilities.xml")]
pub fn get_capa_request() -> &'static str {
let wmts_info = wmts::Wmts::new();
xml_files::write_xml_getcapa(wmts_info);
"Start to create getCapa file"
}
xml_getcapa.rs
#[path = "./../wmts_struct.rs"]
mod wmts;
pub fn write_xml_getcapa(wmts_info: wmts::Wmts) {
let mut file = File::create("./GetCapabilities.xml").unwrap();
let mut writer = EmitterConfig::new()
.perform_indent(true)
.create_writer(&mut file);
}
my main.rs
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
mod router;
fn rocket() -> rocket::Rocket {
rocket::ignite().mount(
"/",
routes![router::router::get_capa_request,],
)
}
fn main() -> () {
// Start Server
rocket().launch();
}
Thank you for your Help !