std::io::Error -> hyper::Error?

EDIT: I actually need a hyper::Error, not a hyper::http::Error

Context: I am using hyper-staticfile and writing a custom hyper Service.

The hyper-staticfile returns for me a Result<Response<Body>, std::io::Error>, but what I need to produce is a Result<Response<Body>, hyper::Error>

Question: Is there an idiomatic way to do std::io::Error -> hyper::Error ?

hyper::Error is error type that originated from within hyper and consumed by client code. you should not need to produce an hyper:Error. please describe the problem you are trying to solve and how you are calling hyper and hyper-staticfile, and maybe people can give suggestions

1 Like
  1. You're right, this is a case of XY problem. I made a mistake while copying sample code.

  2. Everything is now fixed.

  3. For anyone stumbling across this on the internet. If you are implementing a hyper::Service for your custom struct, for the Error field, anyhow::Error worked for me.