summaryrefslogtreecommitdiff
path: root/rust/src/binary_view
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-12-04 15:10:40 -0500
committerMason Reed <mason@vector35.com>2025-12-05 12:26:29 -0500
commit6546844ca4274cd11ec2c91da7c6d7b5e8a82d0b (patch)
tree7341b815993247cba9df7ea95585ce9723510fa0 /rust/src/binary_view
parent6eb12c3c3f53079a822881bf6e197105b25a0fe3 (diff)
[Rust] Fix misc clippy lints and warnings
These are introduced after changing to Rust 1.91.1
Diffstat (limited to 'rust/src/binary_view')
-rw-r--r--rust/src/binary_view/reader.rs17
-rw-r--r--rust/src/binary_view/writer.rs12
2 files changed, 10 insertions, 19 deletions
diff --git a/rust/src/binary_view/reader.rs b/rust/src/binary_view/reader.rs
index 685914e2..3ec105fc 100644
--- a/rust/src/binary_view/reader.rs
+++ b/rust/src/binary_view/reader.rs
@@ -21,7 +21,7 @@ use crate::binary_view::{BinaryView, BinaryViewBase};
use crate::Endianness;
use crate::rc::Ref;
-use std::io::{ErrorKind, Read, Seek, SeekFrom};
+use std::io::{Read, Seek, SeekFrom};
pub struct BinaryReader {
view: Ref<BinaryView>,
@@ -107,14 +107,11 @@ impl Seek for BinaryReader {
SeekFrom::End(end_offset) => {
// We do NOT need to add the image base here as
// the reader (unlike the writer) can set the virtual base.
- let offset =
- self.view
- .len()
- .checked_add_signed(end_offset)
- .ok_or(std::io::Error::new(
- ErrorKind::Other,
- "Seeking from end overflowed",
- ))?;
+ let offset = self
+ .view
+ .len()
+ .checked_add_signed(end_offset)
+ .ok_or(std::io::Error::other("Seeking from end overflowed"))?;
self.seek_to_offset(offset);
}
};
@@ -130,7 +127,7 @@ impl Read for BinaryReader {
let result = unsafe { BNReadData(self.handle, buf.as_mut_ptr() as *mut _, len) };
if !result {
- Err(std::io::Error::new(ErrorKind::Other, "Read out of bounds"))
+ Err(std::io::Error::other("Read out of bounds"))
} else {
Ok(len)
}
diff --git a/rust/src/binary_view/writer.rs b/rust/src/binary_view/writer.rs
index 176a54d8..ca570761 100644
--- a/rust/src/binary_view/writer.rs
+++ b/rust/src/binary_view/writer.rs
@@ -21,7 +21,7 @@ use crate::binary_view::{BinaryView, BinaryViewBase, BinaryViewExt};
use crate::Endianness;
use crate::rc::Ref;
-use std::io::{ErrorKind, Seek, SeekFrom, Write};
+use std::io::{Seek, SeekFrom, Write};
pub struct BinaryWriter {
view: Ref<BinaryView>,
@@ -88,10 +88,7 @@ impl Seek for BinaryWriter {
let view_end = self.view.original_image_base() + self.view.len();
let offset = view_end
.checked_add_signed(end_offset)
- .ok_or(std::io::Error::new(
- ErrorKind::Other,
- "Seeking from end overflowed",
- ))?;
+ .ok_or(std::io::Error::other("Seeking from end overflowed"))?;
self.seek_to_offset(offset);
}
};
@@ -105,10 +102,7 @@ impl Write for BinaryWriter {
let len = buf.len();
let result = unsafe { BNWriteData(self.handle, buf.as_ptr() as *mut _, len) };
if !result {
- Err(std::io::Error::new(
- std::io::ErrorKind::Other,
- "write out of bounds",
- ))
+ Err(std::io::Error::other("write out of bounds"))
} else {
Ok(len)
}