xyjixyjixyji commented on code in PR #6024:
URL: https://github.com/apache/opendal/pull/6024#discussion_r2046190874


##########
bindings/c/include/opendal.h:
##########
@@ -863,6 +863,56 @@ struct opendal_error *opendal_operator_write(const struct 
opendal_operator *op,
 struct opendal_result_read opendal_operator_read(const struct opendal_operator 
*op,
                                                  const char *path);
 
+/**
+ * \brief Blocking read a range of data from `path`.
+ *
+ * Read a range of data from `path` blocking by operator. The range starts 
from `start`
+ * to `end`.
+ *
+ * @param op The opendal_operator created previously
+ * @param path The path you want to read the data out
+ * @param start The start position of the range to read. 0 means the start of 
the file.
+ * @param end The end position of the range to read. 0 means the end of the 
file.
+ * @see opendal_operator
+ * @see opendal_result_read
+ * @see opendal_error
+ * @return Returns opendal_result_read, the `data` field is a pointer to a 
newly allocated
+ * opendal_bytes containing the range of data, the `error` field contains the 
error. If the
+ * `error` is not NULL, then the operation failed and the `data` field 
contains empty bytes.
+ *
+ * \note If the read operation succeeds, the returned opendal_bytes is newly 
allocated on heap.
+ * After your usage of that, please call opendal_bytes_free() to free the 
space.
+ *
+ * # Example
+ *
+ * Following is an example
+ * ```C
+ * // ... you have write "Hello, World!" to path "/testpath"
+ *
+ * // Read bytes starting from 0 to 5
+ * opendal_result_read r = opendal_operator_read_range(op, "/testpath", 0, 5);
+ * assert(r.error == NULL);
+ *
+ * opendal_bytes bytes = r.data;
+ * assert(bytes.len == 5);
+ * opendal_bytes_free(&bytes);
+ * ```
+ *
+ * # Safety
+ *
+ * It is **safe** under the cases below
+ * * The memory pointed to by `path` must contain a valid nul terminator at 
the end of
+ *   the string.
+ *
+ * # Panic
+ *
+ * * If the `path` points to NULL, this function panics, i.e. exits with 
information
+ */
+struct opendal_result_read opendal_operator_read_range(const struct 
opendal_operator *op,

Review Comment:
   Yes this is also something i concern, we could have an API looks like 
`opendal_operator_read_with_opt()` if we don't want to break the current 
`opendal_operator_read()`.



-- 
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: commits-unsubscr...@opendal.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to