Skip to content

Commit 5c79e34

Browse files
committed
Fix MSRV 1.70 compatibility for Error::other()
std::io::Error::other() was stabilized in Rust 1.74, so revert to Error::new(ErrorKind::Other, ...) and allow the clippy::io_other_error lint at the crate level.
1 parent 69cee64 commit 5c79e34

4 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/full_parser/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub fn read_file(file_path: &str) -> Result<ParsedData, std::io::Error> {
4444
}
4545
parser
4646
.consume_bytes(&buf[READ_START..(READ_START + num_bytes_read)])
47-
.map_err(|e| std::io::Error::other(format!("err: {:?}", e)))?;
47+
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("err: {:?}", e)))?;
4848
file_position += num_bytes_read as u64;
4949
}
5050

@@ -76,7 +76,7 @@ pub fn read_file(file_path: &str) -> Result<ParsedData, std::io::Error> {
7676
}
7777
parser
7878
.consume_bytes(&buf[READ_START..(READ_START + num_bytes_read)])
79-
.map_err(|e| std::io::Error::other(format!("err: {:?}", e)))?;
79+
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("err: {:?}", e)))?;
8080
section_position += num_bytes_read as u64;
8181
}
8282
}

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::io_other_error)]
2+
13
pub mod full_parser;
24
pub mod stream_parser;
35
pub mod unpack;

src/stream_parser/file_reader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,7 @@ pub fn read_file_with_simple_callback<CB: FnMut(&Message) -> SimpleCallbackResul
12621262
}
12631263
log_parser
12641264
.consume_bytes(&buf[READ_START..(READ_START + num_bytes_read)])
1265-
.map_err(|e| std::io::Error::other(format!("err: {:?}", e)))?;
1265+
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("err: {:?}", e)))?;
12661266
total_bytes_read += num_bytes_read;
12671267
file_position += num_bytes_read as u64;
12681268
}
@@ -1305,7 +1305,7 @@ pub fn read_file_with_simple_callback<CB: FnMut(&Message) -> SimpleCallbackResul
13051305
}
13061306
log_parser
13071307
.consume_bytes(&buf[READ_START..(READ_START + num_bytes_read)])
1308-
.map_err(|e| std::io::Error::other(format!("err: {:?}", e)))?;
1308+
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("err: {:?}", e)))?;
13091309
total_bytes_read += num_bytes_read;
13101310
section_position += num_bytes_read as u64;
13111311
}

src/unpack/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::io::{Error, Result};
1+
use std::io::{Error, ErrorKind, Result};
22
use std::iter::*;
33

44
/// Convert a array of eight u8 elements into a u64
@@ -84,5 +84,5 @@ pub fn as_f32_le(arr: &[u8]) -> f32 {
8484
/// assert_eq!(unpack::as_str(&arr).unwrap(), "Hello");
8585
/// ```
8686
pub fn as_str(arr: &[u8]) -> Result<&str> {
87-
std::str::from_utf8(arr).map_err(|_| Error::other("data is not a string"))
87+
std::str::from_utf8(arr).map_err(|_| Error::new(ErrorKind::Other, "data is not a string"))
8888
}

0 commit comments

Comments
 (0)