Ji-Xinyou commented on code in PR #1861:
URL: 
https://github.com/apache/incubator-opendal/pull/1861#discussion_r1159345051


##########
bindings/c/include/opendal.h:
##########
@@ -25,15 +25,69 @@
 #include <stddef.h>
 #include <stdbool.h>
 
+/*
+ The [`OperatorPtr`] owns a pointer to a [`BlockingOperator`].
+ It is also the key struct that OpenDAL's APIs access the real
+ operator's memory. The use of OperatorPtr is zero cost, it
+ only returns a reference of the underlying Operator.
+ */
+typedef struct opendal_operator_ptr {
+  const void *ptr;
+} opendal_operator_ptr;
+
+/*
+ The [`Vector`] type is a C-compatable substitute for [`Vec`]
+ in Rust, it will not be deallocated automatically like what
+ has been done in Rust. Instead, you have to call [`free_vec`]
+ to free the heap memory to avoid memory leak.
+ The field `data` should not be modified since it might causes
+ the reallocation of the Vector.
+ */
+typedef struct opendal_vector {
+  const uint8_t *data;
+  uintptr_t len;
+} opendal_vector;
+
 #ifdef __cplusplus
 extern "C" {
 #endif // __cplusplus
 
+/*
+ Constructs a new [`OperatorPtr`] which contains a underlying 
[`BlockingOperator`]
+ If the scheme is invalid, or the operator contructions failed, a nullptr is 
returned
+ */
+struct opendal_operator_ptr od_new_operator(const char *scheme);
+
+/*
+ Write the data into the path blockingly by operator, returns whether the 
write succeeds
+ */
+bool od_operator_blocking_write(struct opendal_operator_ptr op_ptr,
+                                const char *path,
+                                struct opendal_vector bytes);
+
+/*
+ Read the data out from path into a [`Vector`] blockingly by operator, returns
+ a pointer to the vector if succeeds, nullptr otherwise
+ */
+struct opendal_vector *od_operator_blocking_read(struct opendal_operator_ptr 
op_ptr,

Review Comment:
   I have made the prefix of all `pub extern "C"` functions, i.e., user-facing 
APIs to `opendal_` instead of `od_`



##########
bindings/c/include/opendal.h:
##########
@@ -25,15 +25,69 @@
 #include <stddef.h>
 #include <stdbool.h>
 
+/*
+ The [`OperatorPtr`] owns a pointer to a [`BlockingOperator`].
+ It is also the key struct that OpenDAL's APIs access the real
+ operator's memory. The use of OperatorPtr is zero cost, it
+ only returns a reference of the underlying Operator.
+ */
+typedef struct opendal_operator_ptr {
+  const void *ptr;
+} opendal_operator_ptr;
+
+/*
+ The [`Vector`] type is a C-compatable substitute for [`Vec`]
+ in Rust, it will not be deallocated automatically like what
+ has been done in Rust. Instead, you have to call [`free_vec`]
+ to free the heap memory to avoid memory leak.
+ The field `data` should not be modified since it might causes
+ the reallocation of the Vector.
+ */
+typedef struct opendal_vector {
+  const uint8_t *data;
+  uintptr_t len;
+} opendal_vector;
+
 #ifdef __cplusplus
 extern "C" {
 #endif // __cplusplus
 
+/*
+ Constructs a new [`OperatorPtr`] which contains a underlying 
[`BlockingOperator`]
+ If the scheme is invalid, or the operator contructions failed, a nullptr is 
returned
+ */
+struct opendal_operator_ptr od_new_operator(const char *scheme);
+
+/*
+ Write the data into the path blockingly by operator, returns whether the 
write succeeds
+ */
+bool od_operator_blocking_write(struct opendal_operator_ptr op_ptr,
+                                const char *path,
+                                struct opendal_vector bytes);
+
+/*
+ Read the data out from path into a [`Vector`] blockingly by operator, returns
+ a pointer to the vector if succeeds, nullptr otherwise
+ */
+struct opendal_vector *od_operator_blocking_read(struct opendal_operator_ptr 
op_ptr,
+                                                 const char *path);
+
 /*
  Hello, OpenDAL!
  */
 void hello_opendal(void);

Review Comment:
   Fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to