You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by sh...@apache.org on 2024/02/12 18:15:15 UTC
(daffodil-extra) 03/04: remove CustomSeek code, rename read_seek.rs to stdin_seek.rs
This is an automated email from the ASF dual-hosted git repository.
shanedell pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil-extra.git
commit 6237b5f497dbab507b45c408fdc671367593c626
Author: Shane Dell <sh...@gmail.com>
AuthorDate: Tue Feb 6 21:16:05 2024 -0500
remove CustomSeek code, rename read_seek.rs to stdin_seek.rs
---
lsbfdump-jni-rs/native/src/helper_functions.rs | 10 +++++-----
lsbfdump-jni-rs/native/src/lib.rs | 2 +-
lsbfdump-jni-rs/native/src/{read_seek.rs => stdin_seek.rs} | 6 ------
3 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/lsbfdump-jni-rs/native/src/helper_functions.rs b/lsbfdump-jni-rs/native/src/helper_functions.rs
index bc96990..c9f0f65 100644
--- a/lsbfdump-jni-rs/native/src/helper_functions.rs
+++ b/lsbfdump-jni-rs/native/src/helper_functions.rs
@@ -17,13 +17,13 @@
// View https://rust-lang.github.io/api-guidelines/naming.html for naming conventions for functions
-use crate::read_seek::{CustomReadSeek, StdinWithSeek};
+use crate::stdin_seek::StdinWithSeek;
use std::fs::File;
use std::io::{self, Read, Seek, SeekFrom};
-pub fn lsbf_dump(reader: &mut Box<dyn CustomReadSeek>, offset: u64, length: u64, show_address: bool) -> io::Result<Vec<String>> {
+pub fn lsbf_dump(reader: &mut dyn Read, offset: u64, length: u64, show_address: bool) -> io::Result<Vec<String>> {
let mut lines = Vec::new();
let mut count = 0;
let mut buffer = [0; 4];
@@ -44,16 +44,16 @@ pub fn lsbf_dump(reader: &mut Box<dyn CustomReadSeek>, offset: u64, length: u64,
Ok(lines)
}
-pub fn open_and_seek_input_stream(filename: &str, offset: u64) -> io::Result<Box<dyn CustomReadSeek>> {
+pub fn open_and_seek_input_stream(filename: &str, offset: u64) -> io::Result<Box<dyn Read>> {
if filename == "-" {
let mut stdin_with_seek = StdinWithSeek;
stdin_with_seek.seek(SeekFrom::Start(offset))?;
- Ok(Box::new(stdin_with_seek) as Box<dyn CustomReadSeek>)
+ Ok(Box::new(stdin_with_seek) as Box<dyn Read>)
} else {
let file = File::open(filename)?;
let mut file_seek = io::BufReader::new(file);
file_seek.seek(SeekFrom::Start(offset))?;
- Ok(Box::new(file_seek) as Box<dyn CustomReadSeek>)
+ Ok(Box::new(file_seek) as Box<dyn Read>)
}
}
diff --git a/lsbfdump-jni-rs/native/src/lib.rs b/lsbfdump-jni-rs/native/src/lib.rs
index f7bc844..80889d4 100644
--- a/lsbfdump-jni-rs/native/src/lib.rs
+++ b/lsbfdump-jni-rs/native/src/lib.rs
@@ -16,7 +16,7 @@
*/
mod helper_functions;
-mod read_seek;
+mod stdin_seek;
use helper_functions::{lsbf_dump, open_and_seek_input_stream};
diff --git a/lsbfdump-jni-rs/native/src/read_seek.rs b/lsbfdump-jni-rs/native/src/stdin_seek.rs
similarity index 84%
rename from lsbfdump-jni-rs/native/src/read_seek.rs
rename to lsbfdump-jni-rs/native/src/stdin_seek.rs
index 5612d8f..d9e95cd 100644
--- a/lsbfdump-jni-rs/native/src/read_seek.rs
+++ b/lsbfdump-jni-rs/native/src/stdin_seek.rs
@@ -18,12 +18,6 @@
// View https://rust-lang.github.io/api-guidelines/naming.html for naming conventions for traits and structs
use std::io::{self, Cursor, Read, Seek, SeekFrom};
-// Need custom trait so we can do Box<dyn CustomReadSeek>
-// as Box<dyn Read + Seek> can't be done since both Read
-// and Seek are non-auto traits
-pub trait CustomReadSeek: Read + Seek {}
-impl<T: Read + Seek> CustomReadSeek for T {}
-
pub struct StdinWithSeek;
impl Read for StdinWithSeek {