rust actix: how can I properly return an App instance from a module?

343 views Asked by At

I'd like to return an App instance from a module, but I just don't get anywhere.

I am propably doing everything wrong, that can be done wrong.

Here's my effort so far:

app.rs (called by main.rs)

extern crate actix_web;
extern crate actix_http; // => can't be found
extern crate actix_service; // => can't be found

use actix_web::App;
use actix_http::body::MessageBody;
use actix_service::ServiceFactory;

pub fn create() -> Result<App<MessageBody, ServiceFactory>, Error> {
    let app = App::new();
    // adding services
    Ok(App)
}

There's propably a lot wrong with this code, but at the moment my main problem is that I can't import actix_http and actix_service which both are needed to return the proper types of the App result.

Addendum:

Cargo.toml

[package]
name = "backend"
version = "0.1.0"
authors = ["My Name <[email protected]>"]
edition = "2018"

[dependencies]
actix-web="3"
diesel= { version = "1.4.5", features = ["mysql"] }
dotenv= { version = "0.15.0" }

[[bin]]
name = "main"
path = "src/main.rs"
0

There are 0 answers