(error: ParseError)
| 143 | |
| 144 | impl From<ParseError> for io::Error { |
| 145 | fn from(error: ParseError) -> Self { |
| 146 | match error { |
| 147 | ParseError::NoLength => io::Error::new(io::ErrorKind::InvalidData, "could not read content-length header"), |
| 148 | ParseError::CouldNotDecodeHeader => io::Error::new(io::ErrorKind::InvalidData, "could not decode headers"), |
| 149 | ParseError::HeaderDecodeMismatch(expected, actual) => io::Error::new( |
| 150 | io::ErrorKind::InvalidData, |
| 151 | format!("failed to fully parse headers, expected {expected} but parsing ended at {actual} bytes"), |
| 152 | ), |
| 153 | ParseError::InvalidHeader(string) => { |
| 154 | io::Error::new(io::ErrorKind::InvalidData, format!("saw invalid header {string}")) |
| 155 | } |
| 156 | ParseError::Encode(e) => e, |
| 157 | ParseError::Utf8(e) => io::Error::new(io::ErrorKind::InvalidData, format!("Utf8 decode error: {e}")), |
| 158 | ParseError::InvalidContentLength(e) => { |
| 159 | io::Error::new(io::ErrorKind::InvalidData, format!("invalid content-length: {e}")) |
| 160 | } |
| 161 | ParseError::Headers(e) => io::Error::new(io::ErrorKind::InvalidData, format!("invalid headers: {e}")), |
| 162 | ParseError::Body(e) => io::Error::new(io::ErrorKind::InvalidData, format!("invalid body: {e}")), |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | impl From<io::Error> for ParseError { |
nothing calls this directly
no test coverage detected