0

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 <my@emai.l>"]
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"
LongHike
  • 4,016
  • 4
  • 37
  • 76
  • Could you add your `Cargo.toml` to the question? – Cerberus Oct 03 '20 at 04:34
  • @Cerberus Sorry, I had forgotten to add the Cargo.toml. But I kind of get your drift: I propably have to add **actix_http** and **actix_service** as **additional dependencies** to the Cargo.toml, so the rust linker knows that they are available, is that right? I was thinking in terms of node's npm/yarn where a package is available to the application even when it's only being installed as dependency of a dependency. – LongHike Oct 03 '20 at 09:44
  • @LongHike did you solve it? I also have this concern. – Vidy Videni Apr 14 '21 at 10:25
  • @VidyVideny Unfortunately not ;-( – LongHike Apr 14 '21 at 12:44
  • @LongHike, please check here https://github.com/actix/actix-web/issues/2039 – Vidy Videni Apr 21 '21 at 10:18
  • @VidyVideni Thanks a lot for letting me know. I'll try it ASAP. – LongHike Apr 22 '21 at 11:13

0 Answers0