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/incubator-opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 755d72c77 refactor(bindings/ocaml): Refactor module to support
documentation (#2794)
755d72c77 is described below
commit 755d72c779d4aced163d33a2ac6bb51021fe2654
Author: ran <[email protected]>
AuthorDate: Mon Aug 7 18:44:26 2023 +0800
refactor(bindings/ocaml): Refactor module to support documentation (#2794)
* refactor files to support adding docs and IDE hint
* update inner lib name
* format code
* remove scheme mapping
move blocking_operator to operator
* rename src module name
* rename src module name
* rename src module name
---
bindings/ocaml/build.rs | 7 +-
bindings/ocaml/{src => lib}/dune | 16 +--
bindings/ocaml/lib/opendal.ml | 22 ++++
bindings/ocaml/lib/operator.ml | 29 +++++
bindings/ocaml/lib/operator.mli | 119 +++++++++++++++++++++
bindings/ocaml/src/dune | 12 +--
bindings/ocaml/src/lib.rs | 6 +-
bindings/ocaml/src/opendal.ml | 17 ---
bindings/ocaml/src/opendal.mli | 17 ---
bindings/ocaml/src/operator.ml | 17 +++
bindings/ocaml/src/operator.mli | 17 +++
.../src/{block_operator.rs => operator/mod.rs} | 56 +++++-----
bindings/ocaml/test/test.ml | 22 ++--
13 files changed, 255 insertions(+), 102 deletions(-)
diff --git a/bindings/ocaml/build.rs b/bindings/ocaml/build.rs
index fc316b6ca..9b35ddef4 100644
--- a/bindings/ocaml/build.rs
+++ b/bindings/ocaml/build.rs
@@ -15,6 +15,11 @@
// specific language governing permissions and limitations
// under the License.
+use std::path::PathBuf;
+
pub fn main() -> std::io::Result<()> {
- ocaml_build::Sigs::new("src/opendal.ml").generate()
+ let root = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
+ ocaml_build::Sigs::new("src/operator.ml")
+ .with_source_dir(root.join("src/operator"))
+ .generate()
}
diff --git a/bindings/ocaml/src/dune b/bindings/ocaml/lib/dune
similarity index 61%
copy from bindings/ocaml/src/dune
copy to bindings/ocaml/lib/dune
index f8fbe61be..0dd278a71 100644
--- a/bindings/ocaml/src/dune
+++ b/bindings/ocaml/lib/dune
@@ -15,21 +15,7 @@
; specific language governing permissions and limitations
; under the License.
-(rule
- (targets libopendal.a dllopendal.so)
- (deps
- (glob_files *.rs))
- (action
- (progn
- (run sh -c "cd %{project_root}/../.. && cargo build --release")
- (run sh -c
- "mv %{project_root}/../../../../target/release/libopendal_ocaml.so
./dllopendal.so 2> /dev/null || mv
%{project_root}/../../../../target/release/libopendal_ocaml.dylib
./dllopendal.so")
- (run mv %{project_root}/../../../../target/release/libopendal_ocaml.a
- libopendal.a))))
-
(library
(name opendal)
(public_name opendal)
- (foreign_archives opendal)
- (c_library_flags
- (-lpthread -lc -lm)))
+ (libraries opendal.opendal_core))
diff --git a/bindings/ocaml/lib/opendal.ml b/bindings/ocaml/lib/opendal.ml
new file mode 100644
index 000000000..2d549daf3
--- /dev/null
+++ b/bindings/ocaml/lib/opendal.ml
@@ -0,0 +1,22 @@
+(*
+ 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.
+*)
+
+module Operator = Operator
+
+type operator = Opendal_core.Operator.operator
diff --git a/bindings/ocaml/lib/operator.ml b/bindings/ocaml/lib/operator.ml
new file mode 100644
index 000000000..ccd6ec29d
--- /dev/null
+++ b/bindings/ocaml/lib/operator.ml
@@ -0,0 +1,29 @@
+(*
+ 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.
+*)
+
+let new_operator = Opendal_core.Operator.operator
+let is_exist = Opendal_core.Operator.blocking_is_exist
+let create_dir = Opendal_core.Operator.blocking_create_dir
+let read = Opendal_core.Operator.blocking_read
+let write = Opendal_core.Operator.blocking_write
+let copy = Opendal_core.Operator.blocking_copy
+let rename = Opendal_core.Operator.blocking_rename
+let delete = Opendal_core.Operator.blocking_delete
+let remove = Opendal_core.Operator.blocking_remove
+let remove_all = Opendal_core.Operator.blocking_remove_all
diff --git a/bindings/ocaml/lib/operator.mli b/bindings/ocaml/lib/operator.mli
new file mode 100644
index 000000000..b94434c5b
--- /dev/null
+++ b/bindings/ocaml/lib/operator.mli
@@ -0,0 +1,119 @@
+(*
+ 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.
+*)
+
+val new_operator :
+ string ->
+ (string * string) list ->
+ (Opendal_core.Operator.operator, string) result
+(** [new_operator scheme config_map] Create a new block operator from given
scheme and config_map.
+
+ @param scheme Supported services, for details, refer to
https://opendal.apache.org/docs/category/services/
+ @param config_map Configuration information required by the target service
+ @return The block operator
+*)
+
+val is_exist : Opendal_core.Operator.operator -> string -> (bool, string)
result
+(** [is_exist operator path] Check if this path exists or not.
+
+ @param operator The operator
+ @param path want to check
+ @return is exists
+*)
+
+val create_dir :
+ Opendal_core.Operator.operator -> string -> (bool, string) result
+(** [create_dir operator path] Create a dir at given path.
+
+ # Notes
+
+ To indicate that a path is a directory, it is compulsory to include
+ a trailing / in the path. Failure to do so may result in
+ `NotADirectory` error being returned by OpenDAL.
+
+ # Behavior
+
+ - Create on existing dir will succeed.
+ - Create dir is always recursive, works like `mkdir -p`
+ @param operator The operator
+ @param path want to create dir
+*)
+
+val read :
+ Opendal_core.Operator.operator -> string -> (char array, string) result
+(** [read operator path] Read the whole path into a bytes.
+
+ @param operator The operator
+ @param path want to read
+ @return data of path
+*)
+
+val write :
+ Opendal_core.Operator.operator -> string -> bytes -> (unit, string) result
+(** [write operator path data] Write bytes into given path.
+ - Write will make sure all bytes has been written, or an error will be
returned.
+ @param operator The operator
+ @param path want to write
+ @param data want to write
+*)
+
+val copy :
+ Opendal_core.Operator.operator -> string -> string -> (unit, string) result
+(** [copy operator from to] Copy a file from [from] to [to].
+ - [from] and [to] must be a file.
+ - [to] will be overwritten if it exists.
+ - If [from] and [to] are the same, nothing will happen.
+ - copy is idempotent. For same [from] and [to] input, the result will be
the same.
+ @param operator The operator
+ @param from file path
+ @param to file path
+*)
+
+val rename :
+ Opendal_core.Operator.operator -> string -> string -> (unit, string) result
+(** [rename operator from to] Rename a file from [from] to [to].
+ - [from] and [to] must be a file.
+ - [to] will be overwritten if it exists.
+ - If [from] and [to] are the same, a `IsSameFile` error will occur.
+ @param operator The operator
+ @param from file path
+ @param to file path
+*)
+
+val delete : Opendal_core.Operator.operator -> string -> (unit, string) result
+(** [delete operator path] Delete given path.
+ - Delete not existing error won't return errors.
+ @param operator The block operator
+ @param path file path
+*)
+
+val remove :
+ Opendal_core.Operator.operator -> string array -> (unit, string) result
+(** [remove operator paths] Remove path array.
+ - We don't support batch delete now, will call delete on each object in
turn
+ @param operator The block operator
+ @param paths file path array
+*)
+
+val remove_all :
+ Opendal_core.Operator.operator -> string -> (unit, string) result
+(** [remove_all operator path] Remove the path and all nested dirs and files
recursively.
+ - We don't support batch delete now, will call delete on each object in
turn
+ @param operator The block operator
+ @param path file path
+*)
diff --git a/bindings/ocaml/src/dune b/bindings/ocaml/src/dune
index f8fbe61be..68d1d85f6 100644
--- a/bindings/ocaml/src/dune
+++ b/bindings/ocaml/src/dune
@@ -16,20 +16,20 @@
; under the License.
(rule
- (targets libopendal.a dllopendal.so)
+ (targets libopendal_core.a dllopendal_core.so)
(deps
(glob_files *.rs))
(action
(progn
(run sh -c "cd %{project_root}/../.. && cargo build --release")
(run sh -c
- "mv %{project_root}/../../../../target/release/libopendal_ocaml.so
./dllopendal.so 2> /dev/null || mv
%{project_root}/../../../../target/release/libopendal_ocaml.dylib
./dllopendal.so")
+ "mv %{project_root}/../../../../target/release/libopendal_ocaml.so
./dllopendal_core.so 2> /dev/null || mv
%{project_root}/../../../../target/release/libopendal_ocaml.dylib
./dllopendal_core.so")
(run mv %{project_root}/../../../../target/release/libopendal_ocaml.a
- libopendal.a))))
+ libopendal_core.a))))
(library
- (name opendal)
- (public_name opendal)
- (foreign_archives opendal)
+ (name opendal_core)
+ (public_name opendal.opendal_core)
+ (foreign_archives opendal_core)
(c_library_flags
(-lpthread -lc -lm)))
diff --git a/bindings/ocaml/src/lib.rs b/bindings/ocaml/src/lib.rs
index 96aafe309..4a6d1533c 100644
--- a/bindings/ocaml/src/lib.rs
+++ b/bindings/ocaml/src/lib.rs
@@ -19,15 +19,15 @@ use ::opendal as od;
use std::collections::{BTreeMap, HashMap};
use std::str::FromStr;
-mod block_operator;
+mod operator;
pub fn new_operator(
scheme_str: String,
map: BTreeMap<String, String>,
) -> Result<od::Operator, od::Error> {
let hm: HashMap<String, String> = map.into_iter().collect();
- let schema: od::Scheme = od::Scheme::from_str(&scheme_str)?;
- od::Operator::via_map(schema, hm)
+ let scheme: od::Scheme = od::Scheme::from_str(&scheme_str)?;
+ od::Operator::via_map(scheme, hm)
}
pub fn map_res_error<T>(res: Result<T, od::Error>) -> Result<T, String> {
diff --git a/bindings/ocaml/src/opendal.ml b/bindings/ocaml/src/opendal.ml
deleted file mode 100644
index 9638ce794..000000000
--- a/bindings/ocaml/src/opendal.ml
+++ /dev/null
@@ -1,17 +0,0 @@
-(* Generated by ocaml-rs *)
-
-open! Bigarray
-
-(* file: block_operator.rs *)
-
-type blocking_operator
-external new_blocking_operator: string -> (string * string) list ->
(blocking_operator, string) Result.t = "new_blocking_operator"
-external blocking_is_exist: blocking_operator -> string -> (bool, string)
Result.t = "blocking_is_exist"
-external blocking_create_dir: blocking_operator -> string -> (bool, string)
Result.t = "blocking_create_dir"
-external blocking_read: blocking_operator -> string -> (char array, string)
Result.t = "blocking_read"
-external blocking_write: blocking_operator -> string -> bytes -> (unit,
string) Result.t = "blocking_write"
-external blocking_copy: blocking_operator -> string -> string -> (unit,
string) Result.t = "blocking_copy"
-external blocking_rename: blocking_operator -> string -> string -> (unit,
string) Result.t = "blocking_rename"
-external blocking_delete: blocking_operator -> string -> (unit, string)
Result.t = "blocking_delete"
-external blocking_remove: blocking_operator -> string array -> (unit, string)
Result.t = "blocking_remove"
-external blocking_remove_all: blocking_operator -> string -> (unit, string)
Result.t = "blocking_remove_all"
diff --git a/bindings/ocaml/src/opendal.mli b/bindings/ocaml/src/opendal.mli
deleted file mode 100644
index 9638ce794..000000000
--- a/bindings/ocaml/src/opendal.mli
+++ /dev/null
@@ -1,17 +0,0 @@
-(* Generated by ocaml-rs *)
-
-open! Bigarray
-
-(* file: block_operator.rs *)
-
-type blocking_operator
-external new_blocking_operator: string -> (string * string) list ->
(blocking_operator, string) Result.t = "new_blocking_operator"
-external blocking_is_exist: blocking_operator -> string -> (bool, string)
Result.t = "blocking_is_exist"
-external blocking_create_dir: blocking_operator -> string -> (bool, string)
Result.t = "blocking_create_dir"
-external blocking_read: blocking_operator -> string -> (char array, string)
Result.t = "blocking_read"
-external blocking_write: blocking_operator -> string -> bytes -> (unit,
string) Result.t = "blocking_write"
-external blocking_copy: blocking_operator -> string -> string -> (unit,
string) Result.t = "blocking_copy"
-external blocking_rename: blocking_operator -> string -> string -> (unit,
string) Result.t = "blocking_rename"
-external blocking_delete: blocking_operator -> string -> (unit, string)
Result.t = "blocking_delete"
-external blocking_remove: blocking_operator -> string array -> (unit, string)
Result.t = "blocking_remove"
-external blocking_remove_all: blocking_operator -> string -> (unit, string)
Result.t = "blocking_remove_all"
diff --git a/bindings/ocaml/src/operator.ml b/bindings/ocaml/src/operator.ml
new file mode 100644
index 000000000..daa339786
--- /dev/null
+++ b/bindings/ocaml/src/operator.ml
@@ -0,0 +1,17 @@
+(* Generated by ocaml-rs *)
+
+open! Bigarray
+
+(* file: mod.rs *)
+
+type operator
+external operator: string -> (string * string) list -> (operator, string)
Result.t = "operator"
+external blocking_is_exist: operator -> string -> (bool, string) Result.t =
"blocking_is_exist"
+external blocking_create_dir: operator -> string -> (bool, string) Result.t =
"blocking_create_dir"
+external blocking_read: operator -> string -> (char array, string) Result.t =
"blocking_read"
+external blocking_write: operator -> string -> bytes -> (unit, string)
Result.t = "blocking_write"
+external blocking_copy: operator -> string -> string -> (unit, string)
Result.t = "blocking_copy"
+external blocking_rename: operator -> string -> string -> (unit, string)
Result.t = "blocking_rename"
+external blocking_delete: operator -> string -> (unit, string) Result.t =
"blocking_delete"
+external blocking_remove: operator -> string array -> (unit, string) Result.t
= "blocking_remove"
+external blocking_remove_all: operator -> string -> (unit, string) Result.t =
"blocking_remove_all"
diff --git a/bindings/ocaml/src/operator.mli b/bindings/ocaml/src/operator.mli
new file mode 100644
index 000000000..daa339786
--- /dev/null
+++ b/bindings/ocaml/src/operator.mli
@@ -0,0 +1,17 @@
+(* Generated by ocaml-rs *)
+
+open! Bigarray
+
+(* file: mod.rs *)
+
+type operator
+external operator: string -> (string * string) list -> (operator, string)
Result.t = "operator"
+external blocking_is_exist: operator -> string -> (bool, string) Result.t =
"blocking_is_exist"
+external blocking_create_dir: operator -> string -> (bool, string) Result.t =
"blocking_create_dir"
+external blocking_read: operator -> string -> (char array, string) Result.t =
"blocking_read"
+external blocking_write: operator -> string -> bytes -> (unit, string)
Result.t = "blocking_write"
+external blocking_copy: operator -> string -> string -> (unit, string)
Result.t = "blocking_copy"
+external blocking_rename: operator -> string -> string -> (unit, string)
Result.t = "blocking_rename"
+external blocking_delete: operator -> string -> (unit, string) Result.t =
"blocking_delete"
+external blocking_remove: operator -> string array -> (unit, string) Result.t
= "blocking_remove"
+external blocking_remove_all: operator -> string -> (unit, string) Result.t =
"blocking_remove_all"
diff --git a/bindings/ocaml/src/block_operator.rs
b/bindings/ocaml/src/operator/mod.rs
similarity index 51%
rename from bindings/ocaml/src/block_operator.rs
rename to bindings/ocaml/src/operator/mod.rs
index 4ea4f7d73..5915c916b 100644
--- a/bindings/ocaml/src/block_operator.rs
+++ b/bindings/ocaml/src/operator/mod.rs
@@ -18,41 +18,41 @@
use super::*;
#[ocaml::sig]
-pub struct BlockingOperator(od::BlockingOperator);
-ocaml::custom!(BlockingOperator);
+pub struct Operator(od::BlockingOperator);
+ocaml::custom!(Operator);
#[ocaml::func]
-#[ocaml::sig("string -> (string * string) list -> (blocking_operator, string)
Result.t ")]
-pub fn new_blocking_operator(
+#[ocaml::sig("string -> (string * string) list -> (operator, string) Result.t
")]
+pub fn operator(
scheme_str: String,
map: BTreeMap<String, String>,
-) -> Result<ocaml::Pointer<BlockingOperator>, String> {
+) -> Result<ocaml::Pointer<Operator>, String> {
let op = map_res_error(new_operator(scheme_str, map))?;
- Ok(BlockingOperator(op.blocking()).into())
+ Ok(Operator(op.blocking()).into())
}
#[ocaml::func]
-#[ocaml::sig("blocking_operator -> string -> (bool, string) Result.t ")]
-pub fn blocking_is_exist(operator: &mut BlockingOperator, path: String) ->
Result<bool, String> {
+#[ocaml::sig("operator -> string -> (bool, string) Result.t ")]
+pub fn blocking_is_exist(operator: &mut Operator, path: String) ->
Result<bool, String> {
map_res_error(operator.0.is_exist(path.as_str()))
}
#[ocaml::func]
-#[ocaml::sig("blocking_operator -> string -> (bool, string) Result.t ")]
-pub fn blocking_create_dir(operator: &mut BlockingOperator, path: String) ->
Result<(), String> {
+#[ocaml::sig("operator -> string -> (bool, string) Result.t ")]
+pub fn blocking_create_dir(operator: &mut Operator, path: String) ->
Result<(), String> {
map_res_error(operator.0.create_dir(path.as_str()))
}
#[ocaml::func]
-#[ocaml::sig("blocking_operator -> string -> (char array, string) Result.t ")]
-pub fn blocking_read(operator: &mut BlockingOperator, path: String) ->
Result<Vec<u8>, String> {
+#[ocaml::sig("operator -> string -> (char array, string) Result.t ")]
+pub fn blocking_read(operator: &mut Operator, path: String) -> Result<Vec<u8>,
String> {
map_res_error(operator.0.read(path.as_str()))
}
#[ocaml::func]
-#[ocaml::sig("blocking_operator -> string -> bytes -> (unit, string) Result.t
")]
+#[ocaml::sig("operator -> string -> bytes -> (unit, string) Result.t ")]
pub fn blocking_write(
- operator: &mut BlockingOperator,
+ operator: &mut Operator,
path: String,
bs: &'static [u8],
) -> Result<(), String> {
@@ -60,39 +60,31 @@ pub fn blocking_write(
}
#[ocaml::func]
-#[ocaml::sig("blocking_operator -> string -> string -> (unit, string) Result.t
")]
-pub fn blocking_copy(
- operator: &mut BlockingOperator,
- from: String,
- to: String,
-) -> Result<(), String> {
+#[ocaml::sig("operator -> string -> string -> (unit, string) Result.t ")]
+pub fn blocking_copy(operator: &mut Operator, from: String, to: String) ->
Result<(), String> {
map_res_error(operator.0.copy(from.as_str(), to.as_str()))
}
#[ocaml::func]
-#[ocaml::sig("blocking_operator -> string -> string -> (unit, string) Result.t
")]
-pub fn blocking_rename(
- operator: &mut BlockingOperator,
- from: String,
- to: String,
-) -> Result<(), String> {
+#[ocaml::sig("operator -> string -> string -> (unit, string) Result.t ")]
+pub fn blocking_rename(operator: &mut Operator, from: String, to: String) ->
Result<(), String> {
map_res_error(operator.0.rename(from.as_str(), to.as_str()))
}
#[ocaml::func]
-#[ocaml::sig("blocking_operator -> string -> (unit, string) Result.t ")]
-pub fn blocking_delete(operator: &mut BlockingOperator, path: String) ->
Result<(), String> {
+#[ocaml::sig("operator -> string -> (unit, string) Result.t ")]
+pub fn blocking_delete(operator: &mut Operator, path: String) -> Result<(),
String> {
map_res_error(operator.0.delete(path.as_str()))
}
#[ocaml::func]
-#[ocaml::sig("blocking_operator -> string array -> (unit, string) Result.t ")]
-pub fn blocking_remove(operator: &mut BlockingOperator, path: Vec<String>) ->
Result<(), String> {
+#[ocaml::sig("operator -> string array -> (unit, string) Result.t ")]
+pub fn blocking_remove(operator: &mut Operator, path: Vec<String>) ->
Result<(), String> {
map_res_error(operator.0.remove(path))
}
#[ocaml::func]
-#[ocaml::sig("blocking_operator -> string -> (unit, string) Result.t ")]
-pub fn blocking_remove_all(operator: &mut BlockingOperator, path: String) ->
Result<(), String> {
+#[ocaml::sig("operator -> string -> (unit, string) Result.t ")]
+pub fn blocking_remove_all(operator: &mut Operator, path: String) ->
Result<(), String> {
map_res_error(operator.0.remove_all(path.as_str()))
}
diff --git a/bindings/ocaml/test/test.ml b/bindings/ocaml/test/test.ml
index e67c14e99..a92fc470b 100644
--- a/bindings/ocaml/test/test.ml
+++ b/bindings/ocaml/test/test.ml
@@ -24,38 +24,38 @@ let test_check_result = function
| Ok data -> data
| Error err -> assert_failure err
-let new_test_block_operator test_ctxt : blocking_operator =
+let new_test_block_operator test_ctxt : operator =
let cfgs = [ ("root", bracket_tmpdir test_ctxt) ] in
- test_check_result (new_blocking_operator "fs" cfgs)
+ test_check_result (Operator.new_operator "fs" cfgs)
let test_new_block_operator _ = ignore new_test_block_operator
let test_create_dir_and_remove_all test_ctxt =
let bo = new_test_block_operator test_ctxt in
- ignore (test_check_result (blocking_create_dir bo "/testdir/"));
+ ignore (test_check_result (Operator.create_dir bo "/testdir/"));
ignore
(test_check_result
- (blocking_write bo "/testdir/foo" (Bytes.of_string "bar")));
+ (Operator.write bo "/testdir/foo" (Bytes.of_string "bar")));
ignore
(test_check_result
- (blocking_write bo "/testdir/bar" (Bytes.of_string "foo")));
- ignore (test_check_result (blocking_remove_all bo "/testdir/"))
+ (Operator.write bo "/testdir/bar" (Bytes.of_string "foo")));
+ ignore (test_check_result (Operator.remove_all bo "/testdir/"))
let test_block_write_and_read test_ctxt =
let bo = new_test_block_operator test_ctxt in
ignore
(test_check_result
- (blocking_write bo "tempfile" (Bytes.of_string "helloworld")));
- let data = test_check_result (blocking_read bo "tempfile") in
+ (Operator.write bo "tempfile" (Bytes.of_string "helloworld")));
+ let data = test_check_result (Operator.read bo "tempfile") in
assert_equal "helloworld"
(data |> Array.to_seq |> Bytes.of_seq |> Bytes.to_string)
let test_copy_and_read test_ctxt =
let bo = new_test_block_operator test_ctxt in
let data = "helloworld" in
- ignore (test_check_result (blocking_write bo "foo" (Bytes.of_string data)));
- ignore (test_check_result (blocking_copy bo "foo" "bar"));
- let got_res = test_check_result (blocking_read bo "bar") in
+ ignore (test_check_result (Operator.write bo "foo" (Bytes.of_string data)));
+ ignore (test_check_result (Operator.copy bo "foo" "bar"));
+ let got_res = test_check_result (Operator.read bo "bar") in
assert_equal data (got_res |> Array.to_seq |> Bytes.of_seq |>
Bytes.to_string)
let suite =