This is an automated email from the ASF dual-hosted git repository. koushiro pushed a commit to branch remove-scheme-enum-from-bindings in repository https://gitbox.apache.org/repos/asf/opendal.git
commit 4786c2a643c59d486df375595d1377be5c48d3ef Author: koushiro <[email protected]> AuthorDate: Thu Nov 13 15:01:27 2025 +0800 refactor(bindings): remove Scheme enum from c/cpp/lua bindings refactor(bindings): remove Scheme enum from c/cpp/lua bindings --- bindings/c/src/operator.rs | 12 +----------- bindings/cpp/src/async.rs | 10 ++++------ bindings/cpp/src/lib.rs | 3 --- bindings/lua/src/lib.rs | 8 +------- 4 files changed, 6 insertions(+), 27 deletions(-) diff --git a/bindings/c/src/operator.rs b/bindings/c/src/operator.rs index fb6c2571e..df2e65dea 100644 --- a/bindings/c/src/operator.rs +++ b/bindings/c/src/operator.rs @@ -18,7 +18,6 @@ use std::collections::HashMap; use std::ffi::c_void; use std::os::raw::c_char; -use std::str::FromStr; use std::sync::LazyLock; use ::opendal as core; @@ -86,7 +85,7 @@ impl opendal_operator { } fn build_operator( - schema: core::Scheme, + schema: &str, map: HashMap<String, String>, ) -> core::Result<core::blocking::Operator> { let op = core::Operator::via_iter(schema, map)?.layer(core::layers::RetryLayer::new()); @@ -144,15 +143,6 @@ pub unsafe extern "C" fn opendal_operator_new( let scheme = std::ffi::CStr::from_ptr(scheme) .to_str() .expect("malformed scheme"); - let scheme = match core::Scheme::from_str(scheme) { - Ok(s) => s, - Err(e) => { - return opendal_result_operator_new { - op: std::ptr::null_mut(), - error: opendal_error::new(e), - }; - } - }; let mut map = HashMap::<String, String>::default(); if !options.is_null() { diff --git a/bindings/cpp/src/async.rs b/bindings/cpp/src/async.rs index be461ea51..eb4c41b04 100644 --- a/bindings/cpp/src/async.rs +++ b/bindings/cpp/src/async.rs @@ -15,17 +15,17 @@ // specific language governing permissions and limitations // under the License. -use anyhow::Result; -use cxx_async::CxxAsyncException; -use opendal as od; use std::collections::HashMap; use std::future::Future; use std::ops::Deref; use std::pin::Pin; -use std::str::FromStr; use std::sync::{Arc, OnceLock}; use tokio::sync::Mutex; +use anyhow::Result; +use cxx_async::CxxAsyncException; +use opendal as od; + #[cxx::bridge(namespace = opendal::ffi::async_op)] mod ffi { struct HashMapValue { @@ -148,8 +148,6 @@ fn get_lister_counter() -> &'static Mutex<usize> { } fn new_operator(scheme: &str, configs: Vec<ffi::HashMapValue>) -> Result<Box<Operator>> { - let scheme = od::Scheme::from_str(scheme)?; - let map: HashMap<String, String> = configs .into_iter() .map(|value| (value.key, value.value)) diff --git a/bindings/cpp/src/lib.rs b/bindings/cpp/src/lib.rs index 409606e17..ae05423b3 100644 --- a/bindings/cpp/src/lib.rs +++ b/bindings/cpp/src/lib.rs @@ -22,7 +22,6 @@ mod reader; mod types; use std::collections::HashMap; -use std::str::FromStr; use std::sync::LazyLock; use anyhow::Result; @@ -161,8 +160,6 @@ mod ffi { pub struct Operator(od::blocking::Operator); fn new_operator(scheme: &str, configs: Vec<ffi::HashMapValue>) -> Result<*mut Operator> { - let scheme = od::Scheme::from_str(scheme)?; - let map: HashMap<String, String> = configs .into_iter() .map(|value| (value.key, value.value)) diff --git a/bindings/lua/src/lib.rs b/bindings/lua/src/lib.rs index 5b55015f1..165c88f9e 100644 --- a/bindings/lua/src/lib.rs +++ b/bindings/lua/src/lib.rs @@ -16,7 +16,6 @@ // under the License. use std::collections::HashMap; -use std::str::FromStr; use std::sync::LazyLock; use ::opendal as od; @@ -58,12 +57,7 @@ fn operator_new<'a>( map.insert(key, value); } - let od_schema = match od::Scheme::from_str(&schema) { - Ok(s) => s, - Err(e) => return Err(LuaError::external(e)), - }; - - let op = match od::Operator::via_iter(od_schema, map) { + let op = match od::Operator::via_iter(schema, map) { Ok(o) => o, Err(e) => return Err(LuaError::external(e)), };
