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

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 887b4499e refactor(services/onedrive): split into separate crate 
(#6996)
887b4499e is described below

commit 887b4499e29b187a75d0978d719144d7fed82f5f
Author: XYenon <[email protected]>
AuthorDate: Thu Dec 18 19:27:39 2025 +0800

    refactor(services/onedrive): split into separate crate (#6996)
    
    * refactor(services/onedrive): split into separate crate
    
    Extract OneDrive service into its own crate 'opendal-service-onedrive' while
    maintaining the public API surface 'opendal::services::onedrive' through the
    facade.
    
    Changes:
    - Create new crate at core/services/onedrive/ with full service 
implementation
    - Update imports from crate::* to opendal_core::* in service code
    - Remove onedrive module from core/core/src/services/mod.rs
    - Update root Cargo.toml to depend on opendal-service-onedrive with feature 
gate
    - Add facade re-export in core/src/lib.rs to preserve public API
    - Fix documentation examples to import from opendal_service_onedrive crate
    - All tests pass, clippy checks pass, public API preserved
    
    * merge
    
    ---------
    
    Co-authored-by: Xuanwo <[email protected]>
---
 core/Cargo.lock                                    | 20 ++++++++
 core/Cargo.toml                                    |  3 +-
 core/core/Cargo.toml                               |  1 -
 core/core/src/services/mod.rs                      |  5 --
 core/services/onedrive/Cargo.toml                  | 56 ++++++++++++++++++++++
 .../onedrive => services/onedrive/src}/backend.rs  |  5 +-
 .../onedrive => services/onedrive/src}/builder.rs  |  8 ++--
 .../onedrive => services/onedrive/src}/config.rs   |  9 ++--
 .../onedrive => services/onedrive/src}/core.rs     |  6 ++-
 .../onedrive => services/onedrive/src}/deleter.rs  |  5 +-
 .../onedrive => services/onedrive/src}/docs.md     |  4 +-
 .../onedrive => services/onedrive/src}/error.rs    |  4 +-
 .../onedrive/src}/graph_model.rs                   |  0
 .../mod.rs => services/onedrive/src/lib.rs}        | 12 +++--
 .../onedrive => services/onedrive/src}/lister.rs   |  7 +--
 .../onedrive => services/onedrive/src}/writer.rs   |  5 +-
 core/src/lib.rs                                    |  2 +
 17 files changed, 117 insertions(+), 35 deletions(-)

diff --git a/core/Cargo.lock b/core/Cargo.lock
index d99e5de7d..2b3dfa295 100644
--- a/core/Cargo.lock
+++ b/core/Cargo.lock
@@ -5582,6 +5582,7 @@ dependencies = [
  "opendal-service-moka",
  "opendal-service-mysql",
  "opendal-service-obs",
+ "opendal-service-onedrive",
  "opendal-service-opfs",
  "opendal-service-oss",
  "opendal-service-pcloud",
@@ -6330,6 +6331,25 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "opendal-service-onedrive"
+version = "0.55.0"
+dependencies = [
+ "anyhow",
+ "bytes",
+ "ctor",
+ "http 1.4.0",
+ "log",
+ "mea",
+ "opendal-core",
+ "pretty_assertions",
+ "reqwest",
+ "serde",
+ "serde_json",
+ "tokio",
+ "tracing-subscriber",
+]
+
 [[package]]
 name = "opendal-service-opfs"
 version = "0.55.0"
diff --git a/core/Cargo.toml b/core/Cargo.toml
index a2657824b..baedf191c 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -140,7 +140,7 @@ services-mongodb = ["opendal-core/services-mongodb"]
 services-monoiofs = ["opendal-core/services-monoiofs"]
 services-mysql = ["dep:opendal-service-mysql"]
 services-obs = ["dep:opendal-service-obs"]
-services-onedrive = ["opendal-core/services-onedrive"]
+services-onedrive = ["dep:opendal-service-onedrive"]
 services-opfs = ["dep:opendal-service-opfs"]
 services-oss = ["dep:opendal-service-oss"]
 services-pcloud = ["dep:opendal-service-pcloud"]
@@ -234,6 +234,7 @@ opendal-service-mini-moka = { path = "services/mini_moka", 
version = "0.55.0", o
 opendal-service-moka = { path = "services/moka", version = "0.55.0", optional 
= true, default-features = false }
 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-onedrive = { path = "services/onedrive", 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 }
diff --git a/core/core/Cargo.toml b/core/core/Cargo.toml
index 3e9751e42..b4be18ad8 100644
--- a/core/core/Cargo.toml
+++ b/core/core/Cargo.toml
@@ -65,7 +65,6 @@ services-lakefs = []
 services-memory = []
 services-mongodb = ["dep:mongodb", "dep:mongodb-internal-macros"]
 services-monoiofs = ["dep:monoio", "dep:flume"]
-services-onedrive = []
 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 ed83487a3..f6d006eec 100644
--- a/core/core/src/services/mod.rs
+++ b/core/core/src/services/mod.rs
@@ -59,11 +59,6 @@ mod monoiofs;
 #[cfg(feature = "services-monoiofs")]
 pub use monoiofs::*;
 
-#[cfg(feature = "services-onedrive")]
-mod onedrive;
-#[cfg(feature = "services-onedrive")]
-pub use onedrive::*;
-
 #[cfg(feature = "services-redis")]
 mod redis;
 #[cfg(feature = "services-redis")]
diff --git a/core/services/onedrive/Cargo.toml 
b/core/services/onedrive/Cargo.toml
new file mode 100644
index 000000000..9875dfae0
--- /dev/null
+++ b/core/services/onedrive/Cargo.toml
@@ -0,0 +1,56 @@
+# 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 OneDrive service implementation"
+name = "opendal-service-onedrive"
+
+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 }
+mea = { version = "0.5.1" }
+reqwest = { version = "0.12.24", features = [
+  "stream",
+], default-features = false }
+serde = { workspace = true, features = ["derive"] }
+serde_json = { workspace = true }
+tokio = { workspace = true, features = ["macros", "io-util"] }
+
+[dev-dependencies]
+anyhow = { version = "1.0.100", features = ["std"] }
+pretty_assertions = "1"
+tokio = { workspace = true, features = [
+  "macros",
+  "rt-multi-thread",
+  "io-util",
+] }
+tracing-subscriber = "0.3"
diff --git a/core/core/src/services/onedrive/backend.rs 
b/core/services/onedrive/src/backend.rs
similarity index 98%
rename from core/core/src/services/onedrive/backend.rs
rename to core/services/onedrive/src/backend.rs
index c6856ddf6..e6ecb8150 100644
--- a/core/core/src/services/onedrive/backend.rs
+++ b/core/services/onedrive/src/backend.rs
@@ -20,13 +20,14 @@ use std::sync::Arc;
 use http::Response;
 use http::StatusCode;
 
+use opendal_core::raw::*;
+use opendal_core::*;
+
 use super::core::OneDriveCore;
 use super::deleter::OneDriveDeleter;
 use super::error::parse_error;
 use super::lister::OneDriveLister;
 use super::writer::OneDriveWriter;
-use crate::raw::*;
-use crate::*;
 
 #[derive(Clone, Debug)]
 pub struct OnedriveBackend {
diff --git a/core/core/src/services/onedrive/builder.rs 
b/core/services/onedrive/src/builder.rs
similarity index 98%
rename from core/core/src/services/onedrive/builder.rs
rename to core/services/onedrive/src/builder.rs
index 0d7b977c2..8d2371a71 100644
--- a/core/core/src/services/onedrive/builder.rs
+++ b/core/services/onedrive/src/builder.rs
@@ -20,14 +20,14 @@ use std::sync::Arc;
 
 use log::debug;
 use mea::mutex::Mutex;
-use services::onedrive::core::OneDriveCore;
-use services::onedrive::core::OneDriveSigner;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 use super::ONEDRIVE_SCHEME;
 use super::backend::OnedriveBackend;
 use super::config::OnedriveConfig;
-use crate::raw::*;
-use crate::*;
+use super::core::OneDriveCore;
+use super::core::OneDriveSigner;
 
 /// Microsoft [OneDrive](https://onedrive.com) backend support.
 #[doc = include_str!("docs.md")]
diff --git a/core/core/src/services/onedrive/config.rs 
b/core/services/onedrive/src/config.rs
similarity index 93%
rename from core/core/src/services/onedrive/config.rs
rename to core/services/onedrive/src/config.rs
index e3d4a53c8..91d4d7b1c 100644
--- a/core/core/src/services/onedrive/config.rs
+++ b/core/services/onedrive/src/config.rs
@@ -17,6 +17,7 @@
 
 use std::fmt::Debug;
 
+use opendal_core::{Configurator, OperatorUri, Result};
 use serde::Deserialize;
 use serde::Serialize;
 
@@ -50,10 +51,10 @@ impl Debug for OnedriveConfig {
     }
 }
 
-impl crate::Configurator for OnedriveConfig {
+impl Configurator for OnedriveConfig {
     type Builder = OnedriveBuilder;
 
-    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(root) = uri.root() {
@@ -79,8 +80,8 @@ impl crate::Configurator for OnedriveConfig {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::Configurator;
-    use crate::types::OperatorUri;
+    use opendal_core::Configurator;
+    use opendal_core::OperatorUri;
 
     #[test]
     fn from_uri_sets_root() {
diff --git a/core/core/src/services/onedrive/core.rs 
b/core/services/onedrive/src/core.rs
similarity index 99%
rename from core/core/src/services/onedrive/core.rs
rename to core/services/onedrive/src/core.rs
index 76b334d81..aa85145f6 100644
--- a/core/core/src/services/onedrive/core.rs
+++ b/core/services/onedrive/src/core.rs
@@ -17,6 +17,7 @@
 
 use std::fmt::Debug;
 use std::sync::Arc;
+use std::time::Duration;
 
 use bytes::Buf;
 use bytes::Bytes;
@@ -26,10 +27,11 @@ use http::StatusCode;
 use http::header;
 use mea::mutex::Mutex;
 
+use opendal_core::raw::*;
+use opendal_core::*;
+
 use super::error::parse_error;
 use super::graph_model::*;
-use crate::raw::*;
-use crate::*;
 
 pub struct OneDriveCore {
     pub info: Arc<AccessorInfo>,
diff --git a/core/core/src/services/onedrive/deleter.rs 
b/core/services/onedrive/src/deleter.rs
similarity index 97%
rename from core/core/src/services/onedrive/deleter.rs
rename to core/services/onedrive/src/deleter.rs
index 68d38c21d..30e477021 100644
--- a/core/core/src/services/onedrive/deleter.rs
+++ b/core/services/onedrive/src/deleter.rs
@@ -19,10 +19,11 @@ use std::sync::Arc;
 
 use http::StatusCode;
 
+use opendal_core::raw::*;
+use opendal_core::*;
+
 use super::core::OneDriveCore;
 use super::error::parse_error;
-use crate::raw::*;
-use crate::*;
 
 /// Delete operation
 /// Documentation: 
https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_delete?view=odsp-graph-online
diff --git a/core/core/src/services/onedrive/docs.md 
b/core/services/onedrive/src/docs.md
similarity index 98%
rename from core/core/src/services/onedrive/docs.md
rename to core/services/onedrive/src/docs.md
index 4461e7578..80728800f 100644
--- a/core/core/src/services/onedrive/docs.md
+++ b/core/services/onedrive/src/docs.md
@@ -74,7 +74,7 @@ When you have a current access token:
 
 ```rust,no_run
 use anyhow::Result;
-use opendal_core::services::Onedrive;
+use opendal_service_onedrive::Onedrive;
 use opendal_core::Operator;
 
 #[tokio::main]
@@ -93,7 +93,7 @@ When you have an Application with a refresh token:
 
 ```rust,no_run
 use anyhow::Result;
-use opendal_core::services::Onedrive;
+use opendal_service_onedrive::Onedrive;
 use opendal_core::Operator;
 
 #[tokio::main]
diff --git a/core/core/src/services/onedrive/error.rs 
b/core/services/onedrive/src/error.rs
similarity index 97%
rename from core/core/src/services/onedrive/error.rs
rename to core/services/onedrive/src/error.rs
index 99b890588..3d540a335 100644
--- a/core/core/src/services/onedrive/error.rs
+++ b/core/services/onedrive/src/error.rs
@@ -18,8 +18,8 @@
 use http::Response;
 use http::StatusCode;
 
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 /// Parse error response into Error.
 pub(super) fn parse_error(response: Response<Buffer>) -> Error {
diff --git a/core/core/src/services/onedrive/graph_model.rs 
b/core/services/onedrive/src/graph_model.rs
similarity index 100%
rename from core/core/src/services/onedrive/graph_model.rs
rename to core/services/onedrive/src/graph_model.rs
diff --git a/core/core/src/services/onedrive/mod.rs 
b/core/services/onedrive/src/lib.rs
similarity index 84%
rename from core/core/src/services/onedrive/mod.rs
rename to core/services/onedrive/src/lib.rs
index ebf9f189e..3493d2478 100644
--- a/core/core/src/services/onedrive/mod.rs
+++ b/core/services/onedrive/src/lib.rs
@@ -15,10 +15,9 @@
 // specific language governing permissions and limitations
 // under the License.
 
-/// Default scheme for onedrive service.
-pub const ONEDRIVE_SCHEME: &str = "onedrive";
-
-use crate::types::DEFAULT_OPERATOR_REGISTRY;
+#![cfg_attr(docsrs, feature(doc_cfg))]
+//! Microsoft OneDrive service implementation for Apache OpenDAL.
+#![deny(missing_docs)]
 
 mod backend;
 mod builder;
@@ -33,7 +32,10 @@ mod writer;
 pub use builder::OnedriveBuilder as Onedrive;
 pub use config::OnedriveConfig;
 
+/// Default scheme for onedrive service.
+pub const ONEDRIVE_SCHEME: &str = "onedrive";
+
 #[ctor::ctor]
 fn register_onedrive_service() {
-    DEFAULT_OPERATOR_REGISTRY.register::<Onedrive>(ONEDRIVE_SCHEME);
+    
opendal_core::DEFAULT_OPERATOR_REGISTRY.register::<Onedrive>(ONEDRIVE_SCHEME);
 }
diff --git a/core/core/src/services/onedrive/lister.rs 
b/core/services/onedrive/src/lister.rs
similarity index 98%
rename from core/core/src/services/onedrive/lister.rs
rename to core/services/onedrive/src/lister.rs
index 86454e2a2..98d3abd53 100644
--- a/core/core/src/services/onedrive/lister.rs
+++ b/core/services/onedrive/src/lister.rs
@@ -19,14 +19,15 @@ use std::sync::Arc;
 
 use bytes::Buf;
 
+use opendal_core::raw::oio;
+use opendal_core::raw::*;
+use opendal_core::*;
+
 use super::core::OneDriveCore;
 use super::error::parse_error;
 use super::graph_model::GENERAL_SELECT_PARAM;
 use super::graph_model::GraphApiOneDriveListResponse;
 use super::graph_model::ItemType;
-use crate::raw::oio;
-use crate::raw::*;
-use crate::*;
 
 pub struct OneDriveLister {
     core: Arc<OneDriveCore>,
diff --git a/core/core/src/services/onedrive/writer.rs 
b/core/services/onedrive/src/writer.rs
similarity index 99%
rename from core/core/src/services/onedrive/writer.rs
rename to core/services/onedrive/src/writer.rs
index e986b0b23..adf2364b1 100644
--- a/core/core/src/services/onedrive/writer.rs
+++ b/core/services/onedrive/src/writer.rs
@@ -21,12 +21,13 @@ use bytes::Buf;
 use bytes::Bytes;
 use http::StatusCode;
 
+use opendal_core::raw::*;
+use opendal_core::*;
+
 use super::core::OneDriveCore;
 use super::error::parse_error;
 use super::graph_model::OneDriveItem;
 use super::graph_model::OneDriveUploadSessionCreationResponseBody;
-use crate::raw::*;
-use crate::*;
 
 pub struct OneDriveWriter {
     core: Arc<OneDriveCore>,
diff --git a/core/src/lib.rs b/core/src/lib.rs
index e36baa274..ad19c2a2a 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -92,6 +92,8 @@ pub mod services {
     pub use opendal_service_mysql::*;
     #[cfg(feature = "services-obs")]
     pub use opendal_service_obs::*;
+    #[cfg(feature = "services-onedrive")]
+    pub use opendal_service_onedrive::*;
     #[cfg(all(target_arch = "wasm32", feature = "services-opfs"))]
     pub use opendal_service_opfs::*;
     #[cfg(feature = "services-oss")]

Reply via email to