fn finish(self: Box<Self>) -> std::io::Result<BlockingCursor> {
self.0.finish().map_err(|e| match e {
lzma_rs::error::Error::IoError(e) => e,
- lzma_rs::error::Error::HeaderTooShort(e) => {
- std::io::Error::new(std::io::ErrorKind::Other, format!("{e}"))
- }
+ lzma_rs::error::Error::HeaderTooShort(e) => std::io::Error::other(format!("{e}")),
lzma_rs::error::Error::LzmaError(e) | lzma_rs::error::Error::XzError(e) => {
- std::io::Error::new(std::io::ErrorKind::Other, e)
+ std::io::Error::other(e)
}
})
}
fn finish(self: Box<Self>) -> std::io::Result<BlockingCursor> {
self.0
.into_inner()
- .map_err(|_e| std::io::Error::new(std::io::ErrorKind::Other, "brotli"))
+ .map_err(|_e| std::io::Error::other("brotli"))
}
fn try_finish(&mut self) -> std::io::Result<()> {
Ok((Box::new(NullBufWriter(buf)), true))
}
}
- HtpContentEncoding::None => Err(std::io::Error::new(
- std::io::ErrorKind::Other,
- "expected a valid encoding",
- )),
+ HtpContentEncoding::None => Err(std::io::Error::other("expected a valid encoding")),
}
}
self.inner.replace(inner);
Ok(())
} else {
- Err(std::io::Error::new(
- std::io::ErrorKind::Other,
- "nothing to flush to",
- ))
+ Err(std::io::Error::other("nothing to flush to"))
}
}
HtpContentEncoding::Lzma => HtpContentEncoding::Deflate,
HtpContentEncoding::Brotli => HtpContentEncoding::Deflate,
HtpContentEncoding::None => {
- return Err(std::io::Error::new(
- std::io::ErrorKind::Other,
- "expected a valid encoding",
- ))
+ return Err(std::io::Error::other("expected a valid encoding"))
}
};
let (writer, passthrough) = Self::writer(self.encoding, &self.options)?;
self.restarts += 1;
Ok(())
} else {
- Err(std::io::Error::new(
- std::io::ErrorKind::Other,
- "too many restart attempts",
- ))
+ Err(std::io::Error::other("too many restart attempts"))
}
}
// Invoke all callbacks.
self.request_run_hook_body_data(&mut tx_data)
- .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "body data hook failed"))?;
+ .map_err(|_| std::io::Error::other("body data hook failed"))?;
let compression_options = self.cfg.compression_options;
let req = self.request_mut().unwrap();
request_entity_len, request_message_len,
)
);
- return Err(std::io::Error::new(
- std::io::ErrorKind::Other,
- "compression_bomb_limit reached",
- ));
+ return Err(std::io::Error::other("compression_bomb_limit reached"));
}
Ok(tx_data.len())
}
// Invoke all callbacks.
self.response_run_hook_body_data(&mut tx_data)
- .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "body data hook failed"))?;
+ .map_err(|_| std::io::Error::other("body data hook failed"))?;
let resp = self.response_mut().unwrap();
if let Some(decompressor) = &mut resp.response_decompressor {
if decompressor.callback_inc() % compression_options.get_time_test_freq() == 0 {
response_entity_len, response_message_len,
)
);
- return Err(std::io::Error::new(
- std::io::ErrorKind::Other,
- "compression_bomb_limit reached",
- ));
+ return Err(std::io::Error::other("compression_bomb_limit reached"));
}
Ok(tx_data.len())
}