Skip to content

the trait plugin::Plugin<iron::Request<'_, '_>> is not implemented for bodyparser::Raw #81

@Southclaws

Description

@Southclaws

I tried to use the example as a reference to get my own code working, but it fails with:

error[E0277]: the trait bound `bodyparser::Raw: plugin::Plugin<iron::Request<'_, '_>>` is not satisfied
  --> src/main.rs:27:24
   |
27 |         let body = req.get::<bodyparser::Raw>();
   |                        ^^^ the trait `plugin::Plugin<iron::Request<'_, '_>>` is not implemented for `bodyparser::Raw`
   |
   = help: the following implementations were found:
             <bodyparser::Raw as plugin::Plugin<iron::request::Request<'a, 'b>>>

The code in question:

    let (tx, rx) = mpsc::channel();
    let sender = Mutex::new(tx);
    let chain = Chain::new(move |req: &mut Request| -> IronResult<Response> {
        println!("received request");

        let body = req.get::<bodyparser::Raw>();
        match body {
            Ok(Some(body)) => println!("Read body:\n{}", body),
            Ok(None) => println!("No body"),
            Err(err) => println!("Error: {:?}", err),
        }

        let tx = sender.lock().unwrap().clone(); //Or whatever
        tx.send("request");

        return Ok(Response::with((status::Ok, "Hello World")));
    });
    chain.link_before(Read::<bodyparser::MaxBodyLength>::one(MAX_BODY_LENGTH));

    thread::spawn(move || {
        for received in rx {
            println!("{}", received)
        }
    });

    match Iron::new(chain).http(env::var("BIND").unwrap()) {
        Ok(_) => println!("fine"),
        Err(error) => panic!("failed to bind HTTP listener: {:?}", error),
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions