Undeclared Error

#[actix_rt::main]

use std::env;
use std::io;

fn main() -> io::Result<()> {
env::set_var("RUST_LOG", "actix_web=debug,actix_server=info");
env_logger::init();

HttpServer::new(|| {
    App::new()
        // enable logger - always register actix-web Logger middleware last
        .wrap(middleware::Logger::default())
        // register HTTP requests handlers
        .service(tweet::list)
        .service(tweet::get)
        .service(tweet::create)
        .service(tweet::delete)
        .service(like::list)
        .service(like::plus_one)
        .service(like::minus_one)
})
.bind("0.0.0.0:9090")?
.run()

}

In this code I am getting error as follow.
failed to resolve: use of undeclared type HttpServer
failed to resolve: use of undeclared type App

Help me out somone

You need to add HttpServer and App to your imports

I am importing like this.

use HttpServer;
use App;

But it showing following error.
unresolved import HttpServer
no external crate HttpServer

same for App.

Those crates don't exit. App and HttpServer should be structs exported from whatever framework you are trying to use.

Look again at how it's done in the tutorial you are following.

It has links to full source code below the example. Click main.rs source code

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.