我正在尝试构建 rustless在 Windows 上:
这是我的 Cargo.toml:
[dependencies.rustless]
git = "https://github.com/rustless/rustless"
[package]
name = "ccampo_substancias_srv"
version = "0.0.1"
authors = [ "------------------------------" ]
[[bin]]
name = "Rest_test"
这是 main.rs:
#![feature(plugin)]
#[plugin]
extern crate rustless;
extern crate hyper;
extern crate iron;
extern crate "rustc-serialize" as rustc_serialize;
extern crate valico;
use hyper::status::StatusCode;
use iron::Iron;
use rustless::{
Application, Api, Nesting, Versioning
};
use rustc_serialize::json::ToJson;
fn main() {
let api = Api::build(dsl!(|api| {
// Specify API version
version("v1", Versioning::AcceptHeader("chat"));
prefix("api");
// Create API for chats
mount(Api::build(dsl!(|chats_api| {
after(|client, _params| {
client.set_status(StatusCode::NotFound);
Ok(())
});
// Add namespace
namespace("chats/:id", dsl!(|chat_ns| {
// Valico settings for this namespace
params(|params| {
params.req_typed("id", valico::u64())
});
// Create endpoint for POST /chats/:id/users/:user_id
post("users/:user_id", dsl!(|endpoint| {
// Add description
desc("Update user");
// Valico settings for endpoint params
params(|params| {
params.req_typed("user_id", valico::u64());
params.req_typed("name", valico::string())
});
handle(|client, params| {
client.json(¶ms.to_json())
})
}));
}));
})));
}));
let app = Application::new(api);
Iron::new(app).listen("localhost:4000").unwrap();
println!("On 4000");
println!("Rustless server started!");
}
在 Windows 10 上使用“cargo build --verbose”和 rust 1.5(64 位)构建。 这是我收到的错误,看起来它与某些文件路径有关:
Fresh jsonway v0.3.5
Fresh conduit-mime-types v0.7.3
Fresh winapi v0.2.5
Build failed, waiting for other jobs to finish...
could not rename crate "C:\\Users\\Pedro\\workspace\\ccampo-substancias-srv\\target\\debug\\build\\advapi32-sys-cfef7a1f30f1e5f6\\build_script_build.exe"
Caused by: Acesso negado. (os error 5)
最佳答案
您的计算机上是否装有防病毒/反恶意软件?它可能会尝试分析您的程序,锁定文件。尝试暂时禁用它或在您的项目目录中添加一个异常(exception),然后再次尝试构建。
关于rust - 在 Windows 上编译 ruSTLess 的基本示例时出现 "could not rename crate",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34315525/