Skip to content

Commit

Permalink
fix bindings: cpp, dotnet, haskell, ocaml, ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorgan committed Jan 19, 2025
1 parent 5c98d37 commit 8337e0e
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bindings/cpp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl Operator {
// Safety: The bytes created from bs will be dropped after the function call.
// So it's safe to declare its lifetime as 'static.
fn write(&self, path: &str, bs: &'static [u8]) -> Result<()> {
Ok(self.0.write(path, bs)?)
Ok(self.0.write(path, bs).map(|_| ())?)
}

fn exists(&self, path: &str) -> Result<bool> {
Expand Down
2 changes: 1 addition & 1 deletion bindings/dotnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub unsafe extern "C" fn blocking_operator_write(
let op = &*(op);
let path = std::ffi::CStr::from_ptr(path).to_str().unwrap();
let content = std::ffi::CStr::from_ptr(content).to_str().unwrap();
op.write(path, content.to_owned()).unwrap()
op.write(path, content.to_owned()).map(|_| ()).unwrap()
}

/// # Safety
Expand Down
2 changes: 1 addition & 1 deletion bindings/haskell/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ pub unsafe extern "C" fn blocking_write(
let bytes = Vec::from_raw_parts(bytes as *mut u8, len, len);

let res = match op.write(path_str, bytes.clone()) {
Ok(()) => FFIResult::ok(()),
Ok(_) => FFIResult::ok(()),
Err(e) => FFIResult::err_with_source("Failed to write", e),
};

Expand Down
2 changes: 1 addition & 1 deletion bindings/ocaml/src/operator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub fn blocking_write(
path: String,
bs: &'static [u8],
) -> Result<(), String> {
map_res_error(operator.0.write(path.as_str(), bs))
map_res_error(operator.0.write(path.as_str(), bs).map(|_| ()))
}

#[ocaml::func]
Expand Down
1 change: 1 addition & 0 deletions bindings/ruby/src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ impl Operator {
rb_self
.0
.write(&path, bs.to_bytes())
.map(|_| ())
.map_err(|err| Error::new(ruby.exception_runtime_error(), err.to_string()))
}

Expand Down
6 changes: 4 additions & 2 deletions core/src/layers/dtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,9 @@ impl<R: oio::Write> oio::Write for DtraceLayerWrapper<R> {
self.inner
.close()
.await
.map(|_| {
.map(|meta| {
probe_lazy!(opendal, writer_close_ok, c_path.as_ptr());
meta
})
.map_err(|err| {
probe_lazy!(opendal, writer_close_error, c_path.as_ptr());
Expand Down Expand Up @@ -418,8 +419,9 @@ impl<R: oio::BlockingWrite> oio::BlockingWrite for DtraceLayerWrapper<R> {
probe_lazy!(opendal, blocking_writer_close_start, c_path.as_ptr());
self.inner
.close()
.map(|_| {
.map(|meta| {
probe_lazy!(opendal, blocking_writer_close_ok, c_path.as_ptr());
meta
})
.map_err(|err| {
probe_lazy!(opendal, blocking_writer_close_error, c_path.as_ptr());
Expand Down

0 comments on commit 8337e0e

Please sign in to comment.