Skip to content

Commit e515231

Browse files
committed
style: fix clippy
1 parent dee3e13 commit e515231

6 files changed

Lines changed: 24 additions & 39 deletions

File tree

backends/curl/src/async/loop.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ enum LoopTask {
5252
oneshot::Sender<NyquestResult<super::CurlAsyncResponse>>,
5353
),
5454
UnpauseRecvHandle(usize),
55-
UnpauseSendHandle(usize),
55+
_UnpauseSendHandle(usize),
5656
DropHandle(usize),
5757
Shutdown,
5858
}
@@ -68,11 +68,8 @@ impl From<LoopTask> for LoopTaskWrapper {
6868
impl Drop for LoopTaskWrapper {
6969
fn drop(&mut self) {
7070
let task = unsafe { ManuallyDrop::take(&mut self.0) };
71-
match task {
72-
LoopTask::ConstructHandle(handle, tx) => {
73-
tx.send(Err(handle)).ok();
74-
}
75-
_ => {}
71+
if let LoopTask::ConstructHandle(handle, tx) = task {
72+
tx.send(Err(handle)).ok();
7673
}
7774
}
7875
}
@@ -97,14 +94,15 @@ impl RequestHandle {
9794
.await?;
9895

9996
let (tx, rx) = oneshot::channel();
100-
self.manager
97+
let send_task_res = self
98+
.manager
10199
.clone()
102100
.dispatch_task(LoopTask::QueryHandleResponse(
103101
self.shared_context.id,
104102
self,
105103
tx,
106104
));
107-
let Ok(res) = rx.await else {
105+
let (Ok(_), Ok(res)) = (send_task_res, rx.await) else {
108106
return Err(
109107
io::Error::new(io::ErrorKind::ConnectionAborted, "handle not found").into(),
110108
);
@@ -141,7 +139,8 @@ impl RequestHandle {
141139
return Poll::Ready(res.map(|()| None));
142140
};
143141
self.manager
144-
.dispatch_task(LoopTask::UnpauseRecvHandle(self.shared_context.id));
142+
.dispatch_task(LoopTask::UnpauseRecvHandle(self.shared_context.id))
143+
.ok();
145144
self.shared_context.waker.register(cx.waker());
146145
Poll::Pending
147146
}
@@ -150,7 +149,8 @@ impl RequestHandle {
150149
impl Drop for RequestHandle {
151150
fn drop(&mut self) {
152151
self.manager
153-
.dispatch_task(LoopTask::DropHandle(self.shared_context.id));
152+
.dispatch_task(LoopTask::DropHandle(self.shared_context.id))
153+
.ok();
154154
}
155155
}
156156

@@ -270,7 +270,7 @@ impl LoopManager {
270270
impl Drop for LoopManager {
271271
fn drop(&mut self) {
272272
if let Some(inner) = self.inner.get_mut() {
273-
inner.dispatch_task(LoopTask::Shutdown);
273+
inner.dispatch_task(LoopTask::Shutdown).ok();
274274
}
275275
}
276276
}
@@ -364,7 +364,7 @@ fn run_loop(multl_waker_tx: oneshot::Sender<LoopManagerShared>) {
364364
handle.unpause_read().ok();
365365
}
366366
}
367-
LoopTask::UnpauseSendHandle(id) => {
367+
LoopTask::_UnpauseSendHandle(id) => {
368368
if let Some((handle, _)) = slab.get(id) {
369369
// Ignore the error. Also see
370370
handle.unpause_write().ok();

backends/curl/src/async/pause.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use curl_sys::{CURLPAUSE_RECV, CURLPAUSE_SEND};
22

3-
pub const CURLPAUSE_ALL: i32 = CURLPAUSE_RECV | CURLPAUSE_SEND;
3+
pub const _CURLPAUSE_ALL: i32 = CURLPAUSE_RECV | CURLPAUSE_SEND;
44

55
#[derive(Clone, Copy)]
66
pub(super) struct EasyPause(*mut curl_sys::CURL);

backends/curl/src/blocking/handler.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::sync::{Arc, Mutex};
22

33
use curl::easy::{Handler, WriteError};
4-
use nyquest_interface::blocking::BoxedStream;
54

65
use crate::state::RequestState;
76

@@ -28,11 +27,11 @@ impl Handler for BlockingHandler {
2827
true
2928
}
3029

31-
fn read(&mut self, data: &mut [u8]) -> Result<usize, curl::easy::ReadError> {
30+
fn read(&mut self, _data: &mut [u8]) -> Result<usize, curl::easy::ReadError> {
3231
Ok(0)
3332
}
3433

35-
fn seek(&mut self, whence: std::io::SeekFrom) -> curl::easy::SeekResult {
34+
fn seek(&mut self, _whence: std::io::SeekFrom) -> curl::easy::SeekResult {
3635
curl::easy::SeekResult::Fail
3736
}
3837
}

backends/curl/src/blocking/multi_easy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl MultiEasy {
163163
let easy = self.easy.detach(&mut self.multi)?;
164164
easy.reset();
165165
unsafe { self.share.bind_easy2(easy)? };
166-
crate::request::populate_request(url, req, options, easy, |easy, stream| unimplemented!())
166+
crate::request::populate_request(url, req, options, easy, |_easy, _stream| unimplemented!())
167167
}
168168

169169
pub fn status(&mut self) -> NyquestResult<u16> {

backends/curl/src/error.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ impl<T> IntoNyquestResult<T> for Result<T, curl::Error> {
1818
return Err(NyquestError::RequestTimeout);
1919
}
2020
Ok(self.map_err(|e| {
21-
std::io::Error::new(
22-
ErrorKind::Other,
23-
format!("curl error:{}:{}", ctx, e.description()),
24-
)
21+
std::io::Error::other(format!("curl error:{}:{}", ctx, e.description()))
2522
})?)
2623
}
2724
}
@@ -30,10 +27,7 @@ impl<T> IntoNyquestResult<T> for Result<T, curl::MultiError> {
3027
fn into_nyquest_result(self, ctx: &str) -> NyquestResult<T> {
3128
// TODO: proper error mapping
3229
Ok(self.map_err(|e| {
33-
std::io::Error::new(
34-
ErrorKind::Other,
35-
format!("curl multi error:{}:{}", ctx, e.description()),
36-
)
30+
std::io::Error::other(format!("curl multi error:{}:{}", ctx, e.description()))
3731
})?)
3832
}
3933
}
@@ -42,10 +36,7 @@ impl<T> IntoNyquestResult<T> for Result<T, curl::ShareError> {
4236
fn into_nyquest_result(self, ctx: &str) -> NyquestResult<T> {
4337
// TODO: proper error mapping
4438
Ok(self.map_err(|e| {
45-
std::io::Error::new(
46-
ErrorKind::Other,
47-
format!("curl share error:{}:{}", ctx, e.description()),
48-
)
39+
std::io::Error::other(format!("curl share error:{}:{}", ctx, e.description()))
4940
})?)
5041
}
5142
}

backends/curl/src/request.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn populate_request<S, H: Handler>(
1010
req: Request<S>,
1111
options: &nyquest_interface::client::ClientOptions,
1212
easy: &mut Easy2<H>,
13-
populate_stream: impl FnOnce(&mut Easy2<H>, S) -> nyquest_interface::Result<()>,
13+
_populate_stream: impl FnOnce(&mut Easy2<H>, S) -> nyquest_interface::Result<()>,
1414
) -> nyquest_interface::Result<()> {
1515
if !options.use_default_proxy {
1616
easy.noproxy("*")
@@ -70,12 +70,7 @@ pub fn populate_request<S, H: Handler>(
7070
easy.post_fields_copy(&content)
7171
.into_nyquest_result("set CURLOPT_COPYPOSTFIELDS")?;
7272
}
73-
Some(Body::Stream {
74-
stream,
75-
content_type,
76-
}) => {
77-
unimplemented!()
78-
}
73+
Some(Body::Stream { .. }) => unimplemented!(),
7974
Some(Body::Form { fields }) => {
8075
let mut buf =
8176
String::with_capacity(fields.iter().map(|(k, v)| k.len() + v.len() + 2).sum());
@@ -123,9 +118,9 @@ pub fn populate_request<S, H: Handler>(
123118
)));
124119
}
125120
}
126-
formpart.add().map_err(|e| {
127-
nyquest_interface::Error::Io(io::Error::new(ErrorKind::Other, e.to_string()))
128-
})?;
121+
formpart
122+
.add()
123+
.map_err(|e| nyquest_interface::Error::Io(io::Error::other(e.to_string())))?;
129124
}
130125
easy.httppost(form)
131126
.into_nyquest_result("set CURLOPT_HTTPPOST")?;

0 commit comments

Comments
 (0)