You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2024/01/10 08:54:25 UTC

(incubator-opendal) 02/04: Remove deps

This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch add-comments
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git

commit f24590c684fc10db3a23f64e50201e165feb3617
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Wed Jan 10 16:29:01 2024 +0800

    Remove deps
    
    Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
 Cargo.lock                          |  2 --
 core/Cargo.toml                     |  2 --
 core/src/raw/oio/list/api.rs        |  9 ++-------
 core/src/raw/oio/read/api.rs        | 24 +++++++-----------------
 core/src/raw/oio/stream/api.rs      |  8 ++------
 core/src/raw/oio/write/api.rs       | 22 ++++++----------------
 core/src/services/memory/backend.rs | 10 +++++-----
 7 files changed, 22 insertions(+), 55 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 0be9fc19a3..8502b66eb3 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4566,10 +4566,8 @@ dependencies = [
  "openssh",
  "openssh-sftp-client",
  "opentelemetry",
- "parking_lot 0.12.1",
  "percent-encoding",
  "persy",
- "pin-project",
  "pretty_assertions",
  "prometheus",
  "prometheus-client",
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 1ca4ca41e4..2f81161040 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -268,10 +268,8 @@ openssh-sftp-client = { version = "0.14.0", optional = true, features = [
   "tracing",
 ] }
 opentelemetry = { version = "0.21.0", optional = true }
-parking_lot = "0.12"
 percent-encoding = "2"
 persy = { version = "1.4.6", optional = true }
-pin-project = "1"
 prometheus = { version = "0.13", features = ["process"], optional = true }
 prometheus-client = { version = "0.22.0", optional = true }
 prost = { version = "0.11", optional = true }
diff --git a/core/src/raw/oio/list/api.rs b/core/src/raw/oio/list/api.rs
index 6130aa914f..07dbdf774b 100644
--- a/core/src/raw/oio/list/api.rs
+++ b/core/src/raw/oio/list/api.rs
@@ -22,8 +22,6 @@ use std::pin::Pin;
 use std::task::Context;
 use std::task::Poll;
 
-use pin_project::pin_project;
-
 use crate::raw::oio::Entry;
 use crate::*;
 
@@ -105,8 +103,6 @@ pub trait ListExt: List {
     }
 }
 
-/// Make this future `!Unpin` for compatibility with async trait methods.
-#[pin_project(!Unpin)]
 pub struct NextFuture<'a, L: List + Unpin + ?Sized> {
     lister: &'a mut L,
 }
@@ -117,9 +113,8 @@ where
 {
     type Output = Result<Option<Entry>>;
 
-    fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<Option<Entry>>> {
-        let this = self.project();
-        Pin::new(this.lister).poll_next(cx)
+    fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<Option<Entry>>> {
+        self.lister.poll_next(cx)
     }
 }
 
diff --git a/core/src/raw/oio/read/api.rs b/core/src/raw/oio/read/api.rs
index c2c9681122..f6175f4360 100644
--- a/core/src/raw/oio/read/api.rs
+++ b/core/src/raw/oio/read/api.rs
@@ -25,7 +25,6 @@ use std::task::Poll;
 
 use bytes::Bytes;
 use futures::Future;
-use pin_project::pin_project;
 use tokio::io::ReadBuf;
 
 use crate::*;
@@ -207,8 +206,6 @@ pub trait ReadExt: Read {
     }
 }
 
-/// Make this future `!Unpin` for compatibility with async trait methods.
-#[pin_project(!Unpin)]
 pub struct ReadFuture<'a, R: Read + Unpin + ?Sized> {
     reader: &'a mut R,
     buf: &'a mut [u8],
@@ -221,13 +218,11 @@ where
     type Output = Result<usize>;
 
     fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<usize>> {
-        let this = self.project();
-        Pin::new(this.reader).poll_read(cx, this.buf)
+        let this = self.get_mut();
+        this.reader.poll_read(cx, this.buf)
     }
 }
 
-/// Make this future `!Unpin` for compatibility with async trait methods.
-#[pin_project(!Unpin)]
 pub struct SeekFuture<'a, R: Read + Unpin + ?Sized> {
     reader: &'a mut R,
     pos: io::SeekFrom,
@@ -240,13 +235,11 @@ where
     type Output = Result<u64>;
 
     fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<u64>> {
-        let this = self.project();
-        Pin::new(this.reader).poll_seek(cx, *this.pos)
+        let this = self.get_mut();
+        this.reader.poll_seek(cx, this.pos)
     }
 }
 
-/// Make this future `!Unpin` for compatibility with async trait methods.
-#[pin_project(!Unpin)]
 pub struct NextFuture<'a, R: Read + Unpin + ?Sized> {
     reader: &'a mut R,
 }
@@ -257,14 +250,11 @@ where
 {
     type Output = Option<Result<Bytes>>;
 
-    fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Result<Bytes>>> {
-        let this = self.project();
-        Pin::new(this.reader).poll_next(cx)
+    fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Result<Bytes>>> {
+        self.reader.poll_next(cx)
     }
 }
 
-/// Make this future `!Unpin` for compatibility with async trait methods.
-#[pin_project(!Unpin)]
 pub struct ReadToEndFuture<'a, R: Read + Unpin + ?Sized> {
     reader: &'a mut R,
     buf: &'a mut Vec<u8>,
@@ -277,7 +267,7 @@ where
     type Output = Result<usize>;
 
     fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<usize>> {
-        let this = self.project();
+        let this = self.get_mut();
         let start_len = this.buf.len();
 
         loop {
diff --git a/core/src/raw/oio/stream/api.rs b/core/src/raw/oio/stream/api.rs
index 6dcbbb5a56..fe95bb656a 100644
--- a/core/src/raw/oio/stream/api.rs
+++ b/core/src/raw/oio/stream/api.rs
@@ -23,7 +23,6 @@ use std::task::Poll;
 
 use bytes::Bytes;
 use bytes::BytesMut;
-use pin_project::pin_project;
 
 use crate::*;
 
@@ -105,8 +104,6 @@ pub trait StreamExt: Stream {
     }
 }
 
-/// Make this future `!Unpin` for compatibility with async trait methods.
-#[pin_project(!Unpin)]
 pub struct NextFuture<'a, T: Stream + Unpin + ?Sized> {
     inner: &'a mut T,
 }
@@ -117,9 +114,8 @@ where
 {
     type Output = Option<Result<Bytes>>;
 
-    fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Result<Bytes>>> {
-        let this = self.project();
-        Pin::new(this.inner).poll_next(cx)
+    fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Result<Bytes>>> {
+        self.inner.poll_next(cx)
     }
 }
 
diff --git a/core/src/raw/oio/write/api.rs b/core/src/raw/oio/write/api.rs
index 55d0730785..637fd11dc0 100644
--- a/core/src/raw/oio/write/api.rs
+++ b/core/src/raw/oio/write/api.rs
@@ -22,8 +22,6 @@ use std::pin::Pin;
 use std::task::Context;
 use std::task::Poll;
 
-use pin_project::pin_project;
-
 use crate::raw::*;
 use crate::*;
 
@@ -153,8 +151,6 @@ pub trait WriteExt: Write {
     }
 }
 
-/// Make this future `!Unpin` for compatibility with async trait methods.
-#[pin_project(!Unpin)]
 pub struct WriteFuture<'a, W: Write + Unpin + ?Sized> {
     writer: &'a mut W,
     buf: &'a dyn oio::WriteBuf,
@@ -167,13 +163,11 @@ where
     type Output = Result<usize>;
 
     fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<usize>> {
-        let this = self.project();
-        Pin::new(this.writer).poll_write(cx, *this.buf)
+        let this = self.get_mut();
+        this.writer.poll_write(cx, this.buf)
     }
 }
 
-/// Make this future `!Unpin` for compatibility with async trait methods.
-#[pin_project(!Unpin)]
 pub struct AbortFuture<'a, W: Write + Unpin + ?Sized> {
     writer: &'a mut W,
 }
@@ -184,14 +178,11 @@ where
 {
     type Output = Result<()>;
 
-    fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>> {
-        let this = self.project();
-        Pin::new(this.writer).poll_abort(cx)
+    fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>> {
+        self.writer.poll_abort(cx)
     }
 }
 
-/// Make this future `!Unpin` for compatibility with async trait methods.
-#[pin_project(!Unpin)]
 pub struct CloseFuture<'a, W: Write + Unpin + ?Sized> {
     writer: &'a mut W,
 }
@@ -202,9 +193,8 @@ where
 {
     type Output = Result<()>;
 
-    fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>> {
-        let this = self.project();
-        Pin::new(this.writer).poll_close(cx)
+    fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>> {
+        self.writer.poll_close(cx)
     }
 }
 
diff --git a/core/src/services/memory/backend.rs b/core/src/services/memory/backend.rs
index 3057d0e46e..6549d0dbe8 100644
--- a/core/src/services/memory/backend.rs
+++ b/core/src/services/memory/backend.rs
@@ -19,9 +19,9 @@ use std::collections::BTreeMap;
 use std::collections::HashMap;
 use std::fmt::Debug;
 use std::sync::Arc;
+use std::sync::Mutex;
 
 use async_trait::async_trait;
-use parking_lot::Mutex;
 
 use crate::raw::adapters::typed_kv;
 use crate::*;
@@ -96,7 +96,7 @@ impl typed_kv::Adapter for Adapter {
     }
 
     fn blocking_get(&self, path: &str) -> Result<Option<typed_kv::Value>> {
-        match self.inner.lock().get(path) {
+        match self.inner.lock().unwrap().get(path) {
             None => Ok(None),
             Some(bs) => Ok(Some(bs.to_owned())),
         }
@@ -107,7 +107,7 @@ impl typed_kv::Adapter for Adapter {
     }
 
     fn blocking_set(&self, path: &str, value: typed_kv::Value) -> Result<()> {
-        self.inner.lock().insert(path.to_string(), value);
+        self.inner.lock().unwrap().insert(path.to_string(), value);
 
         Ok(())
     }
@@ -117,7 +117,7 @@ impl typed_kv::Adapter for Adapter {
     }
 
     fn blocking_delete(&self, path: &str) -> Result<()> {
-        self.inner.lock().remove(path);
+        self.inner.lock().unwrap().remove(path);
 
         Ok(())
     }
@@ -127,7 +127,7 @@ impl typed_kv::Adapter for Adapter {
     }
 
     fn blocking_scan(&self, path: &str) -> Result<Vec<String>> {
-        let inner = self.inner.lock();
+        let inner = self.inner.lock().unwrap();
         let keys: Vec<_> = if path.is_empty() {
             inner.keys().cloned().collect()
         } else {