尝试使用 rust 中的 actix-web 和 mongodb 制作服务器。出现错误
该特征
std::convert::From<mongodb::error::Error>未实现std::io::Error
这是我的代码
use actix_web::{web, App, HttpRequest, HttpServer, Responder};
use mongodb::{options::ClientOptions, Client};
async fn greet(req: HttpRequest) -> impl Responder {
let name = req.match_info().get("name").unwrap_or("World");
format!("Hello {}!", &name)
}
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
// Parse a connection string into an options struct.
let mut client_options = ClientOptions::parse("mongodb://localhost:27017")?;
// Manually set an option.
client_options.app_name = Some("My App".to_string());
// Get a handle to the deployment.
let client = Client::with_options(client_options)?;
// List …Run Code Online (Sandbox Code Playgroud) 我想在任何给定时间读取精简的存储价值。我了解更新值时会调用 subscribe 方法。即使商店没有更新,我也想阅读商店。