Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mercury/src/internal/pack/cache_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl<T: Serialize + for<'a> Deserialize<'a>> FileLoadStore for T {
fn f_load(path: &Path) -> Result<T, io::Error> {
let data = fs::read(path)?;
let obj: T = bincode::serde::decode_from_slice(&data, bincode::config::standard())
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?
.map_err(io::Error::other)?
.0;
Ok(obj)
}
Expand Down
2 changes: 1 addition & 1 deletion mercury/src/internal/pack/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ mod tests {
struct BrokenReader;
impl Read for BrokenReader {
fn read(&mut self, _: &mut [u8]) -> io::Result<usize> {
Err(io::Error::new(io::ErrorKind::Other, "error"))
Err(io::Error::other("error"))
}
}

Expand Down
12 changes: 6 additions & 6 deletions mercury/zstdelta/src/zstdelta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub fn diff(base: &[u8], data: &[u8]) -> io::Result<Vec<u8>> {
unsafe {
let cctx = ZSTD_createCCtx();
if cctx.is_null() {
return Err(io::Error::new(io::ErrorKind::Other, "cannot create CCtx"));
return Err(io::Error::other("cannot create CCtx"));
}

let max_outsize = ZSTD_compressBound(data.len());
Expand All @@ -107,7 +107,7 @@ pub fn diff(base: &[u8], data: &[u8]) -> io::Result<Vec<u8>> {

if ZSTD_isError(outsize) != 0 {
let msg = format!("cannot compress ({})", explain_error(outsize));
Err(io::Error::new(io::ErrorKind::Other, msg))
Err(io::Error::other(msg))
} else {
buf.set_len(outsize);
Ok(buf)
Expand All @@ -120,15 +120,15 @@ pub fn apply(base: &[u8], delta: &[u8]) -> io::Result<Vec<u8>> {
unsafe {
let dctx = ZSTD_createDCtx();
if dctx.is_null() {
return Err(io::Error::new(io::ErrorKind::Other, "cannot create DCtx"));
return Err(io::Error::other("cannot create DCtx"));
}
ZSTD_DCtx_setMaxWindowSize(dctx, 1 << ZSTD_WINDOWLOG_MAX);

let size = ZSTD_findDecompressedSize(delta.as_ptr() as *const c_void, delta.len()) as usize;
if size == ZSTD_CONTENTSIZE_ERROR as usize || size == ZSTD_CONTENTSIZE_UNKNOWN as usize {
ZSTD_freeDCtx(dctx);
let msg = "cannot get decompress size";
return Err(io::Error::new(io::ErrorKind::Other, msg));
return Err(io::Error::other(msg));
}

let mut buf = vec![0u8; size];
Expand All @@ -146,13 +146,13 @@ pub fn apply(base: &[u8], delta: &[u8]) -> io::Result<Vec<u8>> {

if ZSTD_isError(outsize) != 0 {
let msg = format!("cannot decompress ({})", explain_error(outsize));
Err(io::Error::new(io::ErrorKind::Other, msg))
Err(io::Error::other(msg))
} else if outsize != size {
let msg = format!(
"decompress size mismatch (expected {}, got {})",
size, outsize
);
Err(io::Error::new(io::ErrorKind::Other, msg))
Err(io::Error::other(msg))
} else {
Ok(buf)
}
Expand Down
Loading