Ji-Xinyou commented on code in PR #1861:
URL:
https://github.com/apache/incubator-opendal/pull/1861#discussion_r1159965015
##########
bindings/c/include/opendal.h:
##########
@@ -25,14 +25,229 @@
#include <stddef.h>
#include <stdbool.h>
+/*
+ The C-compatible error type enum used in c bindings.
+ NOTICE: the type definition of [`ErrorNo`] should be aligned with
+ [`od::ErrorKind`]
+ */
+typedef enum opendal_errno {
+ /*
+ returning it back. For example, s3 returns an internal service error.
+ */
+ Unexpected,
+ /*
+ Underlying service doesn't support this operation.
+ */
+ Unsupported,
+ /*
+ The config for backend is invalid.
+ */
+ ConfigInvalid,
+ /*
+ The given path is not found.
+ */
+ NotFound,
+ /*
+ The given path doesn't have enough permission for this operation
+ */
+ PermissionDenied,
+ /*
+ The given path is a directory.
+ */
+ IsADirectory,
+ /*
+ The given path is not a directory.
+ */
+ NotADirectory,
+ /*
+ The given path already exists thus we failed to the specified operation on
it.
+ */
+ AlreadyExists,
+ /*
+ Requests that sent to this path is over the limit, please slow down.
+ */
+ RateLimited,
+ /*
+ The given file paths are same.
+ */
+ IsSameFile,
+ /*
+ Unknown error, since [`opendal::ErrorKind`] is nonexhaustive
+ */
+ UnknownError,
+ /*
+ NullPtr error, meaning that a provided pointer which need to be
dereferenced is null
+ */
+ NullPtr,
+} opendal_errno;
+
+/*
+ The C-compatible error status for opendal::Error.
+ NOTICE: the type definition of [`ErrorNo`] should be aligned with
+ [`od::ErrorStatus`]
+ */
+typedef enum opendal_error_status {
+ /*
+ Permanent means without external changes, the error never changes.
+
+ For example, underlying services returns a not found error.
+
+ Users SHOULD never retry this operation.
+ */
+ Permanent,
+ /*
+ Temporary means this error is returned for temporary.
+
+ For example, underlying services is rate limited or unavailable for
temporary.
+
+ Users CAN retry the operation to resolve it.
+ */
+ Temporary,
+ /*
+ Persistent means this error used to be temporary but still failed after
retry.
+
+ For example, underlying services kept returning network errors.
+
+ Users MAY retry this operation but it's highly possible to error again.
+ */
+ Persistent,
+} opendal_error_status;
+
+/*
+ The [`OperatorPtr`] owns a pointer to a [`od::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.
+
+ The [`OperatorPtr`] also has a transparent layout, allowing you
+ to check its validity by native boolean operator.
+ e.g. you could check by (!ptr) on a opendal_operator_ptr type
+ */
+typedef const void *opendal_operator_ptr;
+
+/*
+ The error type returned of all opendal APIs in the C code
+ */
+typedef struct opendal_error {
+ /*
+ The error number of the actual error
+ */
+ enum opendal_errno errno;
+ /*
+ The error status of the error, please see opendal_error_status
+ for more details
+ */
+ enum opendal_error_status error_status;
+ /*
+ The error_msg consumes an area of heap memory, please call
+ [`opendal_free_error`] on the error to free the memory
+ */
+ const char *error_msg;
Review Comment:
Yes, we can name fields whatever we like, I will rename these to message w/o
abbreviation and keep the naming consistent.
--
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]