You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rustc -V
rustc 1.78.0 (9b00956e5 2024-04-29)
windows 10
stable-x86_64-pc-windows-gnu
cargo new app
> cd app
> cargo add viz
> cargo add tokio
config.toml :
[package]
name = "vizapi"
version = "0.1.0"
edition = "2021"
[dependencies]
tokio = "1.37.0"
viz = "0.8.4"
main.rs
use std::net::SocketAddr;
use viz::{Request, Result, Router, Server, ServiceMaker};
async fn index(_: Request) -> Result<&'static str> {
Ok("Hello Viz")
}
#[tokio::main]
async fn main() -> Result<()> {
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {addr}");
let app = Router::new().get("/", index);
if let Err(err) = Server::bind(&addr)
.serve(ServiceMaker::from(app))
.await
{
println!("{err}");
}
Ok(())
}
running :
PS D:\rust\vizapi> cargo run -- --nocaputre
Compiling vizapi v0.1.0 (D:\rust\vizapi)
error: The default runtime flavor is multi_thread, but the rt-multi-thread feature is disabled.
--> src\main.rs:8:1
|
8 | #[tokio::main]
| ^^^^^^^^^^^^^^
|
= note: this error originates in the attribute macro tokio::main (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0432]: unresolved import viz::ServiceMaker
--> src\main.rs:2:44
|
2 | use viz::{Request, Result, Router, Server, ServiceMaker};
| ^^^^^^^^^^^^ no ServiceMaker in the root
error[E0599]: no function or associated item named bind found for struct viz::Server in the current scope
--> src\main.rs:15:31
|
15 | if let Err(err) = Server::bind(&addr)
| ^^^^ function or associated item not found in Server<_, _, _, _>
|
note: if you're trying to build a new viz::Server<_, _, _, _>, consider using viz::Server::<L, E, F, S>::new which returns viz::Server<_, _, _, std::future::Pending<()>>
--> C:\Users\xiaoe.cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\viz-0.8.4\src\server.rs:54:5
|
54 | / pub fn new(executor: E, listener: L, router: Router, build: F) -> Server<L, E, F, Pending<()>>
55 | | where
56 | | F: Fn(E) -> Builder + Send + 'static,
| |________________________________________________^
Some errors have detailed explanations: E0432, E0599.
For more information about an error, try rustc --explain E0432.
error: could not compile vizapi (bin "vizapi") due to 3 previous errors
The text was updated successfully, but these errors were encountered:
rustc -V
rustc 1.78.0 (9b00956e5 2024-04-29)
windows 10
stable-x86_64-pc-windows-gnu
config.toml :
main.rs
running :
PS D:\rust\vizapi> cargo run -- --nocaputre
Compiling vizapi v0.1.0 (D:\rust\vizapi)
error: The default runtime flavor is
multi_thread
, but thert-multi-thread
feature is disabled.--> src\main.rs:8:1
|
8 | #[tokio::main]
| ^^^^^^^^^^^^^^
|
= note: this error originates in the attribute macro
tokio::main
(in Nightly builds, run with -Z macro-backtrace for more info)error[E0432]: unresolved import
viz::ServiceMaker
--> src\main.rs:2:44
|
2 | use viz::{Request, Result, Router, Server, ServiceMaker};
| ^^^^^^^^^^^^ no
ServiceMaker
in the rooterror[E0599]: no function or associated item named
bind
found for structviz::Server
in the current scope--> src\main.rs:15:31
|
15 | if let Err(err) = Server::bind(&addr)
| ^^^^ function or associated item not found in
Server<_, _, _, _>
|
note: if you're trying to build a new
viz::Server<_, _, _, _>
, consider usingviz::Server::<L, E, F, S>::new
which returnsviz::Server<_, _, _, std::future::Pending<()>>
--> C:\Users\xiaoe.cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\viz-0.8.4\src\server.rs:54:5
|
54 | / pub fn new(executor: E, listener: L, router: Router, build: F) -> Server<L, E, F, Pending<()>>
55 | | where
56 | | F: Fn(E) -> Builder + Send + 'static,
| |________________________________________________^
Some errors have detailed explanations: E0432, E0599.
For more information about an error, try
rustc --explain E0432
.error: could not compile
vizapi
(bin "vizapi") due to 3 previous errorsThe text was updated successfully, but these errors were encountered: