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

koushiro pushed a commit to branch extract-pcloud-service
in repository https://gitbox.apache.org/repos/asf/opendal.git

commit d56e9559ea4c49463768410e4263a097700d5aca
Author: koushiro <[email protected]>
AuthorDate: Wed Dec 17 12:57:49 2025 +0800

    refactor: Split pcloud service to new crate
---
 core/Cargo.lock                                    | 15 ++++++++
 core/Cargo.toml                                    |  3 +-
 core/core/Cargo.toml                               |  1 -
 core/core/src/services/mod.rs                      |  5 ---
 core/services/pcloud/Cargo.toml                    | 43 ++++++++++++++++++++++
 .../pcloud => services/pcloud/src}/backend.rs      |  4 +-
 .../pcloud => services/pcloud/src}/config.rs       | 22 +++++------
 .../pcloud => services/pcloud/src}/core.rs         |  4 +-
 .../pcloud => services/pcloud/src}/deleter.rs      |  4 +-
 .../pcloud => services/pcloud/src}/docs.md         |  4 +-
 .../pcloud => services/pcloud/src}/error.rs        |  5 +--
 .../pcloud/mod.rs => services/pcloud/src/lib.rs}   | 12 +++---
 .../pcloud => services/pcloud/src}/lister.rs       |  7 ++--
 .../pcloud => services/pcloud/src}/writer.rs       |  4 +-
 core/src/lib.rs                                    |  2 +
 15 files changed, 95 insertions(+), 40 deletions(-)

diff --git a/core/Cargo.lock b/core/Cargo.lock
index e03ff0760..c62b88056 100644
--- a/core/Cargo.lock
+++ b/core/Cargo.lock
@@ -5576,6 +5576,7 @@ dependencies = [
  "opendal-service-obs",
  "opendal-service-opfs",
  "opendal-service-oss",
+ "opendal-service-pcloud",
  "opendal-service-persy",
  "opendal-service-postgresql",
  "opendal-service-redb",
@@ -6245,6 +6246,20 @@ dependencies = [
  "tracing-subscriber",
 ]
 
+[[package]]
+name = "opendal-service-pcloud"
+version = "0.55.0"
+dependencies = [
+ "bytes",
+ "ctor",
+ "http 1.4.0",
+ "log",
+ "opendal-core",
+ "serde",
+ "serde_json",
+ "tokio",
+]
+
 [[package]]
 name = "opendal-service-persy"
 version = "0.55.0"
diff --git a/core/Cargo.toml b/core/Cargo.toml
index e6231e25f..91ad9eea6 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -143,7 +143,7 @@ services-obs = ["dep:opendal-service-obs"]
 services-onedrive = ["opendal-core/services-onedrive"]
 services-opfs = ["dep:opendal-service-opfs"]
 services-oss = ["dep:opendal-service-oss"]
-services-pcloud = ["opendal-core/services-pcloud"]
+services-pcloud = ["dep:opendal-service-pcloud"]
 services-persy = ["dep:opendal-service-persy"]
 services-postgresql = ["dep:opendal-service-postgresql"]
 services-redb = ["dep:opendal-service-redb"]
@@ -227,6 +227,7 @@ opendal-service-moka = { path = "services/moka", version = 
"0.55.0", optional =
 opendal-service-mysql = { path = "services/mysql", version = "0.55.0", 
optional = true, default-features = false }
 opendal-service-obs = { path = "services/obs", version = "0.55.0", optional = 
true, default-features = false }
 opendal-service-oss = { path = "services/oss", version = "0.55.0", optional = 
true, default-features = false }
+opendal-service-pcloud = { path = "services/pcloud", version = "0.55.0", 
optional = true, default-features = false }
 opendal-service-persy = { path = "services/persy", version = "0.55.0", 
optional = true, default-features = false }
 opendal-service-postgresql = { path = "services/postgresql", version = 
"0.55.0", optional = true, default-features = false }
 opendal-service-redb = { path = "services/redb", version = "0.55.0", optional 
= true, default-features = false }
diff --git a/core/core/Cargo.toml b/core/core/Cargo.toml
index edfaefc7d..5ec2d8845 100644
--- a/core/core/Cargo.toml
+++ b/core/core/Cargo.toml
@@ -74,7 +74,6 @@ services-memory = []
 services-mongodb = ["dep:mongodb", "dep:mongodb-internal-macros"]
 services-monoiofs = ["dep:monoio", "dep:flume"]
 services-onedrive = []
-services-pcloud = []
 services-redis = ["dep:redis", "dep:fastpool", "redis?/tokio-rustls-comp"]
 services-redis-native-tls = ["services-redis", "redis?/tokio-native-tls-comp"]
 services-rocksdb = ["dep:rocksdb", "internal-tokio-rt"]
diff --git a/core/core/src/services/mod.rs b/core/core/src/services/mod.rs
index e1553e71d..712e4261b 100644
--- a/core/core/src/services/mod.rs
+++ b/core/core/src/services/mod.rs
@@ -104,11 +104,6 @@ mod onedrive;
 #[cfg(feature = "services-onedrive")]
 pub use onedrive::*;
 
-#[cfg(feature = "services-pcloud")]
-mod pcloud;
-#[cfg(feature = "services-pcloud")]
-pub use pcloud::*;
-
 #[cfg(feature = "services-redis")]
 mod redis;
 #[cfg(feature = "services-redis")]
diff --git a/core/services/pcloud/Cargo.toml b/core/services/pcloud/Cargo.toml
new file mode 100644
index 000000000..8d58a1a9b
--- /dev/null
+++ b/core/services/pcloud/Cargo.toml
@@ -0,0 +1,43 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[package]
+description = "Apache OpenDAL pCloud service implementation"
+name = "opendal-service-pcloud"
+
+authors = { workspace = true }
+edition = { workspace = true }
+homepage = { workspace = true }
+license = { workspace = true }
+repository = { workspace = true }
+rust-version = { workspace = true }
+version = { workspace = true }
+
+[package.metadata.docs.rs]
+all-features = true
+
+[dependencies]
+opendal-core = { path = "../../core", version = "0.55.0", default-features = 
false }
+bytes = { workspace = true }
+ctor = { workspace = true }
+http = { workspace = true }
+log = { workspace = true }
+serde = { workspace = true, features = ["derive"] }
+serde_json = { workspace = true }
+
+[dev-dependencies]
+tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
diff --git a/core/core/src/services/pcloud/backend.rs 
b/core/services/pcloud/src/backend.rs
similarity index 99%
rename from core/core/src/services/pcloud/backend.rs
rename to core/services/pcloud/src/backend.rs
index b704e11cc..2b300e0ac 100644
--- a/core/core/src/services/pcloud/backend.rs
+++ b/core/services/pcloud/src/backend.rs
@@ -22,6 +22,8 @@ use bytes::Buf;
 use http::Response;
 use http::StatusCode;
 use log::debug;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 use super::PCLOUD_SCHEME;
 use super::config::PcloudConfig;
@@ -32,8 +34,6 @@ use super::error::parse_error;
 use super::lister::PcloudLister;
 use super::writer::PcloudWriter;
 use super::writer::PcloudWriters;
-use crate::raw::*;
-use crate::*;
 
 /// [pCloud](https://www.pcloud.com/) services support.
 #[doc = include_str!("docs.md")]
diff --git a/core/core/src/services/pcloud/config.rs 
b/core/services/pcloud/src/config.rs
similarity index 86%
rename from core/core/src/services/pcloud/config.rs
rename to core/services/pcloud/src/config.rs
index 64deabda8..07b8d22b6 100644
--- a/core/core/src/services/pcloud/config.rs
+++ b/core/services/pcloud/src/config.rs
@@ -17,6 +17,7 @@
 
 use std::fmt::Debug;
 
+use opendal_core::*;
 use serde::Deserialize;
 use serde::Serialize;
 
@@ -49,10 +50,10 @@ impl Debug for PcloudConfig {
     }
 }
 
-impl crate::Configurator for PcloudConfig {
+impl Configurator for PcloudConfig {
     type Builder = PcloudBuilder;
 
-    fn from_uri(uri: &crate::types::OperatorUri) -> crate::Result<Self> {
+    fn from_uri(uri: &OperatorUri) -> Result<Self> {
         let mut map = uri.options().clone();
         if let Some(authority) = uri.authority() {
             map.insert("endpoint".to_string(), format!("https://{authority}";));
@@ -75,28 +76,27 @@ impl crate::Configurator for PcloudConfig {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::Configurator;
-    use crate::types::OperatorUri;
 
     #[test]
-    fn from_uri_sets_endpoint_and_root() {
+    fn from_uri_sets_endpoint_and_root() -> Result<()> {
         let uri = OperatorUri::new(
             "pcloud://api.pcloud.com/drive/photos",
             vec![("username".to_string(), "alice".to_string())],
-        )
-        .unwrap();
+        )?;
 
-        let cfg = PcloudConfig::from_uri(&uri).unwrap();
+        let cfg = PcloudConfig::from_uri(&uri)?;
         assert_eq!(cfg.endpoint, "https://api.pcloud.com".to_string());
         assert_eq!(cfg.root.as_deref(), Some("drive/photos"));
         assert_eq!(cfg.username.as_deref(), Some("alice"));
+        Ok(())
     }
 
     #[test]
-    fn from_uri_allows_missing_authority() {
-        let uri = OperatorUri::new("pcloud", Vec::<(String, 
String)>::new()).unwrap();
+    fn from_uri_allows_missing_authority() -> Result<()> {
+        let uri = OperatorUri::new("pcloud", Vec::<(String, String)>::new())?;
 
-        let cfg = PcloudConfig::from_uri(&uri).unwrap();
+        let cfg = PcloudConfig::from_uri(&uri)?;
         assert!(cfg.endpoint.is_empty());
+        Ok(())
     }
 }
diff --git a/core/core/src/services/pcloud/core.rs 
b/core/services/pcloud/src/core.rs
similarity index 99%
rename from core/core/src/services/pcloud/core.rs
rename to core/services/pcloud/src/core.rs
index b11149e93..35703a8ca 100644
--- a/core/core/src/services/pcloud/core.rs
+++ b/core/services/pcloud/src/core.rs
@@ -23,12 +23,12 @@ use http::Request;
 use http::Response;
 use http::StatusCode;
 use http::header;
+use opendal_core::raw::*;
+use opendal_core::*;
 use serde::Deserialize;
 
 use super::error::PcloudError;
 use super::error::parse_error;
-use crate::raw::*;
-use crate::*;
 
 #[derive(Clone)]
 pub struct PcloudCore {
diff --git a/core/core/src/services/pcloud/deleter.rs 
b/core/services/pcloud/src/deleter.rs
similarity index 97%
rename from core/core/src/services/pcloud/deleter.rs
rename to core/services/pcloud/src/deleter.rs
index 3e433309c..255d6f933 100644
--- a/core/core/src/services/pcloud/deleter.rs
+++ b/core/services/pcloud/src/deleter.rs
@@ -19,12 +19,12 @@ use std::sync::Arc;
 
 use bytes::Buf;
 use http::StatusCode;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 use super::core::*;
 use super::error::PcloudError;
 use super::error::parse_error;
-use crate::raw::*;
-use crate::*;
 
 pub struct PcloudDeleter {
     core: Arc<PcloudCore>,
diff --git a/core/core/src/services/pcloud/docs.md 
b/core/services/pcloud/src/docs.md
similarity index 93%
rename from core/core/src/services/pcloud/docs.md
rename to core/services/pcloud/src/docs.md
index 67c5d9b01..821688316 100644
--- a/core/core/src/services/pcloud/docs.md
+++ b/core/services/pcloud/src/docs.md
@@ -26,9 +26,9 @@ You can refer to [`PcloudBuilder`]'s docs for more information
 ### Via Builder
 
 ```rust,no_run
-use anyhow::Result;
-use opendal_core::services::Pcloud;
 use opendal_core::Operator;
+use opendal_core::Result;
+use opendal_service_pcloud::Pcloud;
 
 #[tokio::main]
 async fn main() -> Result<()> {
diff --git a/core/core/src/services/pcloud/error.rs 
b/core/services/pcloud/src/error.rs
similarity index 98%
rename from core/core/src/services/pcloud/error.rs
rename to core/services/pcloud/src/error.rs
index 644dc4eb1..5b36479f9 100644
--- a/core/core/src/services/pcloud/error.rs
+++ b/core/services/pcloud/src/error.rs
@@ -18,11 +18,10 @@
 use std::fmt::Debug;
 
 use http::Response;
+use opendal_core::raw::*;
+use opendal_core::*;
 use serde::Deserialize;
 
-use crate::raw::*;
-use crate::*;
-
 /// PcloudError is the error returned by Pcloud service.
 #[derive(Default, Deserialize)]
 pub(super) struct PcloudError {
diff --git a/core/core/src/services/pcloud/mod.rs 
b/core/services/pcloud/src/lib.rs
similarity index 84%
rename from core/core/src/services/pcloud/mod.rs
rename to core/services/pcloud/src/lib.rs
index 3295b09ba..d8ce9e499 100644
--- a/core/core/src/services/pcloud/mod.rs
+++ b/core/services/pcloud/src/lib.rs
@@ -15,10 +15,9 @@
 // specific language governing permissions and limitations
 // under the License.
 
-/// Default scheme for pcloud service.
-pub const PCLOUD_SCHEME: &str = "pcloud";
-
-use crate::types::DEFAULT_OPERATOR_REGISTRY;
+//! pCloud service implementation for Apache OpenDAL.
+#![cfg_attr(docsrs, feature(doc_cfg))]
+#![deny(missing_docs)]
 
 mod backend;
 mod config;
@@ -31,7 +30,10 @@ mod writer;
 pub use backend::PcloudBuilder as Pcloud;
 pub use config::PcloudConfig;
 
+/// Default scheme for pcloud service.
+pub const PCLOUD_SCHEME: &str = "pcloud";
+
 #[ctor::ctor]
 fn register_pcloud_service() {
-    DEFAULT_OPERATOR_REGISTRY.register::<Pcloud>(PCLOUD_SCHEME);
+    opendal_core::DEFAULT_OPERATOR_REGISTRY.register::<Pcloud>(PCLOUD_SCHEME);
 }
diff --git a/core/core/src/services/pcloud/lister.rs 
b/core/services/pcloud/src/lister.rs
similarity index 95%
rename from core/core/src/services/pcloud/lister.rs
rename to core/services/pcloud/src/lister.rs
index c3486b68a..8cd8cf766 100644
--- a/core/core/src/services/pcloud/lister.rs
+++ b/core/services/pcloud/src/lister.rs
@@ -19,12 +19,11 @@ use std::sync::Arc;
 
 use bytes::Buf;
 use http::StatusCode;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 use super::core::*;
 use super::error::parse_error;
-use crate::raw::oio::Entry;
-use crate::raw::*;
-use crate::*;
 
 pub struct PcloudLister {
     core: Arc<PcloudCore>,
@@ -76,7 +75,7 @@ impl oio::PageList for PcloudLister {
                             let md = parse_list_metadata(content)?;
                             let path = build_rel_path(&self.core.root, &path);
 
-                            ctx.entries.push_back(Entry::new(&path, md))
+                            ctx.entries.push_back(oio::Entry::new(&path, md))
                         }
                     }
 
diff --git a/core/core/src/services/pcloud/writer.rs 
b/core/services/pcloud/src/writer.rs
similarity index 97%
rename from core/core/src/services/pcloud/writer.rs
rename to core/services/pcloud/src/writer.rs
index b4d04028f..091d5b9a9 100644
--- a/core/core/src/services/pcloud/writer.rs
+++ b/core/services/pcloud/src/writer.rs
@@ -19,12 +19,12 @@ use std::sync::Arc;
 
 use bytes::Buf;
 use http::StatusCode;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 use super::core::PcloudCore;
 use super::error::PcloudError;
 use super::error::parse_error;
-use crate::raw::*;
-use crate::*;
 
 pub type PcloudWriters = oio::OneShotWriter<PcloudWriter>;
 
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 055936fe5..3b03ff778 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -80,6 +80,8 @@ pub mod services {
     pub use opendal_service_opfs::*;
     #[cfg(feature = "services-oss")]
     pub use opendal_service_oss::*;
+    #[cfg(feature = "services-pcloud")]
+    pub use opendal_service_pcloud::*;
     #[cfg(feature = "services-persy")]
     pub use opendal_service_persy::*;
     #[cfg(feature = "services-postgresql")]

Reply via email to