You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by ko...@apache.org on 2025/11/13 07:01:41 UTC
(opendal) branch remove-scheme-enum-from-bindings created (now 20694895b)
This is an automated email from the ASF dual-hosted git repository.
koushiro pushed a change to branch remove-scheme-enum-from-bindings
in repository https://gitbox.apache.org/repos/asf/opendal.git
at 20694895b refactor(bindings): remove Scheme enum from c/cpp/lua bindings
This branch includes the following new commits:
new 20694895b refactor(bindings): remove Scheme enum from c/cpp/lua bindings
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(opendal) 01/01: refactor(bindings): remove Scheme enum from c/cpp/lua bindings
Posted by ko...@apache.org.
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 20694895b268e1a9a42d18c78e1b2d709a018cc0
Author: koushiro <ko...@gmail.com>
AuthorDate: Thu Nov 13 15:01:27 2025 +0800
refactor(bindings): remove Scheme enum from c/cpp/lua bindings
---
bindings/c/src/operator.rs | 16 +++-------------
bindings/cpp/src/async.rs | 10 ++++------
bindings/cpp/src/lib.rs | 3 ---
bindings/lua/src/lib.rs | 8 +-------
4 files changed, 8 insertions(+), 29 deletions(-)
diff --git a/bindings/c/src/operator.rs b/bindings/c/src/operator.rs
index fb6c2571e..72a09cbc5 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() {
@@ -346,7 +336,7 @@ pub unsafe extern "C" fn opendal_operator_reader(
return opendal_result_operator_reader {
reader: std::ptr::null_mut(),
error: opendal_error::new(err),
- }
+ };
}
};
@@ -413,7 +403,7 @@ pub unsafe extern "C" fn opendal_operator_writer(
return opendal_result_operator_writer {
writer: std::ptr::null_mut(),
error: opendal_error::new(err),
- }
+ };
}
};
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)),
};