Skip to content

Commit 4796d36

Browse files
committed
clippy fixes
1 parent 49d4d66 commit 4796d36

4 files changed

Lines changed: 24 additions & 20 deletions

File tree

minifi_rust/extensions/minifi_rs_playground/src/processors/get_file/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fn test_complex_dir_with_filter(
120120
.flow_file
121121
.attributes
122122
.get("filename")
123-
.and_then(|filename| Some(filename.contains(expected_filename_part)))
123+
.map(|filename| filename.contains(expected_filename_part))
124124
.unwrap_or(false)
125125
}));
126126
let sum_file_len = transferred_flow_files

minifi_rust/minifi_native/src/c_ffi/c_ffi_streams.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ pub struct CffiInputStream<'a> {
1313
_marker: std::marker::PhantomData<&'a ()>,
1414
}
1515

16+
// SAFETY: The wrapped `minifi_input_stream*` points at a
17+
// `minifi::io::InputStream` on the C++ side. That interface has no
18+
// thread-affine state (no `thread_local`, no owning-thread assertions in the
19+
// concrete implementations — see
20+
// `minifi-api/common/include/minifi-cpp/io/InputStream.h` and the impls under
21+
// `libminifi/src/core/`). The stream also cannot escape the FFI callback it
22+
// was constructed in: the `'a` lifetime is bound to that call frame.
1623
unsafe impl<'a> Send for CffiInputStream<'a> {}
1724

1825
impl<'a> CffiInputStream<'a> {
@@ -93,6 +100,9 @@ impl<'a> CffiOutputStream<'a> {
93100
}
94101
}
95102

103+
// SAFETY: Same reasoning as `CffiInputStream` above — the underlying
104+
// `minifi::io::OutputStream` has no thread affinity, and the `'a` lifetime keeps
105+
// the stream inside its FFI callback frame.
96106
unsafe impl<'a> Send for CffiOutputStream<'a> {}
97107

98108
impl<'a> std::io::Write for CffiOutputStream<'a> {

minifi_rust/minifi_native/src/mock/mock_logger.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,14 @@ mod tests {
6666

6767
let mut call_count = 0;
6868

69-
trace!(
70-
mock_logger,
71-
"This is a trace message {}",
72-
|| -> u32 {
73-
call_count += 1;
74-
call_count
75-
}()
76-
);
77-
error!(
78-
mock_logger,
79-
"This is an error message {}",
80-
|| -> u32 {
81-
call_count += 1;
82-
call_count
83-
}()
84-
);
69+
trace!(mock_logger, "This is a trace message {}", {
70+
call_count += 1;
71+
call_count
72+
});
73+
error!(mock_logger, "This is an error message {}", {
74+
call_count += 1;
75+
call_count
76+
});
8577

8678
assert_eq!(mock_logger.logs.lock().unwrap().len(), 1);
8779
assert_eq!(call_count, 1);

minifi_rust/minifi_native/src/mock/mock_process_session.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,13 @@ mod tests {
156156
#[test]
157157
fn test_read_in_batches() {
158158
let session = MockProcessSession::new();
159-
let mut flow_file = MockFlowFile::new();
160-
flow_file.content = RefCell::from("Hello, World!".to_string().as_bytes().to_vec());
159+
let flow_file = MockFlowFile::new();
160+
flow_file
161+
.content
162+
.replace("Hello, World!".as_bytes().to_vec());
161163
let mut vec: Vec<u8> = Vec::new();
162164

163-
let res = session.read_in_batches(&mut flow_file, 1, |batch| {
165+
let res = session.read_in_batches(&flow_file, 1, |batch| {
164166
assert_eq!(batch.len(), 1);
165167
vec.push(batch[0]);
166168
Ok(())

0 commit comments

Comments
 (0)