Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo committed Dec 5, 2024
1 parent accaf94 commit f3a1b0e
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 72 deletions.
10 changes: 4 additions & 6 deletions core/src/layers/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,6 @@ impl<D: oio::Delete, I: LoggingInterceptor> oio::Delete for LoggingDeleter<D, I>
fn delete(&mut self, path: &str, args: OpDelete) -> Result<()> {
let version = args
.version()
.clone()
.map(|v| v.to_string())
.unwrap_or_else(|| "<latest>".to_string());

Expand All @@ -1337,7 +1336,7 @@ impl<D: oio::Delete, I: LoggingInterceptor> oio::Delete for LoggingDeleter<D, I>
&self.info,
Operation::DeleterDelete,
&[
("path", &path),
("path", path),
("version", &version),
("queued", &self.queued.to_string()),
("deleted", &self.deleted.to_string()),
Expand All @@ -1351,7 +1350,7 @@ impl<D: oio::Delete, I: LoggingInterceptor> oio::Delete for LoggingDeleter<D, I>
&self.info,
Operation::DeleterDelete,
&[
("path", &path),
("path", path),
("version", &version),
("queued", &self.queued.to_string()),
("deleted", &self.deleted.to_string()),
Expand Down Expand Up @@ -1416,7 +1415,6 @@ impl<D: oio::BlockingDelete, I: LoggingInterceptor> oio::BlockingDelete for Logg
fn delete(&mut self, path: &str, args: OpDelete) -> Result<()> {
let version = args
.version()
.clone()
.map(|v| v.to_string())
.unwrap_or_else(|| "<latest>".to_string());

Expand All @@ -1437,7 +1435,7 @@ impl<D: oio::BlockingDelete, I: LoggingInterceptor> oio::BlockingDelete for Logg
&self.info,
Operation::BlockingDeleterDelete,
&[
("path", &path),
("path", path),
("version", &version),
("queued", &self.queued.to_string()),
("deleted", &self.deleted.to_string()),
Expand All @@ -1451,7 +1449,7 @@ impl<D: oio::BlockingDelete, I: LoggingInterceptor> oio::BlockingDelete for Logg
&self.info,
Operation::BlockingDeleterDelete,
&[
("path", &path),
("path", path),
("version", &version),
("queued", &self.queued.to_string()),
("deleted", &self.deleted.to_string()),
Expand Down
2 changes: 1 addition & 1 deletion core/src/layers/observe/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ impl<R: oio::BlockingDelete, I: MetricsIntercept> oio::BlockingDelete for Metric

let start = Instant::now();

let res = match self.inner.delete(&path, args) {
let res = match self.inner.delete(path, args) {
Ok(entry) => Ok(entry),
Err(err) => {
self.interceptor.observe_operation_errors_total(
Expand Down
3 changes: 1 addition & 2 deletions core/src/raw/oio/delete/batch_delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ pub trait BatchDelete: Send + Sync + Unpin + 'static {

/// delete_batch delete multiple paths at once.
///
/// - Implementations should make sure that the length of `batch` equals to the
/// return result's length.
/// - Implementations should make sure that the length of `batch` equals to the return result's length.
/// - Implementations should return error no path is deleted.
fn delete_batch(
&self,
Expand Down
20 changes: 4 additions & 16 deletions core/src/types/delete/blocking_deleter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,8 @@ impl BlockingDeleter {
I: IntoIterator<Item = D>,
D: IntoDeleteInput,
{
let mut iter = iter.into_iter();
loop {
match iter.next() {
Some(entry) => {
self.delete(entry)?;
}
None => break,
}
for entry in iter {
self.delete(entry)?;
}

Ok(())
Expand All @@ -91,14 +85,8 @@ impl BlockingDeleter {
I: IntoIterator<Item = Result<D>>,
D: IntoDeleteInput,
{
let mut iter = try_iter.into_iter();
loop {
match iter.next() {
Some(entry) => {
self.delete(entry?)?;
}
None => break,
}
for entry in try_iter {
self.delete(entry?)?;
}

Ok(())
Expand Down
29 changes: 6 additions & 23 deletions core/src/types/delete/deleter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ impl Deleter {
I: IntoIterator<Item = D>,
D: IntoDeleteInput,
{
let iter = iter.into_iter();
for entry in iter {
self.delete(entry).await?;
}
Expand All @@ -145,14 +144,8 @@ impl Deleter {
I: IntoIterator<Item = Result<D>>,
D: IntoDeleteInput,
{
let mut iter = try_iter.into_iter();
loop {
match iter.next() {
Some(entry) => {
self.delete(entry?).await?;
}
None => break,
}
for entry in try_iter {
self.delete(entry?).await?;
}

Ok(())
Expand All @@ -171,13 +164,8 @@ impl Deleter {
D: IntoDeleteInput,
{
let mut stream = pin!(stream);
loop {
match stream.next().await {
Some(entry) => {
self.delete(entry).await?;
}
None => break,
}
while let Some(entry) = stream.next().await {
self.delete(entry).await?;
}

Ok(())
Expand All @@ -196,13 +184,8 @@ impl Deleter {
D: IntoDeleteInput,
{
let mut stream = pin!(try_stream);
loop {
match stream.next().await.transpose()? {
Some(entry) => {
self.delete(entry).await?;
}
None => break,
}
while let Some(entry) = stream.next().await.transpose()? {
self.delete(entry).await?;
}

Ok(())
Expand Down
36 changes: 17 additions & 19 deletions core/src/types/delete/futures_delete_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,23 @@ impl<T: IntoDeleteInput> Sink<T> for FuturesDeleteSink {
type Error = Error;

fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>> {
loop {
return match &mut self.state {
State::Idle(_) => Poll::Ready(Ok(())),
State::Delete(fut) => {
let (deleter, res) = ready!(fut.as_mut().poll(cx));
self.state = State::Idle(Some(deleter));
Poll::Ready(res.map(|_| ()))
}
State::Flush(fut) => {
let (deleter, res) = ready!(fut.as_mut().poll(cx));
self.state = State::Idle(Some(deleter));
Poll::Ready(res.map(|_| ()))
}
State::Close(fut) => {
let (deleter, res) = ready!(fut.as_mut().poll(cx));
self.state = State::Idle(Some(deleter));
Poll::Ready(res.map(|_| ()))
}
};
match &mut self.state {
State::Idle(_) => Poll::Ready(Ok(())),
State::Delete(fut) => {
let (deleter, res) = ready!(fut.as_mut().poll(cx));
self.state = State::Idle(Some(deleter));
Poll::Ready(res.map(|_| ()))
}
State::Flush(fut) => {
let (deleter, res) = ready!(fut.as_mut().poll(cx));
self.state = State::Idle(Some(deleter));
Poll::Ready(res.map(|_| ()))
}
State::Close(fut) => {
let (deleter, res) = ready!(fut.as_mut().poll(cx));
self.state = State::Idle(Some(deleter));
Poll::Ready(res.map(|_| ()))
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions core/src/types/operator/blocking_operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ impl BlockingOperator {
/// # Ok(())
/// # }
/// ```
#[deprecated(note = "use `BlockingOperator::delete_iter` instead", since = "0.52")]
#[deprecated(note = "use `BlockingOperator::delete_iter` instead", since = "0.52.0")]
pub fn remove_via(&self, input: impl Iterator<Item = String>) -> Result<()> {
for path in input {
self.delete(&path)?;
Expand All @@ -859,9 +859,9 @@ impl BlockingOperator {
/// # Ok(())
/// # }
/// ```
#[deprecated(note = "use `BlockingOperator::delete_iter` instead", since = "0.52")]
#[deprecated(note = "use `BlockingOperator::delete_iter` instead", since = "0.52.0")]
pub fn remove(&self, paths: Vec<String>) -> Result<()> {
self.delete_iter(paths.into_iter())
self.delete_iter(paths)
}

/// Remove the path and all nested dirs and files recursively.
Expand Down
4 changes: 2 additions & 2 deletions core/src/types/operator/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ impl Operator {
/// # Ok(())
/// # }
/// ```
#[deprecated(note = "use `Operator::delete_iter` instead", since = "0.52")]
#[deprecated(note = "use `Operator::delete_iter` instead", since = "0.52.0")]
pub async fn remove(&self, paths: Vec<String>) -> Result<()> {
let mut deleter = self.deleter().await?;
deleter.delete_iter(paths).await?;
Expand Down Expand Up @@ -1642,7 +1642,7 @@ impl Operator {
/// # Ok(())
/// # }
/// ```
#[deprecated(note = "use `Operator::delete_stream` instead", since = "0.52")]
#[deprecated(note = "use `Operator::delete_stream` instead", since = "0.52.0")]
pub async fn remove_via(&self, input: impl Stream<Item = String> + Unpin) -> Result<()> {
let mut deleter = self.deleter().await?;
deleter
Expand Down

0 comments on commit f3a1b0e

Please sign in to comment.