Apache OpenDALâ„¢ C Binding
The C binding for Apache OpenDALâ„¢
Loading...
Searching...
No Matches
opendal.h File Reference
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

Go to the source code of this file.

Classes

struct  opendal_cancel_token
 An opaque, thread-safe token used to cancel in-flight OpenDAL operations. More...
struct  opendal_bytes
 opendal_bytes carries raw-bytes with its length More...
struct  opendal_error
 The opendal error type for C binding, containing an error code and corresponding error message. More...
struct  opendal_lister
 Lister is designed to list entries at a given path in a blocking manner. More...
struct  opendal_entry
 opendal_list_entry is the entry under a path, which is listed from the opendal_lister More...
struct  opendal_operator_layers
 The layers to apply when initializing an opendal_operator. More...
 Carries all metadata associated with a path. More...
 User metadata associated with a path. More...
 A user metadata key-value pair. More...
struct  opendal_operator
 Used to access almost all OpenDAL APIs. It represents an operator that provides the unified interfaces provided by OpenDAL. More...
struct  opendal_operator_options
 The configuration for the initialization of opendal_operator. More...
 A key-value pair for write user metadata. More...
struct  opendal_write_options
 Options for write operations. More...
struct  opendal_read_options
 Options for read operations. More...
struct  opendal_reader
 The result type returned by opendal's reader operation. More...
struct  opendal_reader_options
 Options for reader operations. More...
struct  opendal_writer
 The result type returned by opendal's writer operation. More...
struct  opendal_delete_options
 Options for delete operations. More...
struct  opendal_stat_options
 Options for stat operations. More...
struct  opendal_list_options
 Options for list operations. More...
struct  opendal_copy_options
 Options for copy operations. More...
struct  opendal_copier
 opendal_copier completes a long-running copy operation to completion in a blocking manner. opendal_copier repeatedly calls a copy operation until completion. More...
struct  opendal_deleter
 opendal_deleter removes many paths from storage. More...
struct  opendal_operator_info
 Metadata for operator, users can use this metadata to get information of operator. More...
struct  opendal_capability
 Capability is used to describe what operations are supported by current Operator. More...
struct  opendal_presigned_request
 The underlying presigned request, which contains the HTTP method, URI, and headers. This is an opaque struct, please use the accessor functions to get the fields. More...
struct  opendal_http_header_pair
 The key-value pair for the headers of the presigned request. More...

Macros

#define OPENDAL_SEEK_SET   0
#define OPENDAL_SEEK_CUR   1
#define OPENDAL_SEEK_END   2

Typedefs

typedef enum opendal_code opendal_code
 The error code for all opendal APIs in C binding.
typedef struct opendal_presigned_request_inner opendal_presigned_request_inner
typedef struct opendal_cancel_token opendal_cancel_token
 An opaque, thread-safe token used to cancel in-flight OpenDAL operations.
typedef struct opendal_bytes opendal_bytes
 opendal_bytes carries raw-bytes with its length
typedef struct opendal_error opendal_error
 The opendal error type for C binding, containing an error code and corresponding error message.
typedef struct opendal_lister opendal_lister
 Lister is designed to list entries at a given path in a blocking manner.
typedef struct opendal_entry opendal_entry
 opendal_list_entry is the entry under a path, which is listed from the opendal_lister
typedef void(* opendal_log_callback) (int32_t level, const char *file, uint32_t line, const char *message)
typedef struct opendal_operator_layers opendal_operator_layers
 The layers to apply when initializing an opendal_operator.
typedef struct opendal_metadata opendal_metadata
 Carries all metadata associated with a path.
typedef struct opendal_metadata_user_metadata opendal_metadata_user_metadata
 User metadata associated with a path.
typedef struct opendal_metadata_user_metadata_pair opendal_metadata_user_metadata_pair
 A user metadata key-value pair.
typedef struct opendal_operator opendal_operator
 Used to access almost all OpenDAL APIs. It represents an operator that provides the unified interfaces provided by OpenDAL.
typedef struct opendal_operator_options opendal_operator_options
 The configuration for the initialization of opendal_operator.
typedef struct opendal_write_user_metadata_pair opendal_write_user_metadata_pair
 A key-value pair for write user metadata.
typedef struct opendal_write_options opendal_write_options
 Options for write operations.
typedef struct opendal_read_options opendal_read_options
 Options for read operations.
typedef struct opendal_reader opendal_reader
 The result type returned by opendal's reader operation.
typedef struct opendal_reader_options opendal_reader_options
 Options for reader operations.
typedef struct opendal_writer opendal_writer
 The result type returned by opendal's writer operation.
typedef struct opendal_delete_options opendal_delete_options
 Options for delete operations.
typedef struct opendal_stat_options opendal_stat_options
 Options for stat operations.
typedef struct opendal_list_options opendal_list_options
 Options for list operations.
typedef struct opendal_copy_options opendal_copy_options
 Options for copy operations.
typedef struct opendal_copier opendal_copier
 opendal_copier completes a long-running copy operation to completion in a blocking manner. opendal_copier repeatedly calls a copy operation until completion.
typedef struct opendal_deleter opendal_deleter
 opendal_deleter removes many paths from storage.
typedef struct opendal_operator_info opendal_operator_info
 Metadata for operator, users can use this metadata to get information of operator.
typedef struct opendal_capability opendal_capability
 Capability is used to describe what operations are supported by current Operator.
typedef struct opendal_presigned_request opendal_presigned_request
 The underlying presigned request, which contains the HTTP method, URI, and headers. This is an opaque struct, please use the accessor functions to get the fields.
typedef struct opendal_http_header_pair opendal_http_header_pair
 The key-value pair for the headers of the presigned request.

Enumerations

enum  opendal_code {
  OPENDAL_UNEXPECTED , OPENDAL_UNSUPPORTED , OPENDAL_CONFIG_INVALID , OPENDAL_NOT_FOUND ,
  OPENDAL_PERMISSION_DENIED , OPENDAL_IS_A_DIRECTORY , OPENDAL_NOT_A_DIRECTORY , OPENDAL_ALREADY_EXISTS ,
  OPENDAL_RATE_LIMITED , OPENDAL_IS_SAME_FILE , OPENDAL_CONDITION_NOT_MATCH , OPENDAL_RANGE_NOT_SATISFIED ,
  OPENDAL_CONFLICT , OPENDAL_CANCELLED , OPENDAL_CHECKSUM_MISMATCH
}
 The error code for all opendal APIs in C binding. More...

Functions

uint32_t opendal_c_abi_version (void)
uintptr_t opendal_c_capability_size (void)
const char * opendal_c_version (void)
struct opendal_cancel_token * opendal_cancel_token_new (void)
 Allocate a new uncancelled opendal_cancel_token.
void opendal_cancel_token_cancel (const struct opendal_cancel_token *token)
 Signal cancellation on token.
bool opendal_cancel_token_is_cancelled (const struct opendal_cancel_token *token)
 Return whether token has been cancelled.
void opendal_cancel_token_free (struct opendal_cancel_token *token)
 Free the heap memory used by opendal_cancel_token.
void opendal_error_free (struct opendal_error *ptr)
 Frees the opendal_error, ok to call on NULL.
struct opendal_error * opendal_lister_next (struct opendal_lister *self, struct opendal_entry **entry)
 Return the next object to be listed.
struct opendal_error * opendal_lister_next_with_cancel (struct opendal_lister *self, const struct opendal_cancel_token *cancel, struct opendal_entry **entry)
 Return the next object to be listed, supporting cancellation via cancel.
void opendal_lister_free (struct opendal_lister *ptr)
 Free the heap-allocated metadata used by opendal_lister.
struct opendal_error * opendal_logging_init (opendal_log_callback callback)
 Installs one process-global native callback for the library's Rust log facade.
struct opendal_operator_layers * opendal_operator_layers_new (void)
 Construct a heap-allocated opendal_operator_layers.
void opendal_operator_layers_add_retry (struct opendal_operator_layers *layers, bool jitter, float factor, uint64_t min_delay_ns, uint64_t max_delay_ns, uint64_t max_times)
 Add a retry layer.
void opendal_operator_layers_add_timeout (struct opendal_operator_layers *layers, uint64_t timeout_ns, uint64_t io_timeout_ns)
 Add a timeout layer.
void opendal_operator_layers_free (struct opendal_operator_layers *ptr)
 Free the allocated memory used by opendal_operator_layers.
void opendal_metadata_free (struct opendal_metadata *ptr)
 Free the heap-allocated metadata used by opendal_metadata.
uint8_t opendal_metadata_mode (const struct opendal_metadata *self)
 Return this entry's mode.
uint8_t opendal_metadata_is_current (const struct opendal_metadata *self)
 Return whether this metadata describes the current object version.
bool opendal_metadata_is_deleted (const struct opendal_metadata *self)
 Return whether this metadata describes a deleted object or delete marker.
char * opendal_metadata_cache_control (const struct opendal_metadata *self)
 Return this entry's Cache-Control value.
uint64_t opendal_metadata_content_length (const struct opendal_metadata *self)
 Return the full content length of this entry.
char * opendal_metadata_content_md5 (const struct opendal_metadata *self)
 Return this entry's Content-MD5 value.
char * opendal_metadata_content_type (const struct opendal_metadata *self)
 Return this entry's Content-Type value.
char * opendal_metadata_content_encoding (const struct opendal_metadata *self)
 Return this entry's Content-Encoding value.
char * opendal_metadata_content_language (const struct opendal_metadata *self)
 Return this entry's Content-Language value, if available.
int64_t opendal_metadata_last_modified_ms (const struct opendal_metadata *self)
 Return this entry's Last-Modified timestamp.
char * opendal_metadata_etag (const struct opendal_metadata *self)
 Return this entry's service-provided ETag as-is.
char * opendal_metadata_content_disposition (const struct opendal_metadata *self)
 Return this entry's Content-Disposition value.
char * opendal_metadata_version (const struct opendal_metadata *self)
 Return this entry's service-specific version identifier.
struct opendal_metadata_user_metadata * opendal_metadata_get_user_metadata (const struct opendal_metadata *self)
 Return the user metadata of the metadata.
bool opendal_metadata_is_file (const struct opendal_metadata *self)
 Return whether the path represents a file.
bool opendal_metadata_is_dir (const struct opendal_metadata *self)
 Return whether the path represents a directory.
const struct opendal_metadata_user_metadata_pair * opendal_metadata_user_metadata_pairs (const struct opendal_metadata_user_metadata *metadata)
 Return the key-value pairs of the user metadata.
uintptr_t opendal_metadata_user_metadata_len (const struct opendal_metadata_user_metadata *metadata)
 Return the number of key-value pairs in the user metadata.
void opendal_metadata_user_metadata_free (struct opendal_metadata_user_metadata *metadata)
 Free the user metadata returned by opendal_metadata_user_metadata.
void opendal_operator_free (const struct opendal_operator *ptr)
 Free the heap-allocated operator pointed by opendal_operator.
struct opendal_error * opendal_operator_new (const char *scheme, const struct opendal_operator_options *options, struct opendal_operator **op)
 Construct an operator based on scheme and options.
struct opendal_error * opendal_operator_new_with_layers (const char *scheme, const struct opendal_operator_options *options, const struct opendal_operator_layers *layers, struct opendal_operator **op)
 Construct an operator based on scheme, options, and explicit layers.
struct opendal_error * opendal_operator_write (const struct opendal_operator *op, const char *path, const struct opendal_bytes *bytes)
 Blocking write raw bytes to path.
struct opendal_error * opendal_operator_write_with (const struct opendal_operator *op, const char *path, const struct opendal_bytes *bytes, const struct opendal_write_options *opts)
 Blocking write raw bytes to path with options.
struct opendal_error * opendal_operator_write_with_metadata (const struct opendal_operator *op, const char *path, const struct opendal_bytes *bytes, const struct opendal_write_options *opts, struct opendal_metadata **meta)
 Blocking write raw bytes to path, returning the written object's metadata.
struct opendal_error * opendal_operator_write_with_cancel (const struct opendal_operator *op, const char *path, const struct opendal_bytes *bytes, const struct opendal_write_options *opts, const struct opendal_cancel_token *cancel, struct opendal_metadata **meta)
 Blocking write raw bytes to path with options, optional cancellation, and optional metadata output.
struct opendal_error * opendal_operator_read (const struct opendal_operator *op, const char *path, struct opendal_bytes *bytes)
 Blocking read the data from path.
struct opendal_error * opendal_operator_read_with (const struct opendal_operator *op, const char *path, const struct opendal_read_options *opts, struct opendal_bytes *bytes)
 Blocking read the data from path with options.
struct opendal_error * opendal_operator_read_with_cancel (const struct opendal_operator *op, const char *path, const struct opendal_read_options *opts, const struct opendal_cancel_token *cancel, struct opendal_bytes *bytes)
 Blocking read the data from path with options and optional cancellation.
struct opendal_error * opendal_operator_reader (const struct opendal_operator *op, const char *path, struct opendal_reader **reader)
 Blocking create a reader for the specified path.
struct opendal_error * opendal_operator_reader_with (const struct opendal_operator *op, const char *path, const struct opendal_reader_options *opts, struct opendal_reader **reader)
 Blocking create a reader for the specified path with options.
struct opendal_error * opendal_operator_reader_with_cancel (const struct opendal_operator *op, const char *path, const struct opendal_reader_options *opts, const struct opendal_cancel_token *cancel, struct opendal_reader **reader)
 Blocking create a reader for the specified path with options and optional cancellation.
struct opendal_error * opendal_operator_writer (const struct opendal_operator *op, const char *path, struct opendal_writer **writer)
 Blocking create a writer for the specified path.
struct opendal_error * opendal_operator_writer_with (const struct opendal_operator *op, const char *path, const struct opendal_write_options *opts, struct opendal_writer **writer)
 Blocking create a writer for the specified path with options.
struct opendal_error * opendal_operator_writer_with_cancel (const struct opendal_operator *op, const char *path, const struct opendal_write_options *opts, const struct opendal_cancel_token *cancel, struct opendal_writer **writer)
 Blocking create a writer for the specified path with options and optional cancellation.
struct opendal_error * opendal_operator_delete (const struct opendal_operator *op, const char *path)
 Blocking delete the object in path.
struct opendal_error * opendal_operator_delete_with (const struct opendal_operator *op, const char *path, const struct opendal_delete_options *opts)
 Blocking delete the object in path with options.
struct opendal_error * opendal_operator_delete_with_cancel (const struct opendal_operator *op, const char *path, const struct opendal_delete_options *opts, const struct opendal_cancel_token *cancel)
 Blocking delete the object in path with options and optional cancellation.
struct opendal_error * opendal_operator_is_exist (const struct opendal_operator *op, const char *path, bool *is_exist)
 Check whether the path exists.
struct opendal_error * opendal_operator_exists (const struct opendal_operator *op, const char *path, bool *exists)
 Check whether the path exists.
struct opendal_error * opendal_operator_exists_with_cancel (const struct opendal_operator *op, const char *path, const struct opendal_cancel_token *cancel, bool *exists)
 Check whether the path exists, supporting optional cancellation via cancel.
struct opendal_error * opendal_operator_stat (const struct opendal_operator *op, const char *path, struct opendal_metadata **meta)
 Stat the path, return its metadata.
struct opendal_error * opendal_operator_stat_with (const struct opendal_operator *op, const char *path, const struct opendal_stat_options *opts, struct opendal_metadata **meta)
 Blocking stat the object in path with options.
struct opendal_error * opendal_operator_stat_with_cancel (const struct opendal_operator *op, const char *path, const struct opendal_stat_options *opts, const struct opendal_cancel_token *cancel, struct opendal_metadata **meta)
 Blocking stat the object in path with options and optional cancellation.
struct opendal_error * opendal_operator_list (const struct opendal_operator *op, const char *path, struct opendal_lister **lister)
 Blocking list the objects in path.
struct opendal_error * opendal_operator_list_with (const struct opendal_operator *op, const char *path, const struct opendal_list_options *opts, struct opendal_lister **lister)
 Blocking list the objects in path with options.
struct opendal_error * opendal_operator_list_with_cancel (const struct opendal_operator *op, const char *path, const struct opendal_list_options *opts, const struct opendal_cancel_token *cancel, struct opendal_lister **lister)
 Blocking list the objects in path with options and optional cancellation.
struct opendal_error * opendal_operator_create_dir (const struct opendal_operator *op, const char *path)
 Blocking create the directory in path.
struct opendal_error * opendal_operator_create_dir_with_cancel (const struct opendal_operator *op, const char *path, const struct opendal_cancel_token *cancel)
 Blocking create the directory in path with optional cancellation.
struct opendal_error * opendal_operator_rename (const struct opendal_operator *op, const char *src, const char *dest)
 Blocking rename the object in path.
struct opendal_error * opendal_operator_rename_with_cancel (const struct opendal_operator *op, const char *src, const char *dest, const struct opendal_cancel_token *cancel)
 Blocking rename the object from src to dest with optional cancellation.
struct opendal_error * opendal_operator_copy (const struct opendal_operator *op, const char *src, const char *dest)
 Blocking copy the object in path.
struct opendal_error * opendal_operator_copy_with (const struct opendal_operator *op, const char *src, const char *dest, const struct opendal_copy_options *opts)
 Blocking copy the object in path with options.
struct opendal_error * opendal_operator_copy_with_cancel (const struct opendal_operator *op, const char *src, const char *dest, const struct opendal_copy_options *opts, const struct opendal_cancel_token *cancel)
 Blocking copy the object from src to dest with options and optional cancellation.
struct opendal_error * opendal_operator_check (const struct opendal_operator *op)
 Check whether the operator works properly.
struct opendal_error * opendal_operator_check_with_cancel (const struct opendal_operator *op, const struct opendal_cancel_token *cancel)
 Check whether the operator works properly, supporting optional cancellation.
struct opendal_error * opendal_operator_copier (const struct opendal_operator *op, const char *src, const char *dest, struct opendal_copier **copier)
 Blocking create a copier to copy a file from src to dest.
struct opendal_error * opendal_operator_copier_with (const struct opendal_operator *op, const char *src, const char *dest, const struct opendal_copy_options *opts, struct opendal_copier **copier)
 Blocking create a copier to copy a file from src to dest with options.
struct opendal_error * opendal_operator_copier_with_cancel (const struct opendal_operator *op, const char *src, const char *dest, const struct opendal_copy_options *opts, const struct opendal_cancel_token *cancel, struct opendal_copier **copier)
 Blocking create a copier to copy a file from src to dest with options and optional cancellation.
struct opendal_error * opendal_operator_deleter (const struct opendal_operator *op, struct opendal_deleter **deleter_out)
 Create a blocking deleter to remove multiple paths.
struct opendal_error * opendal_operator_deleter_with_cancel (const struct opendal_operator *op, const struct opendal_cancel_token *cancel, struct opendal_deleter **deleter_out)
 Create a blocking deleter to remove multiple paths, supporting optional cancellation.
struct opendal_operator_info * opendal_operator_info_new (const struct opendal_operator *op)
 Get information of underlying accessor.
void opendal_operator_info_free (struct opendal_operator_info *ptr)
 Free the heap-allocated opendal_operator_info.
char * opendal_operator_info_get_scheme (const struct opendal_operator_info *self)
 Return the nul-terminated operator's scheme, i.e. service.
char * opendal_operator_info_get_root (const struct opendal_operator_info *self)
 Return the nul-terminated operator's working root path.
char * opendal_operator_info_get_name (const struct opendal_operator_info *self)
 Return the nul-terminated operator backend's name, could be empty if underlying backend has no namespace concept.
void opendal_operator_info_get_capability (const struct opendal_operator_info *self, struct opendal_capability *cap)
 Write the operator's capability into cap.
struct opendal_error * opendal_operator_presign_read (const struct opendal_operator *op, const char *path, uint64_t expire_secs, struct opendal_presigned_request **req)
 Presign a read operation.
struct opendal_error * opendal_operator_presign_read_with (const struct opendal_operator *op, const char *path, uint64_t expire_secs, const struct opendal_read_options *opts, struct opendal_presigned_request **req)
 Presign a read operation with options.
struct opendal_error * opendal_operator_presign_read_with_cancel (const struct opendal_operator *op, const char *path, uint64_t expire_secs, const struct opendal_read_options *opts, const struct opendal_cancel_token *cancel, struct opendal_presigned_request **req)
 Presign a read operation with options and optional cancellation.
struct opendal_error * opendal_operator_presign_write (const struct opendal_operator *op, const char *path, uint64_t expire_secs, struct opendal_presigned_request **req)
 Presign a write operation.
struct opendal_error * opendal_operator_presign_write_with (const struct opendal_operator *op, const char *path, uint64_t expire_secs, const struct opendal_write_options *opts, struct opendal_presigned_request **req)
 Presign a write operation with options.
struct opendal_error * opendal_operator_presign_write_with_cancel (const struct opendal_operator *op, const char *path, uint64_t expire_secs, const struct opendal_write_options *opts, const struct opendal_cancel_token *cancel, struct opendal_presigned_request **req)
 Presign a write operation with options and optional cancellation.
struct opendal_error * opendal_operator_presign_delete (const struct opendal_operator *op, const char *path, uint64_t expire_secs, struct opendal_presigned_request **req)
 Presign a delete operation.
struct opendal_error * opendal_operator_presign_delete_with (const struct opendal_operator *op, const char *path, uint64_t expire_secs, const struct opendal_delete_options *opts, struct opendal_presigned_request **req)
 Presign a delete operation with options.
struct opendal_error * opendal_operator_presign_delete_with_cancel (const struct opendal_operator *op, const char *path, uint64_t expire_secs, const struct opendal_delete_options *opts, const struct opendal_cancel_token *cancel, struct opendal_presigned_request **req)
 Presign a delete operation with options and optional cancellation.
struct opendal_error * opendal_operator_presign_stat (const struct opendal_operator *op, const char *path, uint64_t expire_secs, struct opendal_presigned_request **req)
 Presign a stat operation.
struct opendal_error * opendal_operator_presign_stat_with (const struct opendal_operator *op, const char *path, uint64_t expire_secs, const struct opendal_stat_options *opts, struct opendal_presigned_request **req)
 Presign a stat operation with options.
struct opendal_error * opendal_operator_presign_stat_with_cancel (const struct opendal_operator *op, const char *path, uint64_t expire_secs, const struct opendal_stat_options *opts, const struct opendal_cancel_token *cancel, struct opendal_presigned_request **req)
 Presign a stat operation with options and optional cancellation.
const char * opendal_presigned_request_method (const struct opendal_presigned_request *req)
const char * opendal_presigned_request_uri (const struct opendal_presigned_request *req)
const struct opendal_http_header_pair * opendal_presigned_request_headers (const struct opendal_presigned_request *req)
uintptr_t opendal_presigned_request_headers_len (const struct opendal_presigned_request *req)
void opendal_presigned_request_free (struct opendal_presigned_request *req)
 Free the presigned request.
void opendal_string_free (char *ptr)
 Frees a heap-allocated string returned by OpenDAL C APIs.
void opendal_bytes_free (struct opendal_bytes *ptr)
 Frees the heap memory used by the opendal_bytes.
struct opendal_list_options * opendal_list_options_new (void)
 Construct a heap-allocated opendal_list_options with default values.
void opendal_list_options_set_recursive (struct opendal_list_options *opts, bool recursive)
 Set recursive.
void opendal_list_options_set_limit (struct opendal_list_options *opts, uintptr_t limit)
 Set limit.
void opendal_list_options_set_start_after (struct opendal_list_options *opts, const char *start_after)
 Set start_after.
void opendal_list_options_set_versions (struct opendal_list_options *opts, bool versions)
 Set versions.
void opendal_list_options_set_deleted (struct opendal_list_options *opts, bool deleted)
 Set deleted.
void opendal_list_options_free (struct opendal_list_options *opts)
 Free the heap memory used by opendal_list_options.
struct opendal_stat_options * opendal_stat_options_new (void)
 Construct a heap-allocated opendal_stat_options with default values.
void opendal_stat_options_set_version (struct opendal_stat_options *opts, const char *version)
 Set version.
void opendal_stat_options_set_if_match (struct opendal_stat_options *opts, const char *if_match)
 Set if_match.
void opendal_stat_options_set_if_none_match (struct opendal_stat_options *opts, const char *if_none_match)
 Set if_none_match.
void opendal_stat_options_set_if_modified_since (struct opendal_stat_options *opts, int64_t if_modified_since)
 Set if_modified_since.
void opendal_stat_options_set_if_unmodified_since (struct opendal_stat_options *opts, int64_t if_unmodified_since)
 Set if_unmodified_since.
void opendal_stat_options_set_override_content_type (struct opendal_stat_options *opts, const char *override_content_type)
 Set override_content_type.
void opendal_stat_options_set_override_cache_control (struct opendal_stat_options *opts, const char *override_cache_control)
 Set override_cache_control.
void opendal_stat_options_set_override_content_disposition (struct opendal_stat_options *opts, const char *override_content_disposition)
 Set override_content_disposition.
void opendal_stat_options_free (struct opendal_stat_options *opts)
 Free the heap memory used by opendal_stat_options.
struct opendal_delete_options * opendal_delete_options_new (void)
 Construct a heap-allocated opendal_delete_options with default values.
void opendal_delete_options_set_version (struct opendal_delete_options *opts, const char *version)
 Set version.
void opendal_delete_options_set_recursive (struct opendal_delete_options *opts, bool recursive)
 Set recursive.
void opendal_delete_options_free (struct opendal_delete_options *opts)
 Free the heap memory used by opendal_delete_options.
struct opendal_read_options * opendal_read_options_new (void)
 Construct a heap-allocated opendal_read_options with default values.
void opendal_read_options_set_range (struct opendal_read_options *opts, uint64_t offset, uint64_t length)
 Set the range to length bytes from offset.
void opendal_read_options_set_range_from (struct opendal_read_options *opts, uint64_t offset)
 Set the range to start at offset and continue to the end of the file.
void opendal_read_options_set_version (struct opendal_read_options *opts, const char *version)
 Set version.
void opendal_read_options_set_if_match (struct opendal_read_options *opts, const char *if_match)
 Set if_match.
void opendal_read_options_set_if_none_match (struct opendal_read_options *opts, const char *if_none_match)
 Set if_none_match.
void opendal_read_options_set_if_modified_since (struct opendal_read_options *opts, int64_t if_modified_since)
 Set if_modified_since.
void opendal_read_options_set_if_unmodified_since (struct opendal_read_options *opts, int64_t if_unmodified_since)
 Set if_unmodified_since.
void opendal_read_options_set_concurrent (struct opendal_read_options *opts, uintptr_t concurrent)
 Set concurrent.
void opendal_read_options_set_chunk (struct opendal_read_options *opts, uintptr_t chunk)
 Set chunk.
void opendal_read_options_set_gap (struct opendal_read_options *opts, uintptr_t gap)
 Set gap.
void opendal_read_options_set_content_length_hint (struct opendal_read_options *opts, uint64_t content_length_hint)
 Set content_length_hint.
void opendal_read_options_set_override_content_type (struct opendal_read_options *opts, const char *override_content_type)
 Set override_content_type.
void opendal_read_options_set_override_cache_control (struct opendal_read_options *opts, const char *override_cache_control)
 Set override_cache_control.
void opendal_read_options_set_override_content_disposition (struct opendal_read_options *opts, const char *override_content_disposition)
 Set override_content_disposition.
void opendal_read_options_free (struct opendal_read_options *opts)
 Free the heap memory used by opendal_read_options.
struct opendal_reader_options * opendal_reader_options_new (void)
 Construct a heap-allocated opendal_reader_options with default values.
void opendal_reader_options_set_version (struct opendal_reader_options *opts, const char *version)
 Set version.
void opendal_reader_options_set_if_match (struct opendal_reader_options *opts, const char *if_match)
 Set if_match.
void opendal_reader_options_set_if_none_match (struct opendal_reader_options *opts, const char *if_none_match)
 Set if_none_match.
void opendal_reader_options_set_if_modified_since (struct opendal_reader_options *opts, int64_t if_modified_since)
 Set if_modified_since.
void opendal_reader_options_set_if_unmodified_since (struct opendal_reader_options *opts, int64_t if_unmodified_since)
 Set if_unmodified_since.
void opendal_reader_options_set_content_length_hint (struct opendal_reader_options *opts, uint64_t content_length_hint)
 Set content_length_hint.
void opendal_reader_options_set_concurrent (struct opendal_reader_options *opts, uintptr_t concurrent)
 Set concurrent.
void opendal_reader_options_set_chunk (struct opendal_reader_options *opts, uintptr_t chunk)
 Set chunk.
void opendal_reader_options_set_gap (struct opendal_reader_options *opts, uintptr_t gap)
 Set gap.
void opendal_reader_options_set_prefetch (struct opendal_reader_options *opts, uintptr_t prefetch)
 Set prefetch.
void opendal_reader_options_free (struct opendal_reader_options *opts)
 Free the heap memory used by opendal_reader_options.
struct opendal_write_options * opendal_write_options_new (void)
 Construct a heap-allocated opendal_write_options with default values.
void opendal_write_options_set_append (struct opendal_write_options *opts, bool append)
 Set append.
void opendal_write_options_set_cache_control (struct opendal_write_options *opts, const char *cache_control)
 Set cache_control.
void opendal_write_options_set_content_type (struct opendal_write_options *opts, const char *content_type)
 Set content_type.
void opendal_write_options_set_content_disposition (struct opendal_write_options *opts, const char *content_disposition)
 Set content_disposition.
void opendal_write_options_set_content_encoding (struct opendal_write_options *opts, const char *content_encoding)
 Set content_encoding.
void opendal_write_options_set_if_match (struct opendal_write_options *opts, const char *if_match)
 Set if_match.
void opendal_write_options_set_if_none_match (struct opendal_write_options *opts, const char *if_none_match)
 Set if_none_match.
void opendal_write_options_set_if_not_exists (struct opendal_write_options *opts, bool if_not_exists)
 Set if_not_exists.
void opendal_write_options_set_concurrent (struct opendal_write_options *opts, uintptr_t concurrent)
 Set concurrent.
void opendal_write_options_set_chunk (struct opendal_write_options *opts, uintptr_t chunk)
 Set chunk.
void opendal_write_options_set_user_metadata (struct opendal_write_options *opts, const struct opendal_write_user_metadata_pair *pairs, uintptr_t len)
 Set user_metadata.
void opendal_write_options_free (struct opendal_write_options *opts)
 Free the heap memory used by opendal_write_options.
struct opendal_copy_options * opendal_copy_options_new (void)
 Construct a heap-allocated opendal_copy_options with default values.
void opendal_copy_options_set_if_not_exists (struct opendal_copy_options *opts, bool if_not_exists)
 Set if_not_exists.
void opendal_copy_options_set_if_match (struct opendal_copy_options *opts, const char *if_match)
 Set if_match.
void opendal_copy_options_set_source_version (struct opendal_copy_options *opts, const char *source_version)
 Set source_version.
void opendal_copy_options_set_source_content_length_hint (struct opendal_copy_options *opts, uint64_t source_content_length_hint)
 Set source_content_length_hint.
void opendal_copy_options_set_concurrent (struct opendal_copy_options *opts, uintptr_t concurrent)
 Set concurrent.
void opendal_copy_options_set_chunk (struct opendal_copy_options *opts, uintptr_t chunk)
 Set chunk.
void opendal_copy_options_free (struct opendal_copy_options *opts)
 Free the heap memory used by opendal_copy_options.
struct opendal_operator_options * opendal_operator_options_new (void)
 Construct a heap-allocated opendal_operator_options.
void opendal_operator_options_set (struct opendal_operator_options *opts, const char *key, const char *value)
 Set a Key-Value pair inside opendal_operator_options.
void opendal_operator_options_free (struct opendal_operator_options *ptr)
 Free the allocated memory used by [opendal_operator_options].
char * opendal_entry_path (const struct opendal_entry *self)
 Path of entry.
char * opendal_entry_name (const struct opendal_entry *self)
 Name of entry.
struct opendal_metadata * opendal_entry_metadata (const struct opendal_entry *self)
 Return the metadata associated with this entry.
void opendal_entry_free (struct opendal_entry *ptr)
 Frees the heap memory used by the opendal_list_entry.
struct opendal_error * opendal_reader_read (struct opendal_reader *self, uint8_t *buf, uintptr_t len, uintptr_t *size)
 Read data from the reader into buf and write the number of bytes read to *size.
struct opendal_error * opendal_reader_read_with_cancel (struct opendal_reader *self, uint8_t *buf, uintptr_t len, const struct opendal_cancel_token *cancel, uintptr_t *size)
 Read data from the reader into buf, supporting cancellation via cancel.
struct opendal_error * opendal_reader_seek (struct opendal_reader *self, int64_t offset, int32_t whence, uint64_t *pos)
 Seek to an offset, in bytes, in a stream, and write the new position to *pos.
struct opendal_error * opendal_reader_seek_with_cancel (struct opendal_reader *self, int64_t offset, int32_t whence, const struct opendal_cancel_token *cancel, uint64_t *pos)
 Seek to an offset, in bytes, in a stream, supporting cancellation via cancel.
void opendal_reader_free (struct opendal_reader *ptr)
 Frees the heap memory used by the opendal_reader.
struct opendal_error * opendal_writer_write (struct opendal_writer *self, const struct opendal_bytes *bytes, uintptr_t *size)
 Write data to the writer and write the number of bytes written to *size.
struct opendal_error * opendal_writer_write_with_cancel (struct opendal_writer *self, const struct opendal_bytes *bytes, const struct opendal_cancel_token *cancel, uintptr_t *size)
 Write data to the writer, supporting cancellation via cancel.
struct opendal_error * opendal_writer_close (struct opendal_writer *ptr)
 Close the writer and make sure all data have been stored.
struct opendal_error * opendal_writer_close_with_metadata (struct opendal_writer *ptr, struct opendal_metadata **meta)
 Close the writer and write the written object's metadata to *meta.
struct opendal_error * opendal_writer_close_with_cancel (struct opendal_writer *ptr, const struct opendal_cancel_token *cancel, struct opendal_metadata **meta)
 Close the writer, supporting cancellation via cancel and optional metadata output.
void opendal_writer_free (struct opendal_writer *ptr)
 Frees the heap memory used by the opendal_writer.
struct opendal_error * opendal_copier_next (struct opendal_copier *self, uintptr_t *size, bool *has_next)
 Perform one step of the copy operation.
struct opendal_error * opendal_copier_next_with_cancel (struct opendal_copier *self, const struct opendal_cancel_token *cancel, uintptr_t *size, bool *has_next)
 Perform one step of the copy operation, supporting cancellation via cancel.
struct opendal_error * opendal_copier_abort (struct opendal_copier *self)
 Abort the pending copy operation.
struct opendal_error * opendal_copier_abort_with_cancel (struct opendal_copier *self, const struct opendal_cancel_token *cancel)
 Abort the pending copy operation, supporting cancellation via cancel.
void opendal_copier_free (struct opendal_copier *ptr)
 Free the heap memory used by the opendal_copier.
struct opendal_error * opendal_deleter_delete (struct opendal_deleter *self, const char *path)
 Submit path for deletion.
struct opendal_error * opendal_deleter_delete_many (struct opendal_deleter *self, const char *const *paths, uintptr_t paths_len)
 Submit multiple paths for deletion in one call.
struct opendal_error * opendal_deleter_delete_many_with_cancel (struct opendal_deleter *self, const char *const *paths, uintptr_t paths_len, const struct opendal_cancel_token *cancel)
 Submit multiple paths for deletion in one call, supporting cancellation via cancel.
struct opendal_error * opendal_deleter_delete_with (struct opendal_deleter *self, const char *path, const struct opendal_delete_options *opts)
 Submit path for deletion with per-path options.
struct opendal_error * opendal_deleter_delete_with_cancel (struct opendal_deleter *self, const char *path, const struct opendal_delete_options *opts, const struct opendal_cancel_token *cancel)
 Submit path for deletion with per-path options, supporting cancellation via cancel.
struct opendal_error * opendal_deleter_flush (struct opendal_deleter *self)
 Complete pending deletions and keep the deleter usable.
struct opendal_error * opendal_deleter_flush_with_cancel (struct opendal_deleter *self, const struct opendal_cancel_token *cancel)
 Complete pending deletions and keep the deleter usable, supporting cancellation via cancel.
void opendal_deleter_free (struct opendal_deleter *ptr)
 Free the heap memory used by the opendal_deleter.

Macro Definition Documentation

◆ OPENDAL_SEEK_CUR

#define OPENDAL_SEEK_CUR   1

Seek relative to the current stream position.

◆ OPENDAL_SEEK_END

#define OPENDAL_SEEK_END   2

Seek relative to the end of the stream.

◆ OPENDAL_SEEK_SET

#define OPENDAL_SEEK_SET   0

Seek from the start of the stream.

Typedef Documentation

◆ opendal_bytes

typedef struct opendal_bytes opendal_bytes

opendal_bytes carries raw-bytes with its length

The opendal_bytes type is a C-compatible substitute for Vec type in Rust. For buffers returned by OpenDAL C APIs, call opendal_bytes_free() to free the heap memory and avoid memory leaks. If you reuse an opendal_bytes output variable across multiple read calls, call opendal_bytes_free() on the previous result before passing it again as an output parameter. For caller-owned input buffers passed to OpenDAL C APIs, the caller keeps ownership and must not call opendal_bytes_free() on them.

See also
opendal_bytes_free

◆ opendal_cancel_token

typedef struct opendal_cancel_token opendal_cancel_token

An opaque, thread-safe token used to cancel in-flight OpenDAL operations.

Pass a token created with opendal_cancel_token_new() to any *_with_cancel function. Calling opendal_cancel_token_cancel() from another thread wakes waiting operations and causes them to drop their in-flight work and return OPENDAL_CANCELLED.

A single token may be shared across multiple concurrent operations, and cancelling it is idempotent. Free the token with opendal_cancel_token_free() only after all operations using it have returned.

See also
opendal_cancel_token_new()
opendal_cancel_token_cancel()
opendal_cancel_token_is_cancelled()
opendal_cancel_token_free()

◆ opendal_capability

typedef struct opendal_capability opendal_capability

Capability is used to describe what operations are supported by current Operator.

Size limit fields are zero when the operator does not define a limit.

These flags describe the underlying OpenDAL operator. A flag can be true even when the C binding does not expose the matching function (for example, restore).

◆ opendal_code

typedef enum opendal_code opendal_code

The error code for all opendal APIs in C binding.

Todo
The error handling is not complete, the error with error message will be added in the future.

◆ opendal_copier

typedef struct opendal_copier opendal_copier

opendal_copier completes a long-running copy operation to completion in a blocking manner. opendal_copier repeatedly calls a copy operation until completion.

Internally, each copy step performs a unit of work and reports progress. When copy completes, has_next returns false.

A "step" is one backend-defined unit of work. For backends that copy in multiple requests (e.g. multipart copy), one step typically copies one chunk; for backends that only support single-request copy, the entire copy happens in a single step. The reported byte count is best-effort: a step may report 0 bytes when the backend advances its state without a reliable byte delta.

Users can construct a copier by opendal_operator_copier, opendal_operator_copier_with, or opendal_operator_copier_with_cancel.

See also
opendal_operator_copier()
opendal_copier_next()

◆ opendal_copy_options

typedef struct opendal_copy_options opendal_copy_options

Options for copy operations.

Each condition checks the destination file, never the source, and every condition must hold for the copy to proceed:

  • A false condition fails the copy with OPENDAL_CONDITION_NOT_MATCH.
  • A condition the service does not advertise through its capability fails the copy with OPENDAL_UNSUPPORTED; OpenDAL never silently drops a condition.
  • A missing source fails the copy with OPENDAL_NOT_FOUND; when a condition error applies at the same time, which error the copy returns is unspecified.
  • A service-side conflict unrelated to these conditions surfaces as OPENDAL_CONFLICT.

See the conditional operation specification for the complete cross-operation contract.

Use opendal_copy_options_new() to construct and opendal_copy_options_free() to free.

A caller that declares the struct itself must initialize every member, for example with opendal_copy_options opts = {0};, because a function that takes these options reads every member, also one whose has_* member is false.

See also
opendal_operator_copy_with
opendal_copy_options_new
opendal_copy_options_free
opendal_copy_options_set_if_not_exists
opendal_copy_options_set_if_match
opendal_copy_options_set_source_version
opendal_copy_options_set_source_content_length_hint
opendal_copy_options_set_concurrent
opendal_copy_options_set_chunk

◆ opendal_delete_options

typedef struct opendal_delete_options opendal_delete_options

Options for delete operations.

C exposes only version and recursive, and neither is a condition, so the conditions below cannot be used from C yet. Selecting a version with version fails with OPENDAL_UNSUPPORTED when opendal_capability.delete_with_version is false, even if the path is missing.

Each condition checks the file currently stored at the delete path, and every condition must hold for the delete to proceed:

With valid, supported options, deleting a missing file remains a successful no-op once every condition holds.

See the conditional operation specification for the complete cross-operation contract.

Use opendal_delete_options_new() to construct and opendal_delete_options_free() to free.

A caller that declares the struct itself must initialize every member, for example with opendal_delete_options opts = {0};, because a function that takes these options reads every member.

See also
opendal_operator_delete_with
opendal_delete_options_new
opendal_delete_options_free
opendal_delete_options_set_version
opendal_delete_options_set_recursive

◆ opendal_deleter

typedef struct opendal_deleter opendal_deleter

opendal_deleter removes many paths from storage.

Uses batch deletion when the service supports it. Submitting paths can delete them immediately or trigger a batch. Call opendal_deleter_flush to wait for any pending deletions to complete.

The handle stays usable after a flush. On a batch flush failure, pending paths remain queued for another flush.

Construct a deleter with opendal_operator_deleter and release it with opendal_deleter_free. Calls using the same handle must not overlap.

See also
opendal_operator_deleter()
opendal_deleter_delete()
opendal_deleter_delete_many()
opendal_deleter_delete_with()
opendal_deleter_flush()

◆ opendal_entry

typedef struct opendal_entry opendal_entry

opendal_list_entry is the entry under a path, which is listed from the opendal_lister

For examples, please see the comment section of opendal_operator_list()

See also
opendal_operator_list()
opendal_list_entry_path()
opendal_list_entry_name()

◆ opendal_error

typedef struct opendal_error opendal_error

The opendal error type for C binding, containing an error code and corresponding error message.

The normal operations returns a pointer to the opendal_error, and the nullptr normally represents no error has taken placed. If any error has taken place, the caller should check the error code and print the error message.

The error code is represented in opendal_code, which is an enum on different type of errors. The error messages is represented in opendal_bytes, which is a non-null terminated byte array.

Note
1. The error message is on heap, so the error needs to be freed by the caller, by calling opendal_error_free. 2. The error message is not null terminated, so the caller should never use "%s" to print the error message.
See also
opendal_code
opendal_bytes
opendal_error_free

◆ opendal_http_header_pair

typedef struct opendal_http_header_pair opendal_http_header_pair

The key-value pair for the headers of the presigned request.

◆ opendal_list_options

typedef struct opendal_list_options opendal_list_options

Options for list operations.

Groups

  • Traversal: recursive.
  • Pagination: limit, start_after.
  • Versioning: versions, deleted.

The operation fails with OPENDAL_UNSUPPORTED when an option requires a capability that the operator lacks.

Use opendal_list_options_new() to construct and opendal_list_options_free() to free.

A caller that declares the struct itself must initialize every member, for example with opendal_list_options opts = {0};, because a function that takes these options reads every member.

See also
opendal_operator_list_with
opendal_list_options_new
opendal_list_options_free
opendal_list_options_set_recursive
opendal_list_options_set_limit
opendal_list_options_set_start_after
opendal_list_options_set_versions
opendal_list_options_set_deleted

◆ opendal_lister

typedef struct opendal_lister opendal_lister

Lister is designed to list entries at a given path in a blocking manner.

Users can construct a lister with opendal_operator_list, opendal_operator_list_with, or opendal_operator_list_with_cancel.

For examples, please see the comment section of opendal_operator_list()

See also
opendal_operator_list()

◆ opendal_log_callback

typedef void(* opendal_log_callback) (int32_t level, const char *file, uint32_t line, const char *message)

A native logging callback. Levels are DEBUG=0 (including TRACE), INFO=1, WARN=2, and ERROR=3; these values are not glog severity values.

File and message are non-null, NUL-terminated strings borrowed only for the callback invocation. Copy any value retained after the callback returns. Embedded NUL bytes are rendered as \0. An unavailable file is empty and an unavailable line is zero.

The callback must remain valid for the lifetime of the program, support concurrent calls, and not unwind through the C ABI. Recursive logging from the callback is not supported.

◆ opendal_metadata

typedef struct opendal_metadata opendal_metadata

Carries all metadata associated with a path.

The metadata of the "thing" under a path. Please only use the opendal_metadata with our provided API, e.g. opendal_metadata_content_length().

Note
The metadata is also heap-allocated, please call opendal_metadata_free() on this to free the heap memory.
See also
opendal_metadata_free

◆ opendal_metadata_user_metadata

typedef struct opendal_metadata_user_metadata opendal_metadata_user_metadata

User metadata associated with a path.

◆ opendal_metadata_user_metadata_pair

typedef struct opendal_metadata_user_metadata_pair opendal_metadata_user_metadata_pair

A user metadata key-value pair.

◆ opendal_operator

typedef struct opendal_operator opendal_operator

Used to access almost all OpenDAL APIs. It represents an operator that provides the unified interfaces provided by OpenDAL.

See also
opendal_operator_new This function construct the operator
opendal_operator_free This function frees the heap memory of the operator
Note
The opendal_operator owns an async opendal::Operator together with the Tokio runtime handle used to drive its operations.
Remarks
You may use the field ptr to check whether this is a NULL operator.

◆ opendal_operator_info

typedef struct opendal_operator_info opendal_operator_info

Metadata for operator, users can use this metadata to get information of operator.

◆ opendal_operator_layers

typedef struct opendal_operator_layers opendal_operator_layers

The layers to apply when initializing an opendal_operator.

Note
This is also a heap-allocated struct, please free it after you use it.

◆ opendal_operator_options

typedef struct opendal_operator_options opendal_operator_options

The configuration for the initialization of opendal_operator.

Note
This is also a heap-allocated struct, please free it after you use it
See also
opendal_operator_new has an example of using opendal_operator_options
opendal_operator_options_new This function construct the operator
opendal_operator_options_free This function frees the heap memory of the operator
opendal_operator_options_set This function allow you to set the options

◆ opendal_presigned_request

typedef struct opendal_presigned_request opendal_presigned_request

The underlying presigned request, which contains the HTTP method, URI, and headers. This is an opaque struct, please use the accessor functions to get the fields.

◆ opendal_presigned_request_inner

◆ opendal_read_options

typedef struct opendal_read_options opendal_read_options

Options for read operations.

Each condition checks the file being read, and every condition must hold for the read to proceed. Once the option and capability checks pass, a read that reaches storage fails with OPENDAL_NOT_FOUND for a missing file, no matter which conditions are set. An existing file that fails a condition returns OPENDAL_CONDITION_NOT_MATCH, and a condition the service does not advertise through its capability returns OPENDAL_UNSUPPORTED; OpenDAL never silently drops a condition. A read with an empty range, such as one that opendal_read_options_set_range(opts, offset, 0) sets, validates the read options and capabilities, then returns an empty buffer without accessing storage or evaluating conditions against the file.

See the conditional operation specification for the complete cross-operation contract.

Use opendal_read_options_new() to construct and opendal_read_options_free() to free.

A caller that declares the struct itself must initialize every member, for example with opendal_read_options opts = {0};, because a function that takes these options reads every member, also one whose has_* member is false.

See also
opendal_operator_read_with
opendal_read_options_new
opendal_read_options_free
opendal_read_options_set_range
opendal_read_options_set_range_from
opendal_read_options_set_version
opendal_read_options_set_if_match
opendal_read_options_set_if_none_match
opendal_read_options_set_if_modified_since
opendal_read_options_set_if_unmodified_since
opendal_read_options_set_concurrent
opendal_read_options_set_chunk
opendal_read_options_set_gap
opendal_read_options_set_content_length_hint
opendal_read_options_set_override_content_type
opendal_read_options_set_override_cache_control
opendal_read_options_set_override_content_disposition

◆ opendal_reader

typedef struct opendal_reader opendal_reader

The result type returned by opendal's reader operation.

Note
The opendal_reader owns an async OpenDAL reader driven on the operator's Tokio runtime handle.

◆ opendal_reader_options

typedef struct opendal_reader_options opendal_reader_options

Options for reader operations.

Each condition checks the file being read, and every condition must hold for the reader to produce data. Once the option and capability checks pass, a read that reaches storage fails with OPENDAL_NOT_FOUND for a missing file, no matter which conditions are set. An existing file that fails a condition returns OPENDAL_CONDITION_NOT_MATCH, and a condition the service does not advertise through its capability returns OPENDAL_UNSUPPORTED; OpenDAL never silently drops a condition. Without a positive chunk, or with content_length_hint set, opendal_operator_reader_with() checks the options and capabilities without accessing storage, so a missing file or a failed condition surfaces when a read from the returned reader reaches storage. With a positive chunk and no content_length_hint, it first stats the file, so either can fail opendal_operator_reader_with() instead. opendal_reader_seek() with OPENDAL_SEEK_END also stats the file unless the reader knows the file's length, from content_length_hint, the stat for chunk, an earlier successful OPENDAL_SEEK_END seek, or an earlier read on a service that reports it. Each such stat carries the reader's version and conditions, as chunk describes.

See the conditional operation specification for the complete cross-operation contract.

Use opendal_reader_options_new() to construct and opendal_reader_options_free() to free.

A caller that declares the struct itself must initialize every member, for example with opendal_reader_options opts = {0};, because a function that takes these options reads every member, also one whose has_* member is false.

See also
opendal_operator_reader_with
opendal_reader_options_new
opendal_reader_options_free
opendal_reader_options_set_version
opendal_reader_options_set_if_match
opendal_reader_options_set_if_none_match
opendal_reader_options_set_if_modified_since
opendal_reader_options_set_if_unmodified_since
opendal_reader_options_set_content_length_hint
opendal_reader_options_set_concurrent
opendal_reader_options_set_chunk
opendal_reader_options_set_gap
opendal_reader_options_set_prefetch

◆ opendal_stat_options

typedef struct opendal_stat_options opendal_stat_options

Options for stat operations.

Each condition checks the file being observed, and every condition must hold for the stat to return metadata. With valid, supported options, stat returns OPENDAL_NOT_FOUND for a missing file. An existing file that fails a condition returns OPENDAL_CONDITION_NOT_MATCH, and a condition the service does not advertise through its capability returns OPENDAL_UNSUPPORTED; OpenDAL never silently drops a condition.

See the conditional operation specification for the complete cross-operation contract.

Use opendal_stat_options_new() to construct and opendal_stat_options_free() to free.

A caller that declares the struct itself must initialize every member, for example with opendal_stat_options opts = {0};, because a function that takes these options reads every member, also one whose has_* member is false.

See also
opendal_operator_stat_with
opendal_stat_options_new
opendal_stat_options_free
opendal_stat_options_set_version
opendal_stat_options_set_if_match
opendal_stat_options_set_if_none_match
opendal_stat_options_set_if_modified_since
opendal_stat_options_set_if_unmodified_since
opendal_stat_options_set_override_content_type
opendal_stat_options_set_override_cache_control
opendal_stat_options_set_override_content_disposition

◆ opendal_write_options

typedef struct opendal_write_options opendal_write_options

Options for write operations.

Each condition checks the file currently stored at the write path, and the service evaluates it atomically with the write's visible commit:

See the conditional operation specification for the complete cross-operation contract.

Use opendal_write_options_new() to construct and opendal_write_options_free() to free.

A caller that declares the struct itself must initialize every member, for example with opendal_write_options opts = {0};, because a function that takes these options reads every member, also one whose has_* member is false.

See also
opendal_operator_write_with
opendal_write_options_new
opendal_write_options_free
opendal_write_options_set_append
opendal_write_options_set_cache_control
opendal_write_options_set_content_type
opendal_write_options_set_content_disposition
opendal_write_options_set_content_encoding
opendal_write_options_set_if_match
opendal_write_options_set_if_none_match
opendal_write_options_set_if_not_exists
opendal_write_options_set_concurrent
opendal_write_options_set_chunk
opendal_write_options_set_user_metadata

◆ opendal_write_user_metadata_pair

typedef struct opendal_write_user_metadata_pair opendal_write_user_metadata_pair

A key-value pair for write user metadata.

opendal_write_options.user_metadata points to an array of these pairs, and the operation reads the first user_metadata_len of them. A pair whose key or value is NULL is skipped.

◆ opendal_writer

typedef struct opendal_writer opendal_writer

The result type returned by opendal's writer operation.

Note
The opendal_writer owns an async opendal::Writer driven on the operator's Tokio runtime handle.

Enumeration Type Documentation

◆ opendal_code

The error code for all opendal APIs in C binding.

Todo
The error handling is not complete, the error with error message will be added in the future.
Enumerator
OPENDAL_UNEXPECTED 

returning it back. For example, s3 returns an internal service error.

OPENDAL_UNSUPPORTED 

Underlying service doesn't support this operation.

OPENDAL_CONFIG_INVALID 

The config for backend is invalid.

OPENDAL_NOT_FOUND 

The given path is not found.

OPENDAL_PERMISSION_DENIED 

The given path doesn't have enough permission for this operation

OPENDAL_IS_A_DIRECTORY 

The given path is a directory.

OPENDAL_NOT_A_DIRECTORY 

The given path is not a directory.

OPENDAL_ALREADY_EXISTS 

The given path already exists thus we failed to the specified operation on it.

OPENDAL_RATE_LIMITED 

Requests that sent to this path is over the limit, please slow down.

OPENDAL_IS_SAME_FILE 

The given file paths are same.

OPENDAL_CONDITION_NOT_MATCH 

A condition supplied through the OpenDAL operation evaluated to false.

OPENDAL_RANGE_NOT_SATISFIED 

The range of the content is not satisfied.

OPENDAL_CONFLICT 

The operation conflicts with the current or transitional state of the resource.

OPENDAL_CANCELLED 

The operation was cancelled via an opendal_cancel_token.

OPENDAL_CHECKSUM_MISMATCH 

A checksum did not match the expected value.

Function Documentation

◆ opendal_bytes_free()

void opendal_bytes_free ( struct opendal_bytes * ptr)

Frees the heap memory used by the opendal_bytes.

◆ opendal_c_abi_version()

uint32_t opendal_c_abi_version ( void )

Returns the C ABI version. This value changes on incompatible changes to the C ABI, including changes to exported struct layouts.

◆ opendal_c_capability_size()

uintptr_t opendal_c_capability_size ( void )

Returns the size in bytes of the library's opendal_capability struct.

◆ opendal_c_version()

const char * opendal_c_version ( void )

Returns the compiled OpenDAL core version as a NUL-terminated string.

The library owns the read-only string. It remains valid while the library is loaded.

◆ opendal_cancel_token_cancel()

void opendal_cancel_token_cancel ( const struct opendal_cancel_token * token)

Signal cancellation on token.

Safe to call from any thread while operations are in flight, safe to call multiple times, and a no-op when token is NULL.

◆ opendal_cancel_token_free()

void opendal_cancel_token_free ( struct opendal_cancel_token * token)

Free the heap memory used by opendal_cancel_token.

Safe to call on NULL. Must only be called after every operation that received token has returned.

◆ opendal_cancel_token_is_cancelled()

bool opendal_cancel_token_is_cancelled ( const struct opendal_cancel_token * token)

Return whether token has been cancelled.

Returns false when token is NULL.

◆ opendal_cancel_token_new()

struct opendal_cancel_token * opendal_cancel_token_new ( void )

Allocate a new uncancelled opendal_cancel_token.

Free the returned token with opendal_cancel_token_free() once no operations are using it.

◆ opendal_copier_abort()

struct opendal_error * opendal_copier_abort ( struct opendal_copier * self)

Abort the pending copy operation.

Returns NULL if the abort succeeds, otherwise it contains the error code and error message.

◆ opendal_copier_abort_with_cancel()

struct opendal_error * opendal_copier_abort_with_cancel ( struct opendal_copier * self,
const struct opendal_cancel_token * cancel )

Abort the pending copy operation, supporting cancellation via cancel.

Pass NULL for cancel to run without cancellation. If cancelled mid-flight, returns OPENDAL_CANCELLED and preserves the copier so the caller can retry the abort with a fresh cancel token (or NULL) or free it cleanly.

◆ opendal_copier_free()

void opendal_copier_free ( struct opendal_copier * ptr)

Free the heap memory used by the opendal_copier.

◆ opendal_copier_next()

struct opendal_error * opendal_copier_next ( struct opendal_copier * self,
uintptr_t * size,
bool * has_next )

Perform one step of the copy operation.

One step performs one backend-defined unit of work: typically one chunk for backends that copy in multiple requests, or the entire copy for backends that only support single-request copy.

Writes the number of bytes copied in this step to *size (best-effort; may be 0 when the backend advances without a reliable byte delta) and whether more steps remain to *has_next. When *has_next is true the caller should call this function again to continue the copy. When *has_next is false and the returned error is NULL the copy has completed. On failure, writes 0 to *size and false to *has_next, and returns an opendal_error *.

See also
opendal_operator_copier()

◆ opendal_copier_next_with_cancel()

struct opendal_error * opendal_copier_next_with_cancel ( struct opendal_copier * self,
const struct opendal_cancel_token * cancel,
uintptr_t * size,
bool * has_next )

Perform one step of the copy operation, supporting cancellation via cancel.

Pass NULL for cancel to run without cancellation. On cancellation, writes 0 to *size and false to *has_next, returns OPENDAL_CANCELLED, and preserves the copier so the caller can resume, abort, or free it cleanly.

◆ opendal_copy_options_free()

void opendal_copy_options_free ( struct opendal_copy_options * opts)

Free the heap memory used by opendal_copy_options.

Parameters
optsThe opendal_copy_options to free.

◆ opendal_copy_options_new()

struct opendal_copy_options * opendal_copy_options_new ( void )

Construct a heap-allocated opendal_copy_options with default values.

Returns
A new opendal_copy_options with all options set to their defaults.
See also
opendal_copy_options_free

◆ opendal_copy_options_set_chunk()

void opendal_copy_options_set_chunk ( struct opendal_copy_options * opts,
uintptr_t chunk )

Set chunk.

Sets chunk size for segmented copy operations.

Capability

Check opendal_capability.copy_can_multi, opendal_capability.copy_multi_min_size and opendal_capability.copy_multi_max_size before using this feature.

This is a best-effort execution option. Services that support server-side segmented copy can use it as the target size for each copy step. Services that cannot split copy operations can ignore it. 0 has the same behavior as leaving it unset.

The setter also sets has_chunk.

Parameters
optsThe opendal_copy_options to modify.
chunkThe value to set.

◆ opendal_copy_options_set_concurrent()

void opendal_copy_options_set_concurrent ( struct opendal_copy_options * opts,
uintptr_t concurrent )

Set concurrent.

Sets concurrent copy operations for opendal_operator_copy_with() and for the copier from opendal_operator_copier_with().

This is a best-effort execution option. Services that cannot split copy into concurrent server-side tasks can ignore it. 0 has the same behavior as 1.

Parameters
optsThe opendal_copy_options to modify.
concurrentThe value to set; 0 is the default.

◆ opendal_copy_options_set_if_match()

void opendal_copy_options_set_if_match ( struct opendal_copy_options * opts,
const char * if_match )

Set if_match.

Copy only when the destination file has this exact ETag.

The condition succeeds when the destination file exists and its ETag equals this value. A destination file with a different ETag, or a missing destination file, fails the copy with OPENDAL_CONDITION_NOT_MATCH. Only concrete ETag values are portable; a wildcard such as "*" has no portable meaning here.

The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.copy_with_if_match.

A non-NULL if_match must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_copy_with(), returns.

Parameters
optsThe opendal_copy_options to modify.
if_matchThe string to borrow; NULL unsets it.

◆ opendal_copy_options_set_if_not_exists()

void opendal_copy_options_set_if_not_exists ( struct opendal_copy_options * opts,
bool if_not_exists )

Set if_not_exists.

Copy only when no file exists at the destination path.

The condition succeeds when the destination path is empty, so the copy creates the destination file. An existing destination file fails the copy with OPENDAL_CONDITION_NOT_MATCH.

The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.copy_with_if_not_exists.

Parameters
optsThe opendal_copy_options to modify.
if_not_existsThe value to set.

◆ opendal_copy_options_set_source_content_length_hint()

void opendal_copy_options_set_source_content_length_hint ( struct opendal_copy_options * opts,
uint64_t source_content_length_hint )

Set source_content_length_hint.

Asserted complete content length of the source object.

OpenDAL may trust this value without reading source metadata. It can use the value to plan copied ranges. An incorrect value can therefore cause incomplete copy planning or failed requests. For example, on s3 with chunk set, OpenDAL clamps chunk to opendal_capability.copy_multi_min_size and opendal_capability.copy_multi_max_size to determine the effective part size. OpenDAL plans multipart ranges from the hint when it is at least that size. With a hint below the source length, the multipart copy can succeed with only that many bytes at the destination. A hint above the source length fails the multipart copy. With a hint below the effective part size, s3 attempts a whole-object copy in one request. The fs service ignores the hint.

This option does not pin the source object or protect the copy from a concurrent source change. Set it only when the caller can guarantee that the value describes the object that the service will copy, for example by selecting an immutable source_version. Otherwise omit it if the source can change.

The setter also sets has_source_content_length_hint.

Parameters
optsThe opendal_copy_options to modify.
source_content_length_hintThe value to set.

◆ opendal_copy_options_set_source_version()

void opendal_copy_options_set_source_version ( struct opendal_copy_options * opts,
const char * source_version )

Set source_version.

Copy from a specific source file version.

This selects which stored version of the source the copy reads; it is not a condition on the destination file. Destination behavior follows normal copy semantics.

Check opendal_capability.copy_with_source_version before using this option.

A non-NULL source_version must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_copy_with(), returns.

Parameters
optsThe opendal_copy_options to modify.
source_versionThe string to borrow; NULL unsets it.

◆ opendal_delete_options_free()

void opendal_delete_options_free ( struct opendal_delete_options * opts)

Free the heap memory used by opendal_delete_options.

Parameters
optsThe opendal_delete_options to free.

◆ opendal_delete_options_new()

struct opendal_delete_options * opendal_delete_options_new ( void )

Construct a heap-allocated opendal_delete_options with default values.

Returns
A new opendal_delete_options with all options set to their defaults.
See also
opendal_delete_options_free

◆ opendal_delete_options_set_recursive()

void opendal_delete_options_set_recursive ( struct opendal_delete_options * opts,
bool recursive )

Set recursive.

Whether to delete the target recursively.

The default, false, deletes a single object. With true, a trailing slash (for example, "a/") scopes deletion to a directory and its descendants across services. Prefix matching for paths without a trailing slash is service-specific. On prefix-based services such as memory, "a" also matches entries under "ab/".

With true, the operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.delete_with_recursive.

Parameters
optsThe opendal_delete_options to modify.
recursiveThe value to set.

◆ opendal_delete_options_set_version()

void opendal_delete_options_set_version ( struct opendal_delete_options * opts,
const char * version )

Set version.

Delete the given version of the file instead of the current one.

This selects which stored version the delete removes; it is not a condition on the file.

Check opendal_capability.delete_with_version before using this option.

Parameters
optsThe opendal_delete_options to modify.
versionThe string to copy; NULL unsets it.

◆ opendal_deleter_delete()

struct opendal_error * opendal_deleter_delete ( struct opendal_deleter * self,
const char * path )

Submit path for deletion.

Call opendal_deleter_flush to complete any pending deletions.

Parameters
pathThe path to delete
Returns
NULL on success, or an opendal_error * on failure.

Safety

  • 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

◆ opendal_deleter_delete_many()

struct opendal_error * opendal_deleter_delete_many ( struct opendal_deleter * self,
const char *const * paths,
uintptr_t paths_len )

Submit multiple paths for deletion in one call.

All paths use default options. Use opendal_deleter_delete_with for per-path options. Submission stops at the first error. Earlier paths may already have been deleted. Call opendal_deleter_flush to complete any pending deletions.

Parameters
pathsThe paths to delete
paths_lenThe number of paths in paths
Returns
NULL on success, or an opendal_error * on failure.

Safety

  • When paths_len is greater than zero, paths must point to an array of paths_len pointers.
  • Every pointer in paths must point to a string with a valid nul terminator.

Panic

  • If paths or any pointer in paths is NULL when paths_len is greater than zero, this function panics.

◆ opendal_deleter_delete_many_with_cancel()

struct opendal_error * opendal_deleter_delete_many_with_cancel ( struct opendal_deleter * self,
const char *const * paths,
uintptr_t paths_len,
const struct opendal_cancel_token * cancel )

Submit multiple paths for deletion in one call, supporting cancellation via cancel.

Pass NULL for cancel to run without cancellation.

Parameters
pathsThe paths to delete
paths_lenThe number of paths in paths
cancelOptional cancel token, or NULL
Returns
NULL on success, or an opendal_error * on cancellation or failure.

◆ opendal_deleter_delete_with()

struct opendal_error * opendal_deleter_delete_with ( struct opendal_deleter * self,
const char * path,
const struct opendal_delete_options * opts )

Submit path for deletion with per-path options.

Parameters
pathThe path to delete
optsThe options for this path, or NULL to use defaults
See also
opendal_delete_options
Returns
NULL on success, or an opendal_error * on failure.

Safety

  • The memory pointed to by path must contain a valid nul terminator at the end of the string.
  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. opendal_delete_options_set_version stores a copy of its string, which meets this.

Panic

  • If the path points to NULL, this function panics

◆ opendal_deleter_delete_with_cancel()

struct opendal_error * opendal_deleter_delete_with_cancel ( struct opendal_deleter * self,
const char * path,
const struct opendal_delete_options * opts,
const struct opendal_cancel_token * cancel )

Submit path for deletion with per-path options, supporting cancellation via cancel.

Pass NULL for opts to use defaults, and NULL for cancel to run without cancellation.

Parameters
pathThe path to delete
optsThe options for this path, or NULL to use defaults
cancelOptional cancel token, or NULL
Returns
NULL on success, or an opendal_error * on cancellation or failure.

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. opendal_delete_options_set_version stores a copy of its string, which meets this.

◆ opendal_deleter_flush()

struct opendal_error * opendal_deleter_flush ( struct opendal_deleter * self)

Complete pending deletions and keep the deleter usable.

Call this before freeing the handle to complete the deletions. If a batch flush fails, pending paths remain queued for a retry.

Returns
NULL on success, or an opendal_error * on failure.

◆ opendal_deleter_flush_with_cancel()

struct opendal_error * opendal_deleter_flush_with_cancel ( struct opendal_deleter * self,
const struct opendal_cancel_token * cancel )

Complete pending deletions and keep the deleter usable, supporting cancellation via cancel.

Pass NULL for cancel to run without cancellation.

Parameters
cancelOptional cancel token, or NULL
Returns
NULL on success, or an opendal_error * on cancellation or failure.

◆ opendal_deleter_free()

void opendal_deleter_free ( struct opendal_deleter * ptr)

Free the heap memory used by the opendal_deleter.

Freeing a deleter drops the queued paths that were never flushed: call opendal_deleter_flush first unless you mean to discard them.

◆ opendal_entry_free()

void opendal_entry_free ( struct opendal_entry * ptr)

Frees the heap memory used by the opendal_list_entry.

◆ opendal_entry_metadata()

struct opendal_metadata * opendal_entry_metadata ( const struct opendal_entry * self)

Return the metadata associated with this entry.

The returned metadata is heap-allocated and must be freed by the caller via opendal_metadata_free().

◆ opendal_entry_name()

char * opendal_entry_name ( const struct opendal_entry * self)

Name of entry.

Name is the last segment of path. If this entry is a dir, Name MUST endswith / Otherwise, Name MUST NOT endswith /.

Note
Free the returned string with opendal_string_free()

◆ opendal_entry_path()

char * opendal_entry_path ( const struct opendal_entry * self)

Path of entry.

Path is relative to operator's root. Only valid in current operator.

Note
Free the returned string with opendal_string_free()

◆ opendal_error_free()

void opendal_error_free ( struct opendal_error * ptr)

Frees the opendal_error, ok to call on NULL.

◆ opendal_list_options_free()

void opendal_list_options_free ( struct opendal_list_options * opts)

Free the heap memory used by opendal_list_options.

Parameters
optsThe opendal_list_options to free.

◆ opendal_list_options_new()

struct opendal_list_options * opendal_list_options_new ( void )

Construct a heap-allocated opendal_list_options with default values.

Returns
A new opendal_list_options with all options set to their defaults.
See also
opendal_list_options_free

◆ opendal_list_options_set_deleted()

void opendal_list_options_set_deleted ( struct opendal_list_options * opts,
bool deleted )

Set deleted.

Include delete markers; default false.

Requires opendal_capability.list_with_deleted.

Parameters
optsThe opendal_list_options to modify.
deletedThe value to set.

◆ opendal_list_options_set_limit()

void opendal_list_options_set_limit ( struct opendal_list_options * opts,
uintptr_t limit )

Set limit.

Maximum results per request (backend hint) to control memory and throttling.

Parameters
optsThe opendal_list_options to modify.
limitThe value to set; 0 unsets it.

◆ opendal_list_options_set_recursive()

void opendal_list_options_set_recursive ( struct opendal_list_options * opts,
bool recursive )

Set recursive.

Whether to list recursively under the prefix; default false.

Setting this option to true requires the operator's effective opendal_capability.list_with_recursive capability.

Parameters
optsThe opendal_list_options to modify.
recursiveThe value to set.

◆ opendal_list_options_set_start_after()

void opendal_list_options_set_start_after ( struct opendal_list_options * opts,
const char * start_after )

Set start_after.

Start listing after this key, excluding the key itself.

Setting this requires opendal_capability.list_with_start_after.

Parameters
optsThe opendal_list_options to modify.
start_afterThe string to copy; NULL unsets it.

◆ opendal_list_options_set_versions()

void opendal_list_options_set_versions ( struct opendal_list_options * opts,
bool versions )

Set versions.

Include object versions; default false.

Requires opendal_capability.list_with_versions.

Parameters
optsThe opendal_list_options to modify.
versionsThe value to set.

◆ opendal_lister_free()

void opendal_lister_free ( struct opendal_lister * ptr)

Free the heap-allocated metadata used by opendal_lister.

◆ opendal_lister_next()

struct opendal_error * opendal_lister_next ( struct opendal_lister * self,
struct opendal_entry ** entry )

Return the next object to be listed.

Lister is an iterator of the objects under its path, this method is the same as calling next() on the iterator.

On success, writes the next entry pointer (or NULL when listing is exhausted) to *entry and returns NULL. On failure, writes NULL to *entry and returns a newly allocated error that must be freed with opendal_error_free().

For examples, please see the comment section of opendal_operator_list()

See also
opendal_operator_list()

◆ opendal_lister_next_with_cancel()

struct opendal_error * opendal_lister_next_with_cancel ( struct opendal_lister * self,
const struct opendal_cancel_token * cancel,
struct opendal_entry ** entry )

Return the next object to be listed, supporting cancellation via cancel.

Pass NULL for cancel to run without cancellation. On success, writes the next entry pointer (or NULL when listing is exhausted) to *entry and returns NULL. On cancellation or failure, writes NULL to *entry and returns an opendal_error * (OPENDAL_CANCELLED on cancellation).

◆ opendal_logging_init()

struct opendal_error * opendal_logging_init ( opendal_log_callback callback)

Installs one process-global native callback for the library's Rust log facade.

The default C operator constructor adds a logging layer that emits operation events through this callback. With opendal_operator_new_with_layers, set layers=logging in the options to enable operation logging. The callback can also receive records from other Rust components using the same log facade.

Returns NULL on success. A null callback or an already installed logger returns OPENDAL_CONFIG_INVALID; free that error with opendal_error_free. A registration failure leaves the installed logger and its level unchanged. This function cannot replace or unregister a logger.

Safety

A non-null callback must satisfy the lifetime and concurrency requirements documented on opendal_log_callback.

◆ opendal_metadata_cache_control()

char * opendal_metadata_cache_control ( const struct opendal_metadata * self)

Return this entry's Cache-Control value.

Note
: The string is on heap, free it with opendal_string_free().

◆ opendal_metadata_content_disposition()

char * opendal_metadata_content_disposition ( const struct opendal_metadata * self)

Return this entry's Content-Disposition value.

Note
: The string is on heap, free it with opendal_string_free().

◆ opendal_metadata_content_encoding()

char * opendal_metadata_content_encoding ( const struct opendal_metadata * self)

Return this entry's Content-Encoding value.

Note
: The string is on heap, free it with opendal_string_free().

◆ opendal_metadata_content_language()

char * opendal_metadata_content_language ( const struct opendal_metadata * self)

Return this entry's Content-Language value, if available.

Note
: The string is on heap, free it with opendal_string_free().

◆ opendal_metadata_content_length()

uint64_t opendal_metadata_content_length ( const struct opendal_metadata * self)

Return the full content length of this entry.

◆ opendal_metadata_content_md5()

char * opendal_metadata_content_md5 ( const struct opendal_metadata * self)

Return this entry's Content-MD5 value.

Note
: The string is on heap, free it with opendal_string_free().

◆ opendal_metadata_content_type()

char * opendal_metadata_content_type ( const struct opendal_metadata * self)

Return this entry's Content-Type value.

Note
: The string is on heap, free it with opendal_string_free().

◆ opendal_metadata_etag()

char * opendal_metadata_etag ( const struct opendal_metadata * self)

Return this entry's service-provided ETag as-is.

Note
: The string is on heap, free it with opendal_string_free().

◆ opendal_metadata_free()

void opendal_metadata_free ( struct opendal_metadata * ptr)

Free the heap-allocated metadata used by opendal_metadata.

◆ opendal_metadata_get_user_metadata()

struct opendal_metadata_user_metadata * opendal_metadata_get_user_metadata ( const struct opendal_metadata * self)

Return the user metadata of the metadata.

Note
: The returned user metadata is on heap, free it with opendal_metadata_user_metadata_free().

◆ opendal_metadata_is_current()

uint8_t opendal_metadata_is_current ( const struct opendal_metadata * self)

Return whether this metadata describes the current object version.

Returns 1 for true, 0 for false, and 2 if unknown.

◆ opendal_metadata_is_deleted()

bool opendal_metadata_is_deleted ( const struct opendal_metadata * self)

Return whether this metadata describes a deleted object or delete marker.

◆ opendal_metadata_is_dir()

bool opendal_metadata_is_dir ( const struct opendal_metadata * self)

Return whether the path represents a directory.

◆ opendal_metadata_is_file()

bool opendal_metadata_is_file ( const struct opendal_metadata * self)

Return whether the path represents a file.

◆ opendal_metadata_last_modified_ms()

int64_t opendal_metadata_last_modified_ms ( const struct opendal_metadata * self)

Return this entry's Last-Modified timestamp.

Returns milliseconds since the Unix epoch, or -1 if unknown.

Example

// ... previously you wrote "Hello, World!" to path "/testpath"
opendal_metadata *meta = NULL;
opendal_error *err = opendal_operator_stat(op, "/testpath", &meta);
assert(err == NULL);
struct opendal_error * opendal_operator_stat(const struct opendal_operator *op, const char *path, struct opendal_metadata **meta)
Stat the path, return its metadata.
int64_t opendal_metadata_last_modified_ms(const struct opendal_metadata *self)
Return this entry's Last-Modified timestamp.
The opendal error type for C binding, containing an error code and corresponding error message.
Definition opendal.h:184
Carries all metadata associated with a path.
Definition opendal.h:265

◆ opendal_metadata_mode()

uint8_t opendal_metadata_mode ( const struct opendal_metadata * self)

Return this entry's mode.

Returns 0 for unknown, 1 for file, and 2 for dir.

◆ opendal_metadata_user_metadata_free()

void opendal_metadata_user_metadata_free ( struct opendal_metadata_user_metadata * metadata)

Free the user metadata returned by opendal_metadata_user_metadata.

◆ opendal_metadata_user_metadata_len()

uintptr_t opendal_metadata_user_metadata_len ( const struct opendal_metadata_user_metadata * metadata)

Return the number of key-value pairs in the user metadata.

◆ opendal_metadata_user_metadata_pairs()

const struct opendal_metadata_user_metadata_pair * opendal_metadata_user_metadata_pairs ( const struct opendal_metadata_user_metadata * metadata)

Return the key-value pairs of the user metadata.

◆ opendal_metadata_version()

char * opendal_metadata_version ( const struct opendal_metadata * self)

Return this entry's service-specific version identifier.

Note
: The string is on heap, free it with opendal_string_free().

◆ opendal_operator_check()

struct opendal_error * opendal_operator_check ( const struct opendal_operator * op)

Check whether the operator works properly.

◆ opendal_operator_check_with_cancel()

struct opendal_error * opendal_operator_check_with_cancel ( const struct opendal_operator * op,
const struct opendal_cancel_token * cancel )

Check whether the operator works properly, supporting optional cancellation.

Pass NULL for cancel to run without cancellation.

◆ opendal_operator_copier()

struct opendal_error * opendal_operator_copier ( const struct opendal_operator * op,
const char * src,
const char * dest,
struct opendal_copier ** copier )

Blocking create a copier to copy a file from src to dest.

The returned copier is used to complete a long-running copy operation. Call opendal_copier_next repeatedly to make progress, and opendal_copier_free to release it once finished.

Parameters
opThe opendal_operator created previously
srcThe designated source path you want to copy
destThe designated destination path you want to copy
copierOutput pointer receiving the allocated opendal_copier * on success, or NULL on failure
See also
opendal_operator
opendal_copier
Returns
NULL if the operation succeeds, or an opendal_error * on failure.

Safety

  • The memory pointed to by src and dest must contain a valid nul terminator at the end of the string.
  • copier must be a valid, aligned, writable pointer.

Panic

  • If src, dest, or copier points to NULL, this function panics

◆ opendal_operator_copier_with()

struct opendal_error * opendal_operator_copier_with ( const struct opendal_operator * op,
const char * src,
const char * dest,
const struct opendal_copy_options * opts,
struct opendal_copier ** copier )

Blocking create a copier to copy a file from src to dest with options.

This is the same as opendal_operator_copier but accepts an opendal_copy_options to control the behavior, e.g. concurrent or chunk. Pass NULL to use defaults.

Parameters
opThe opendal_operator created previously
srcThe designated source path you want to copy
destThe designated destination path you want to copy
optsThe options for the copy operation; pass NULL to use defaults
copierOutput pointer receiving the allocated opendal_copier * on success, or NULL on failure
See also
opendal_operator_copier
opendal_copy_options
Returns
NULL if the operation succeeds, or an opendal_error * on failure.

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_copy_options string setters store the caller's pointer, not a copy. The returned copier does not read *opts, so the caller can free the options and their strings when this function returns.

◆ opendal_operator_copier_with_cancel()

struct opendal_error * opendal_operator_copier_with_cancel ( const struct opendal_operator * op,
const char * src,
const char * dest,
const struct opendal_copy_options * opts,
const struct opendal_cancel_token * cancel,
struct opendal_copier ** copier )

Blocking create a copier to copy a file from src to dest with options and optional cancellation.

Pass NULL for opts to use defaults, and NULL for cancel to run without cancellation. On cancellation or failure, writes NULL to *copier and returns an opendal_error * (OPENDAL_CANCELLED on cancellation).

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_copy_options string setters store the caller's pointer, not a copy. The returned copier does not read *opts, so the caller can free the options and their strings when this function returns.

◆ opendal_operator_copy()

struct opendal_error * opendal_operator_copy ( const struct opendal_operator * op,
const char * src,
const char * dest )

Blocking copy the object in path.

Copy the object in src to dest blocking by op. Error is NULL if successful, otherwise it contains the error code and error message.

Parameters
opThe opendal_operator created previously
srcThe designated source path you want to copy
destThe designated destination path you want to copy
See also
opendal_operator
opendal_error
Returns
NULL if succeeds, otherwise it contains the error code and error message.

Example

Following is an example

//...prepare your opendal_operator, named op for example
// prepare your data
char* data = "Hello, World!";
opendal_bytes bytes = opendal_bytes { .data = (uint8_t*)data, .len = 13 };
opendal_error *error = opendal_operator_write(op, "/testpath", bytes);
assert(error == NULL);
// now you can rename!
opendal_error *error = opendal_operator_copy(op, "/testpath", "/testpath2");
// Assert that this succeeds
assert(error == NULL);
struct opendal_error * opendal_operator_write(const struct opendal_operator *op, const char *path, const struct opendal_bytes *bytes)
Blocking write raw bytes to path.
struct opendal_error * opendal_operator_copy(const struct opendal_operator *op, const char *src, const char *dest)
Blocking copy the object in path.
opendal_bytes carries raw-bytes with its length
Definition opendal.h:150

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 src or dest points to NULL, this function panics, i.e. exits with information

◆ opendal_operator_copy_with()

struct opendal_error * opendal_operator_copy_with ( const struct opendal_operator * op,
const char * src,
const char * dest,
const struct opendal_copy_options * opts )

Blocking copy the object in path with options.

Copy the object from src to dest blocking by op, using the provided opendal_copy_options to control the behavior, e.g. if_not_exists or if_match conditions.

Parameters
opThe opendal_operator created previously
srcThe designated source path you want to copy
destThe designated destination path you want to copy
optsThe options for the copy operation; pass NULL to use defaults
See also
opendal_operator
opendal_copy_options
opendal_error
Returns
NULL if succeeds, otherwise it contains the error code and error message.

Example

Following is an example

//...prepare your opendal_operator, named op for example
// prepare your data
char* data = "Hello, World!";
opendal_bytes bytes = opendal_bytes { .data = (uint8_t*)data, .len = 13 };
opendal_error *error = opendal_operator_write(op, "/testpath", bytes);
assert(error == NULL);
// prepare options
// now you can copy with options!
opendal_error *error = opendal_operator_copy_with(op, "/testpath", "/testpath2", opts);
// Assert that this succeeds
assert(error == NULL);
// remember to free the options
void opendal_copy_options_set_if_not_exists(struct opendal_copy_options *opts, bool if_not_exists)
Set if_not_exists.
struct opendal_error * opendal_operator_copy_with(const struct opendal_operator *op, const char *src, const char *dest, const struct opendal_copy_options *opts)
Blocking copy the object in path with options.
struct opendal_copy_options * opendal_copy_options_new(void)
Construct a heap-allocated opendal_copy_options with default values.
void opendal_copy_options_free(struct opendal_copy_options *opts)
Free the heap memory used by opendal_copy_options.
Options for copy operations.
Definition opendal.h:1540

Safety

It is safe under the cases below

  • The memory pointed to by src and dest must contain a valid nul terminator at the end of the string.
  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_copy_options string setters store the caller's pointer, not a copy.

Panic

  • If the src or dest points to NULL, this function panics, i.e. exits with information

◆ opendal_operator_copy_with_cancel()

struct opendal_error * opendal_operator_copy_with_cancel ( const struct opendal_operator * op,
const char * src,
const char * dest,
const struct opendal_copy_options * opts,
const struct opendal_cancel_token * cancel )

Blocking copy the object from src to dest with options and optional cancellation.

Pass NULL for opts to use defaults, and NULL for cancel to run without cancellation.

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_copy_options string setters store the caller's pointer, not a copy.

◆ opendal_operator_create_dir()

struct opendal_error * opendal_operator_create_dir ( const struct opendal_operator * op,
const char * path )

Blocking create the directory in path.

Create the directory in path blocking by op_ptr. Error is NULL if successful, otherwise it contains the error code and error message.

Parameters
opThe opendal_operator created previously
pathThe designated directory you want to create
See also
opendal_operator
opendal_error
Returns
NULL if succeeds, otherwise it contains the error code and error message.

Example

Following is an example

//...prepare your opendal_operator, named op for example
// create your directory
opendal_error *error = opendal_operator_create_dir(op, "/testdir/");
// Assert that this succeeds
assert(error == NULL);
struct opendal_error * opendal_operator_create_dir(const struct opendal_operator *op, const char *path)
Blocking create the directory in path.

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

◆ opendal_operator_create_dir_with_cancel()

struct opendal_error * opendal_operator_create_dir_with_cancel ( const struct opendal_operator * op,
const char * path,
const struct opendal_cancel_token * cancel )

Blocking create the directory in path with optional cancellation.

Pass NULL for cancel to run without cancellation.

◆ opendal_operator_delete()

struct opendal_error * opendal_operator_delete ( const struct opendal_operator * op,
const char * path )

Blocking delete the object in path.

Delete the object in path blocking by op_ptr. Error is NULL if successful, otherwise it contains the error code and error message.

Parameters
opThe opendal_operator created previously
pathThe designated path you want to delete
See also
opendal_operator
opendal_error
Returns
NULL if succeeds, otherwise it contains the error code and error message.

Example

Following is an example

//...prepare your opendal_operator, named op for example
// prepare your data
char* data = "Hello, World!";
opendal_bytes bytes = opendal_bytes { .data = (uint8_t*)data, .len = 13 };
opendal_error *error = opendal_operator_write(op, "/testpath", bytes);
assert(error == NULL);
// now you can delete!
opendal_error *error = opendal_operator_delete(op, "/testpath");
// Assert that this succeeds
assert(error == NULL);
struct opendal_error * opendal_operator_delete(const struct opendal_operator *op, const char *path)
Blocking delete the object in path.

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

◆ opendal_operator_delete_with()

struct opendal_error * opendal_operator_delete_with ( const struct opendal_operator * op,
const char * path,
const struct opendal_delete_options * opts )

Blocking delete the object in path with options.

Delete the object in path blocking by op, using the provided opendal_delete_options. This is similar to opendal_operator_delete but allows specifying a version or requesting a recursive delete.

Parameters
opThe opendal_operator created previously
pathThe designated path you want to delete
optsThe options for the delete operation; pass NULL to use defaults
See also
opendal_delete_options
Returns
NULL if succeeds, otherwise it contains the error code and error message.

Safety

  • The memory pointed to by path must contain a valid nul terminator at the end of the string.
  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. opendal_delete_options_set_version stores a copy of its string, which meets this.

Panic

  • If the path points to NULL, this function panics, i.e. exits with information

◆ opendal_operator_delete_with_cancel()

struct opendal_error * opendal_operator_delete_with_cancel ( const struct opendal_operator * op,
const char * path,
const struct opendal_delete_options * opts,
const struct opendal_cancel_token * cancel )

Blocking delete the object in path with options and optional cancellation.

Pass NULL for opts to use defaults, and NULL for cancel to run without cancellation.

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. opendal_delete_options_set_version stores a copy of its string, which meets this.

◆ opendal_operator_deleter()

struct opendal_error * opendal_operator_deleter ( const struct opendal_operator * op,
struct opendal_deleter ** deleter_out )

Create a blocking deleter to remove multiple paths.

Submit paths with opendal_deleter_delete or opendal_deleter_delete_many. Call opendal_deleter_flush to complete pending deletions and opendal_deleter_free to release the handle.

Parameters
opThe opendal_operator created previously
deleter_outOutput pointer receiving the allocated deleter on success, or NULL on failure
Returns
NULL if the operation succeeds, or an opendal_error * on failure.

Safety

◆ opendal_operator_deleter_with_cancel()

struct opendal_error * opendal_operator_deleter_with_cancel ( const struct opendal_operator * op,
const struct opendal_cancel_token * cancel,
struct opendal_deleter ** deleter_out )

Create a blocking deleter to remove multiple paths, supporting optional cancellation.

Pass NULL for cancel to run without cancellation. On cancellation or failure, writes NULL to *deleter_out and returns an opendal_error * (OPENDAL_CANCELLED on cancellation).

◆ opendal_operator_exists()

struct opendal_error * opendal_operator_exists ( const struct opendal_operator * op,
const char * path,
bool * exists )

Check whether the path exists.

If the operation succeeds, no matter the path exists or not, the error should be a nullptr. Otherwise, the field exists is filled with false, and the error is set

Parameters
opThe opendal_operator created previously
pathThe path you want to check existence
existsOutput pointer receiving whether the path exists, or false on failure
See also
opendal_operator
opendal_error
Returns
NULL if the operation succeeds, or an opendal_error * on failure.

Example

// .. you previously wrote some data to path "/mytest/obj"
bool exists = false;
opendal_error *err = opendal_operator_exists(op, "/mytest/obj", &exists);
assert(err == NULL);
assert(exists);
// but you previously did **not** write any data to path "/yourtest/obj"
err = opendal_operator_exists(op, "/yourtest/obj", &exists);
assert(err == NULL);
assert(!exists);
struct opendal_error * opendal_operator_exists(const struct opendal_operator *op, const char *path, bool *exists)
Check whether the path exists.

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.
  • exists must be a valid, aligned, writable pointer.

Panic

  • If path or exists points to NULL, this function panics, i.e. exits with information

◆ opendal_operator_exists_with_cancel()

struct opendal_error * opendal_operator_exists_with_cancel ( const struct opendal_operator * op,
const char * path,
const struct opendal_cancel_token * cancel,
bool * exists )

Check whether the path exists, supporting optional cancellation via cancel.

Pass NULL for cancel to run without cancellation. On cancellation or failure, writes false to *exists and returns an opendal_error * (OPENDAL_CANCELLED on cancellation).

◆ opendal_operator_free()

void opendal_operator_free ( const struct opendal_operator * ptr)

Free the heap-allocated operator pointed by opendal_operator.

Please only use this for a pointer pointing at a valid opendal_operator. Calling this function on NULL does nothing, but calling this function on pointers of other type will lead to segfault.

Example

opendal_operator *op = NULL;
opendal_error *err = opendal_operator_new("fs", NULL, &op);
// ... use this op, maybe some reads and writes
// free this operator
void opendal_operator_free(const struct opendal_operator *ptr)
Free the heap-allocated operator pointed by opendal_operator.
struct opendal_error * opendal_operator_new(const char *scheme, const struct opendal_operator_options *options, struct opendal_operator **op)
Construct an operator based on scheme and options.
Used to access almost all OpenDAL APIs. It represents an operator that provides the unified interface...
Definition opendal.h:311

◆ opendal_operator_info_free()

void opendal_operator_info_free ( struct opendal_operator_info * ptr)

Free the heap-allocated opendal_operator_info.

◆ opendal_operator_info_get_capability()

void opendal_operator_info_get_capability ( const struct opendal_operator_info * self,
struct opendal_capability * cap )

Write the operator's capability into cap.

◆ opendal_operator_info_get_name()

char * opendal_operator_info_get_name ( const struct opendal_operator_info * self)

Return the nul-terminated operator backend's name, could be empty if underlying backend has no namespace concept.

Note
: The string is on heap, free it with opendal_string_free()

◆ opendal_operator_info_get_root()

char * opendal_operator_info_get_root ( const struct opendal_operator_info * self)

Return the nul-terminated operator's working root path.

Note
: The string is on heap, free it with opendal_string_free()

◆ opendal_operator_info_get_scheme()

char * opendal_operator_info_get_scheme ( const struct opendal_operator_info * self)

Return the nul-terminated operator's scheme, i.e. service.

Note
: The string is on heap, free it with opendal_string_free()

◆ opendal_operator_info_new()

struct opendal_operator_info * opendal_operator_info_new ( const struct opendal_operator * op)

Get information of underlying accessor.

Example

char *scheme;
assert(!strcmp(scheme, "memory"));
char * opendal_operator_info_get_scheme(const struct opendal_operator_info *self)
Return the nul-terminated operator's scheme, i.e. service.
void opendal_operator_info_free(struct opendal_operator_info *ptr)
Free the heap-allocated opendal_operator_info.
void opendal_string_free(char *ptr)
Frees a heap-allocated string returned by OpenDAL C APIs.
struct opendal_operator_info * opendal_operator_info_new(const struct opendal_operator *op)
Get information of underlying accessor.
Metadata for operator, users can use this metadata to get information of operator.
Definition opendal.h:1708

◆ opendal_operator_is_exist()

struct opendal_error * opendal_operator_is_exist ( const struct opendal_operator * op,
const char * path,
bool * is_exist )

Check whether the path exists.

If the operation succeeds, no matter the path exists or not, the error should be a nullptr. Otherwise, the field is_exist is filled with false, and the error is set

Parameters
opThe opendal_operator created previously
pathThe path you want to check existence
is_existOutput pointer receiving whether the path exists, or false on failure
See also
opendal_operator
opendal_error
Returns
NULL if the operation succeeds, or an opendal_error * on failure.

Example

// .. you previously wrote some data to path "/mytest/obj"
bool exists = false;
opendal_error *err = opendal_operator_is_exist(op, "/mytest/obj", &exists);
assert(err == NULL);
assert(exists);
// but you previously did **not** write any data to path "/yourtest/obj"
err = opendal_operator_is_exist(op, "/yourtest/obj", &exists);
assert(err == NULL);
assert(!exists);
struct opendal_error * opendal_operator_is_exist(const struct opendal_operator *op, const char *path, bool *is_exist)
Check whether the path exists.

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.
  • is_exist must be a valid, aligned, writable pointer.

Panic

  • If path or is_exist points to NULL, this function panics, i.e. exits with information

◆ opendal_operator_layers_add_retry()

void opendal_operator_layers_add_retry ( struct opendal_operator_layers * layers,
bool jitter,
float factor,
uint64_t min_delay_ns,
uint64_t max_delay_ns,
uint64_t max_times )

Add a retry layer.

◆ opendal_operator_layers_add_timeout()

void opendal_operator_layers_add_timeout ( struct opendal_operator_layers * layers,
uint64_t timeout_ns,
uint64_t io_timeout_ns )

Add a timeout layer.

◆ opendal_operator_layers_free()

void opendal_operator_layers_free ( struct opendal_operator_layers * ptr)

Free the allocated memory used by opendal_operator_layers.

◆ opendal_operator_layers_new()

struct opendal_operator_layers * opendal_operator_layers_new ( void )

Construct a heap-allocated opendal_operator_layers.

◆ opendal_operator_list()

struct opendal_error * opendal_operator_list ( const struct opendal_operator * op,
const char * path,
struct opendal_lister ** lister )

Blocking list the objects in path.

List the object in path blocking by op_ptr, writing the constructed opendal_lister * to *lister. Users should call opendal_lister_next() on the lister.

Parameters
opThe opendal_operator created previously
pathThe designated path you want to list
listerOutput pointer receiving the allocated opendal_lister * on success, or NULL on failure
See also
opendal_lister
Returns
NULL if the operation succeeds, or an opendal_error * on failure.

Example

Following is an example

// You have written some data into some files path "root/dir1"
// Your opendal_operator was called op
opendal_lister *lister = NULL;
opendal_error *err = opendal_operator_list(op, "root/dir1", &lister);
assert(err == NULL);
opendal_entry *entry = NULL;
while ((err = opendal_lister_next(lister, &entry)) == NULL && entry != NULL) {
char* de_path = opendal_entry_path(entry);
char* de_name = opendal_entry_name(entry);
// ...... your operations
// remember to free the entry after you are done using it
}
assert(err == NULL);
// and remember to free the lister
struct opendal_error * opendal_operator_list(const struct opendal_operator *op, const char *path, struct opendal_lister **lister)
Blocking list the objects in path.
void opendal_lister_free(struct opendal_lister *ptr)
Free the heap-allocated metadata used by opendal_lister.
char * opendal_entry_name(const struct opendal_entry *self)
Name of entry.
char * opendal_entry_path(const struct opendal_entry *self)
Path of entry.
struct opendal_error * opendal_lister_next(struct opendal_lister *self, struct opendal_entry **entry)
Return the next object to be listed.
void opendal_entry_free(struct opendal_entry *ptr)
Frees the heap memory used by the opendal_list_entry.
opendal_list_entry is the entry under a path, which is listed from the opendal_lister
Definition opendal.h:215
Lister is designed to list entries at a given path in a blocking manner.
Definition opendal.h:199

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.
  • lister must be a valid, aligned, writable pointer.

Panic

  • If path or lister points to NULL, this function panics, i.e. exits with information

◆ opendal_operator_list_with()

struct opendal_error * opendal_operator_list_with ( const struct opendal_operator * op,
const char * path,
const struct opendal_list_options * opts,
struct opendal_lister ** lister )

Blocking list the objects in path with options.

List the objects in path with the provided opendal_list_options. This is similar to opendal_operator_list but allows passing options such as recursive to control the listing behavior.

Parameters
opThe opendal_operator created previously
pathThe designated path you want to list
optsThe options for the list operation; pass NULL to use defaults
listerOutput pointer receiving the allocated opendal_lister * on success, or NULL on failure
See also
opendal_lister
opendal_list_options
Returns
NULL if the operation succeeds, or an opendal_error * on failure.

Safety

  • The memory pointed to by path must contain a valid null terminator at the end of the string.
  • lister must be a valid, aligned, writable pointer.
  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. opendal_list_options_set_start_after stores a copy of its string, which meets this.

Panic

  • If path or lister points to NULL, this function panics, i.e. exits with information

◆ opendal_operator_list_with_cancel()

struct opendal_error * opendal_operator_list_with_cancel ( const struct opendal_operator * op,
const char * path,
const struct opendal_list_options * opts,
const struct opendal_cancel_token * cancel,
struct opendal_lister ** lister )

Blocking list the objects in path with options and optional cancellation.

Pass NULL for opts to use defaults, and NULL for cancel to run without cancellation. On cancellation or failure, writes NULL to *lister and returns an opendal_error * (OPENDAL_CANCELLED on cancellation).

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. opendal_list_options_set_start_after stores a copy of its string, which meets this.

◆ opendal_operator_new()

struct opendal_error * opendal_operator_new ( const char * scheme,
const struct opendal_operator_options * options,
struct opendal_operator ** op )

Construct an operator based on scheme and options.

Pass service configuration and any context.<name>.*, layers, and layer.<name>.* options as key-value pairs from trusted sources. The linked library must include the selected service and configured providers.

The layers option lists layer names from inner to outer, separated by commas. This constructor appends the C binding's default retry and logging layers after the configured layers. In particular, layers=retry adds an inner retry layer beneath the default retry layer. Use opendal_operator_new_with_layers() with layers set to NULL to use only the configured layers in addition to OpenDAL's core layers.

Parameters
schemethe service scheme you want to specify, e.g. "fs", "s3"
optionsthe pointer to the options for this operator, it could be NULL, which means no option is set
opoutput pointer receiving the newly allocated opendal_operator * on success, or NULL on failure
See also
opendal_operator_options
Returns
NULL if construction succeeds, or an opendal_error * on failure.

Example

Following is an example.

// Allocate a new options
// Set the options you need
opendal_operator_options_set(options, "root", "/myroot");
// Construct the operator based on the options and scheme
opendal_operator *op = NULL;
opendal_error *err = opendal_operator_new("memory", options, &op);
// you could free the options right away since the options is not used afterwards
// ... your operations
void opendal_operator_options_free(struct opendal_operator_options *ptr)
Free the allocated memory used by [opendal_operator_options].
void opendal_operator_options_set(struct opendal_operator_options *opts, const char *key, const char *value)
Set a Key-Value pair inside opendal_operator_options.
struct opendal_operator_options * opendal_operator_options_new(void)
Construct a heap-allocated opendal_operator_options.
The configuration for the initialization of opendal_operator.
Definition opendal.h:329

Safety

scheme must be a valid nul-terminated C string and op must be a valid, aligned, writable pointer.

◆ opendal_operator_new_with_layers()

struct opendal_error * opendal_operator_new_with_layers ( const char * scheme,
const struct opendal_operator_options * options,
const struct opendal_operator_layers * layers,
struct opendal_operator ** op )

Construct an operator based on scheme, options, and explicit layers.

This constructor uses the same configuration options as opendal_operator_new(). It appends the layers in the C handle in insertion order, after any layers configured in options. Pass NULL for the C handle to keep only the configured layers and OpenDAL's core layers.

This constructor omits the C binding's default retry and logging layers.

Parameters
schemeThe service scheme.
optionsThe configuration options, or NULL to use defaults.
layersThe C layer handle, or NULL to append no explicit layers.
opOutput pointer receiving the newly allocated opendal_operator * on success, or NULL on failure.
Returns
NULL if construction succeeds, or an opendal_error * on failure.

Safety

scheme must be a valid nul-terminated C string and op must be a valid, aligned, writable pointer.

◆ opendal_operator_options_free()

void opendal_operator_options_free ( struct opendal_operator_options * ptr)

Free the allocated memory used by [opendal_operator_options].

◆ opendal_operator_options_new()

struct opendal_operator_options * opendal_operator_options_new ( void )

Construct a heap-allocated opendal_operator_options.

Returns
An empty opendal_operator_option, which could be set by opendal_operator_option_set().
See also
opendal_operator_option_set

◆ opendal_operator_options_set()

void opendal_operator_options_set ( struct opendal_operator_options * opts,
const char * key,
const char * value )

Set a Key-Value pair inside opendal_operator_options.

Safety

This function is unsafe because it dereferences and casts the raw pointers Make sure the pointer of key and value point to a valid string.

Example

opendal_operator_options_set(options, "root", "/myroot");
// .. use your opendal_operator_options

◆ opendal_operator_presign_delete()

struct opendal_error * opendal_operator_presign_delete ( const struct opendal_operator * op,
const char * path,
uint64_t expire_secs,
struct opendal_presigned_request ** req )

Presign a delete operation.

req must point to writable storage for a request pointer. On success, writes the request to *req and returns NULL; free the request with opendal_presigned_request_free(). On failure, writes NULL to *req and returns an error that must be freed with opendal_error_free().

◆ opendal_operator_presign_delete_with()

struct opendal_error * opendal_operator_presign_delete_with ( const struct opendal_operator * op,
const char * path,
uint64_t expire_secs,
const struct opendal_delete_options * opts,
struct opendal_presigned_request ** req )

Presign a delete operation with options.

req must point to writable storage for a request pointer. On success, writes the request to *req and returns NULL; free the request with opendal_presigned_request_free(). On failure, writes NULL to *req and returns an error that must be freed with opendal_error_free().

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. opendal_delete_options_set_version stores a copy of its string, which meets this.

◆ opendal_operator_presign_delete_with_cancel()

struct opendal_error * opendal_operator_presign_delete_with_cancel ( const struct opendal_operator * op,
const char * path,
uint64_t expire_secs,
const struct opendal_delete_options * opts,
const struct opendal_cancel_token * cancel,
struct opendal_presigned_request ** req )

Presign a delete operation with options and optional cancellation.

Pass NULL for opts to use defaults, and NULL for cancel to run without cancellation. On cancellation or failure, writes NULL to *req and returns an opendal_error * (OPENDAL_CANCELLED on cancellation).

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. opendal_delete_options_set_version stores a copy of its string, which meets this.

◆ opendal_operator_presign_read()

struct opendal_error * opendal_operator_presign_read ( const struct opendal_operator * op,
const char * path,
uint64_t expire_secs,
struct opendal_presigned_request ** req )

Presign a read operation.

req must point to writable storage for a request pointer. On success, writes the request to *req and returns NULL; free the request with opendal_presigned_request_free(). On failure, writes NULL to *req and returns an error that must be freed with opendal_error_free().

◆ opendal_operator_presign_read_with()

struct opendal_error * opendal_operator_presign_read_with ( const struct opendal_operator * op,
const char * path,
uint64_t expire_secs,
const struct opendal_read_options * opts,
struct opendal_presigned_request ** req )

Presign a read operation with options.

req must point to writable storage for a request pointer. On success, writes the request to *req and returns NULL; free the request with opendal_presigned_request_free(). On failure, writes NULL to *req and returns an error that must be freed with opendal_error_free().

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_read_options string setters store the caller's pointer, not a copy.

◆ opendal_operator_presign_read_with_cancel()

struct opendal_error * opendal_operator_presign_read_with_cancel ( const struct opendal_operator * op,
const char * path,
uint64_t expire_secs,
const struct opendal_read_options * opts,
const struct opendal_cancel_token * cancel,
struct opendal_presigned_request ** req )

Presign a read operation with options and optional cancellation.

Pass NULL for opts to use defaults, and NULL for cancel to run without cancellation. On cancellation or failure, writes NULL to *req and returns an opendal_error * (OPENDAL_CANCELLED on cancellation).

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_read_options string setters store the caller's pointer, not a copy.

◆ opendal_operator_presign_stat()

struct opendal_error * opendal_operator_presign_stat ( const struct opendal_operator * op,
const char * path,
uint64_t expire_secs,
struct opendal_presigned_request ** req )

Presign a stat operation.

req must point to writable storage for a request pointer. On success, writes the request to *req and returns NULL; free the request with opendal_presigned_request_free(). On failure, writes NULL to *req and returns an error that must be freed with opendal_error_free().

◆ opendal_operator_presign_stat_with()

struct opendal_error * opendal_operator_presign_stat_with ( const struct opendal_operator * op,
const char * path,
uint64_t expire_secs,
const struct opendal_stat_options * opts,
struct opendal_presigned_request ** req )

Presign a stat operation with options.

req must point to writable storage for a request pointer. On success, writes the request to *req and returns NULL; free the request with opendal_presigned_request_free(). On failure, writes NULL to *req and returns an error that must be freed with opendal_error_free().

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_stat_options string setters store the caller's pointer, not a copy.

◆ opendal_operator_presign_stat_with_cancel()

struct opendal_error * opendal_operator_presign_stat_with_cancel ( const struct opendal_operator * op,
const char * path,
uint64_t expire_secs,
const struct opendal_stat_options * opts,
const struct opendal_cancel_token * cancel,
struct opendal_presigned_request ** req )

Presign a stat operation with options and optional cancellation.

Pass NULL for opts to use defaults, and NULL for cancel to run without cancellation. On cancellation or failure, writes NULL to *req and returns an opendal_error * (OPENDAL_CANCELLED on cancellation).

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_stat_options string setters store the caller's pointer, not a copy.

◆ opendal_operator_presign_write()

struct opendal_error * opendal_operator_presign_write ( const struct opendal_operator * op,
const char * path,
uint64_t expire_secs,
struct opendal_presigned_request ** req )

Presign a write operation.

req must point to writable storage for a request pointer. On success, writes the request to *req and returns NULL; free the request with opendal_presigned_request_free(). On failure, writes NULL to *req and returns an error that must be freed with opendal_error_free().

◆ opendal_operator_presign_write_with()

struct opendal_error * opendal_operator_presign_write_with ( const struct opendal_operator * op,
const char * path,
uint64_t expire_secs,
const struct opendal_write_options * opts,
struct opendal_presigned_request ** req )

Presign a write operation with options.

req must point to writable storage for a request pointer. On success, writes the request to *req and returns NULL; free the request with opendal_presigned_request_free(). On failure, writes NULL to *req and returns an error that must be freed with opendal_error_free().

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A non-NULL user_metadata must point to user_metadata_len readable pairs, and each non-NULL key and value in them to a readable, nul-terminated C string, until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_write_options string and user metadata setters store the caller's pointers, not copies.

◆ opendal_operator_presign_write_with_cancel()

struct opendal_error * opendal_operator_presign_write_with_cancel ( const struct opendal_operator * op,
const char * path,
uint64_t expire_secs,
const struct opendal_write_options * opts,
const struct opendal_cancel_token * cancel,
struct opendal_presigned_request ** req )

Presign a write operation with options and optional cancellation.

Pass NULL for opts to use defaults, and NULL for cancel to run without cancellation. On cancellation or failure, writes NULL to *req and returns an opendal_error * (OPENDAL_CANCELLED on cancellation).

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A non-NULL user_metadata must point to user_metadata_len readable pairs, and each non-NULL key and value in them to a readable, nul-terminated C string, until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_write_options string and user metadata setters store the caller's pointers, not copies.

◆ opendal_operator_read()

struct opendal_error * opendal_operator_read ( const struct opendal_operator * op,
const char * path,
struct opendal_bytes * bytes )

Blocking read the data from path.

Read the data out from path blocking by operator.

Parameters
opThe opendal_operator created previously
pathThe path you want to read the data out
bytesOutput pointer receiving the newly allocated opendal_bytes on success, or an empty opendal_bytes on failure
See also
opendal_operator
opendal_bytes
opendal_error
Returns
NULL if the read succeeds, or an opendal_error * on failure.
Note
If the read operation succeeds, the buffer inside *bytes is newly allocated on heap. After your usage of that, please call opendal_bytes_free() to free the space. If you reuse the same opendal_bytes variable for another read call, free any previously owned buffer first.

Example

Following is an example

// ... you have write "Hello, World!" to path "/testpath"
opendal_error *err = opendal_operator_read(op, "testpath", &bytes);
assert(err == NULL);
assert(bytes.len == 13);
struct opendal_error * opendal_operator_read(const struct opendal_operator *op, const char *path, struct opendal_bytes *bytes)
Blocking read the data from path.
void opendal_bytes_free(struct opendal_bytes *ptr)
Frees the heap memory used by the opendal_bytes.
uintptr_t len
Definition opendal.h:158

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.
  • bytes must point to valid, aligned, writable storage.

Panic

  • If path or bytes points to NULL, this function panics, i.e. exits with information

◆ opendal_operator_read_with()

struct opendal_error * opendal_operator_read_with ( const struct opendal_operator * op,
const char * path,
const struct opendal_read_options * opts,
struct opendal_bytes * bytes )

Blocking read the data from path with options.

Read the data out from path blocking by operator, using the provided opendal_read_options to control the behavior, e.g. range, version, or conditional headers.

Parameters
opThe opendal_operator created previously
pathThe path you want to read the data out
optsThe options for the read operation; pass NULL to use defaults
bytesOutput pointer receiving the newly allocated opendal_bytes on success, or an empty opendal_bytes on failure
See also
opendal_operator
opendal_read_options
opendal_error
Returns
NULL if the read succeeds, or an opendal_error * on failure.
Note
If the read operation succeeds, the buffer inside *bytes is newly allocated on heap. After your usage of that, please call opendal_bytes_free() to free the space. If you reuse the same opendal_bytes variable for another read call, free any previously owned buffer first.

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.
  • bytes must point to valid, aligned, writable storage.
  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_read_options string setters store the caller's pointer, not a copy.

Panic

  • If path or bytes points to NULL, this function panics, i.e. exits with information

◆ opendal_operator_read_with_cancel()

struct opendal_error * opendal_operator_read_with_cancel ( const struct opendal_operator * op,
const char * path,
const struct opendal_read_options * opts,
const struct opendal_cancel_token * cancel,
struct opendal_bytes * bytes )

Blocking read the data from path with options and optional cancellation.

Pass NULL for opts to use defaults, and NULL for cancel to run without cancellation. On cancellation or failure, writes an empty opendal_bytes to *bytes and returns an opendal_error * (OPENDAL_CANCELLED on cancellation).

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_read_options string setters store the caller's pointer, not a copy.

◆ opendal_operator_reader()

struct opendal_error * opendal_operator_reader ( const struct opendal_operator * op,
const char * path,
struct opendal_reader ** reader )

Blocking create a reader for the specified path.

Parameters
opThe opendal_operator created previously
pathThe path you want to read the data out
readerOutput pointer receiving the allocated opendal_reader * on success, or NULL on failure
See also
opendal_operator
opendal_reader
opendal_error
Returns
NULL if the operation succeeds, or an opendal_error * on failure.

Example

Following is an example

// ... you have created an operator named op
opendal_reader *reader = NULL;
opendal_error *err = opendal_operator_reader(op, "/testpath", &reader);
assert(err == NULL);
struct opendal_error * opendal_operator_reader(const struct opendal_operator *op, const char *path, struct opendal_reader **reader)
Blocking create a reader for the specified path.
The result type returned by opendal's reader operation.
Definition opendal.h:964

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.
  • reader must be a valid, aligned, writable pointer.

Panic

  • If path or reader points to NULL, this function panics, i.e. exits with information

◆ opendal_operator_reader_with()

struct opendal_error * opendal_operator_reader_with ( const struct opendal_operator * op,
const char * path,
const struct opendal_reader_options * opts,
struct opendal_reader ** reader )

Blocking create a reader for the specified path with options.

This function prepares a reader, applying the conditional, version and concurrency options carried by opts. A NULL opts is treated as the default options, behaving like opendal_operator_reader.

Parameters
opThe opendal_operator created previously
pathThe designated path where the reader will be used
optsThe reader options, or NULL to use the defaults
readerOutput pointer receiving the allocated opendal_reader * on success, or NULL on failure
See also
opendal_operator
opendal_reader_options
Returns
NULL if the operation succeeds, or an opendal_error * on failure.

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.
  • reader must be a valid, aligned, writable pointer.
  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_reader_options string setters store the caller's pointer, not a copy.

Panic

  • If path or reader points to NULL, this function panics, i.e. exits with information

◆ opendal_operator_reader_with_cancel()

struct opendal_error * opendal_operator_reader_with_cancel ( const struct opendal_operator * op,
const char * path,
const struct opendal_reader_options * opts,
const struct opendal_cancel_token * cancel,
struct opendal_reader ** reader )

Blocking create a reader for the specified path with options and optional cancellation.

Pass NULL for opts to use defaults, and NULL for cancel to run without cancellation. On cancellation or failure, writes NULL to *reader and returns an opendal_error * (OPENDAL_CANCELLED on cancellation).

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_reader_options string setters store the caller's pointer, not a copy.

◆ opendal_operator_rename()

struct opendal_error * opendal_operator_rename ( const struct opendal_operator * op,
const char * src,
const char * dest )

Blocking rename the object in path.

Rename the object in src to dest blocking by op. Error is NULL if successful, otherwise it contains the error code and error message.

Parameters
opThe opendal_operator created previously
srcThe designated source path you want to rename
destThe designated destination path you want to rename
See also
opendal_operator
opendal_error
Returns
NULL if succeeds, otherwise it contains the error code and error message.

Example

Following is an example

//...prepare your opendal_operator, named op for example
// prepare your data
char* data = "Hello, World!";
opendal_bytes bytes = opendal_bytes { .data = (uint8_t*)data, .len = 13 };
opendal_error *error = opendal_operator_write(op, "/testpath", bytes);
assert(error == NULL);
// now you can rename!
opendal_error *error = opendal_operator_rename(op, "/testpath", "/testpath2");
// Assert that this succeeds
assert(error == NULL);
struct opendal_error * opendal_operator_rename(const struct opendal_operator *op, const char *src, const char *dest)
Blocking rename the object in path.

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 src or dest points to NULL, this function panics, i.e. exits with information

◆ opendal_operator_rename_with_cancel()

struct opendal_error * opendal_operator_rename_with_cancel ( const struct opendal_operator * op,
const char * src,
const char * dest,
const struct opendal_cancel_token * cancel )

Blocking rename the object from src to dest with optional cancellation.

Pass NULL for cancel to run without cancellation.

◆ opendal_operator_stat()

struct opendal_error * opendal_operator_stat ( const struct opendal_operator * op,
const char * path,
struct opendal_metadata ** meta )

Stat the path, return its metadata.

Error is NULL if successful, otherwise it contains the error code and error message.

Parameters
opThe opendal_operator created previously
pathThe path you want to stat
metaOutput pointer receiving the allocated opendal_metadata * on success, or NULL on failure
See also
opendal_operator
opendal_metadata
Returns
NULL if the operation succeeds, or an opendal_error * on failure.

Example

// ... previously you wrote "Hello, World!" to path "/testpath"
opendal_metadata *meta = NULL;
opendal_error *err = opendal_operator_stat(op, "/testpath", &meta);
assert(err == NULL);
// ... you could now use your metadata, notice that please only access metadata
// using the APIs provided by OpenDAL

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.
  • meta must be a valid, aligned, writable pointer.

Panic

  • If path or meta points to NULL, this function panics, i.e. exits with information

◆ opendal_operator_stat_with()

struct opendal_error * opendal_operator_stat_with ( const struct opendal_operator * op,
const char * path,
const struct opendal_stat_options * opts,
struct opendal_metadata ** meta )

Blocking stat the object in path with options.

Stat the object in path with the provided opendal_stat_options. This is similar to opendal_operator_stat but allows passing options such as version, if_match, if_none_match, or response header overrides.

Parameters
opThe opendal_operator created previously
pathThe path you want to stat
optsThe options for the stat operation; pass NULL to use defaults
metaOutput pointer receiving the allocated opendal_metadata * on success, or NULL on failure
See also
opendal_operator
opendal_stat_options
Returns
NULL if the operation succeeds, or an opendal_error * on failure.

Safety

  • The memory pointed to by path must contain a valid nul terminator at the end of the string.
  • meta must be a valid, aligned, writable pointer.
  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_stat_options string setters store the caller's pointer, not a copy.

Panic

  • If path or meta points to NULL, this function panics, i.e. exits with information

◆ opendal_operator_stat_with_cancel()

struct opendal_error * opendal_operator_stat_with_cancel ( const struct opendal_operator * op,
const char * path,
const struct opendal_stat_options * opts,
const struct opendal_cancel_token * cancel,
struct opendal_metadata ** meta )

Blocking stat the object in path with options and optional cancellation.

Pass NULL for opts to use defaults, and NULL for cancel to run without cancellation. On cancellation or failure, writes NULL to *meta and returns an opendal_error * (OPENDAL_CANCELLED on cancellation).

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_stat_options string setters store the caller's pointer, not a copy.

◆ opendal_operator_write()

struct opendal_error * opendal_operator_write ( const struct opendal_operator * op,
const char * path,
const struct opendal_bytes * bytes )

Blocking write raw bytes to path.

Write the bytes into the path blocking by op_ptr. Error is NULL if successful, otherwise it contains the error code and error message.

Note
It is important to notice that the bytes that is passes in will be consumed by this function. Therefore, you should not use the bytes after this function returns.
Parameters
opThe opendal_operator created previously
pathThe designated path you want to write your bytes in
bytesThe opendal_byte typed bytes to be written
See also
opendal_operator
opendal_bytes
opendal_error
Returns
NULL if succeeds, otherwise it contains the error code and error message.

Example

Following is an example

//...prepare your opendal_operator, named op for example
// prepare your data
char* data = "Hello, World!";
opendal_bytes bytes = opendal_bytes { .data = (uint8_t*)data, .len = 13 };
// now you can write!
opendal_error *err = opendal_operator_write(op, "/testpath", bytes);
// Assert that this succeeds
assert(err == NULL);

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.
  • If bytes.len is greater than 0, bytes.data must point to at least bytes.len valid bytes. If bytes.len is 0, bytes.data must be NULL.

Panic

  • If the path points to NULL, this function panics, i.e. exits with information

◆ opendal_operator_write_with()

struct opendal_error * opendal_operator_write_with ( const struct opendal_operator * op,
const char * path,
const struct opendal_bytes * bytes,
const struct opendal_write_options * opts )

Blocking write raw bytes to path with options.

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A non-NULL user_metadata must point to user_metadata_len readable pairs, and each non-NULL key and value in them to a readable, nul-terminated C string, until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_write_options string and user metadata setters store the caller's pointers, not copies.

◆ opendal_operator_write_with_cancel()

struct opendal_error * opendal_operator_write_with_cancel ( const struct opendal_operator * op,
const char * path,
const struct opendal_bytes * bytes,
const struct opendal_write_options * opts,
const struct opendal_cancel_token * cancel,
struct opendal_metadata ** meta )

Blocking write raw bytes to path with options, optional cancellation, and optional metadata output.

Pass NULL for opts to use defaults, NULL for cancel to run without cancellation, and NULL for meta to discard the written object's metadata. When meta is non-null, *meta receives the allocated opendal_metadata * on success, or NULL on cancellation or failure.

Parameters
opThe opendal_operator created previously
pathThe designated path where the data will be written
bytesThe data to write
optsThe write options, or NULL to use the defaults
cancelOptional cancel token, or NULL
metaOptional output pointer receiving the allocated opendal_metadata *, or NULL
Returns
NULL if the operation succeeds, or an opendal_error * on cancellation or failure.

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A non-NULL user_metadata must point to user_metadata_len readable pairs, and each non-NULL key and value in them to a readable, nul-terminated C string, until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_write_options string and user metadata setters store the caller's pointers, not copies.

◆ opendal_operator_write_with_metadata()

struct opendal_error * opendal_operator_write_with_metadata ( const struct opendal_operator * op,
const char * path,
const struct opendal_bytes * bytes,
const struct opendal_write_options * opts,
struct opendal_metadata ** meta )

Blocking write raw bytes to path, returning the written object's metadata.

Like opendal_operator_write_with, but on success writes the metadata of the just-written object (e.g. etag, version, last modified) to *meta instead of discarding it. A NULL opts is treated as the default options, behaving like a plain write.

Parameters
opThe opendal_operator created previously
pathThe designated path where the data will be written
bytesThe data to write
optsThe write options, or NULL to use the defaults
metaOutput pointer receiving the allocated opendal_metadata * on success, or NULL on failure
See also
opendal_operator
opendal_write_options
Returns
NULL if the operation succeeds, or an opendal_error * on failure.
Note
The returned metadata must be freed with opendal_metadata_free().

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.
  • The bytes provided has valid byte in the data field and the len field is set correctly.
  • meta must be a valid, aligned, writable pointer.
  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A non-NULL user_metadata must point to user_metadata_len readable pairs, and each non-NULL key and value in them to a readable, nul-terminated C string, until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_write_options string and user metadata setters store the caller's pointers, not copies.

Panic

  • If path or meta points to NULL, this function panics, i.e. exits with information

◆ opendal_operator_writer()

struct opendal_error * opendal_operator_writer ( const struct opendal_operator * op,
const char * path,
struct opendal_writer ** writer )

Blocking create a writer for the specified path.

This function prepares a writer that can be used to write data to the specified path using the provided operator.

Parameters
opThe opendal_operator created previously
pathThe designated path where the writer will be used
writerOutput pointer receiving the allocated opendal_writer * on success, or NULL on failure
See also
opendal_operator
opendal_writer
opendal_error
Returns
NULL if the operation succeeds, or an opendal_error * on failure.

Example

Following is an example

//...prepare your opendal_operator, named op for example
opendal_writer *writer = NULL;
opendal_error *err = opendal_operator_writer(op, "/testpath", &writer);
assert(err == NULL);
// Use the writer to write data...
struct opendal_error * opendal_operator_writer(const struct opendal_operator *op, const char *path, struct opendal_writer **writer)
Blocking create a writer for the specified path.
The result type returned by opendal's writer operation.
Definition opendal.h:1200

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.
  • writer must be a valid, aligned, writable pointer.

Panic

  • If path or writer points to NULL, this function panics, i.e. exits with information

◆ opendal_operator_writer_with()

struct opendal_error * opendal_operator_writer_with ( const struct opendal_operator * op,
const char * path,
const struct opendal_write_options * opts,
struct opendal_writer ** writer )

Blocking create a writer for the specified path with options.

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A non-NULL user_metadata must point to user_metadata_len readable pairs, and each non-NULL key and value in them to a readable, nul-terminated C string, until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_write_options string and user metadata setters store the caller's pointers, not copies. The returned writer does not read *opts, so the caller can free the options, their strings, and the pairs when this function returns.

◆ opendal_operator_writer_with_cancel()

struct opendal_error * opendal_operator_writer_with_cancel ( const struct opendal_operator * op,
const char * path,
const struct opendal_write_options * opts,
const struct opendal_cancel_token * cancel,
struct opendal_writer ** writer )

Blocking create a writer for the specified path with options and optional cancellation.

Pass NULL for opts to use defaults, and NULL for cancel to run without cancellation. On cancellation or failure, writes NULL to *writer and returns an opendal_error * (OPENDAL_CANCELLED on cancellation).

Safety

  • If opts is not NULL, each non-NULL string member of *opts must point to a readable, nul-terminated C string until this function returns. A non-NULL user_metadata must point to user_metadata_len readable pairs, and each non-NULL key and value in them to a readable, nul-terminated C string, until this function returns. A string that is not valid UTF-8 makes this function panic. The opendal_write_options string and user metadata setters store the caller's pointers, not copies. The returned writer does not read *opts, so the caller can free the options, their strings, and the pairs when this function returns.

◆ opendal_presigned_request_free()

void opendal_presigned_request_free ( struct opendal_presigned_request * req)

Free the presigned request.

◆ opendal_presigned_request_headers()

const struct opendal_http_header_pair * opendal_presigned_request_headers ( const struct opendal_presigned_request * req)

Get the headers of the presigned request.

◆ opendal_presigned_request_headers_len()

uintptr_t opendal_presigned_request_headers_len ( const struct opendal_presigned_request * req)

Get the length of the headers of the presigned request.

◆ opendal_presigned_request_method()

const char * opendal_presigned_request_method ( const struct opendal_presigned_request * req)

Get the method of the presigned request.

◆ opendal_presigned_request_uri()

const char * opendal_presigned_request_uri ( const struct opendal_presigned_request * req)

Get the URI of the presigned request.

◆ opendal_read_options_free()

void opendal_read_options_free ( struct opendal_read_options * opts)

Free the heap memory used by opendal_read_options.

Parameters
optsThe opendal_read_options to free.

◆ opendal_read_options_new()

struct opendal_read_options * opendal_read_options_new ( void )

Construct a heap-allocated opendal_read_options with default values.

Returns
A new opendal_read_options with all options set to their defaults.
See also
opendal_read_options_free

◆ opendal_read_options_set_chunk()

void opendal_read_options_set_chunk ( struct opendal_read_options * opts,
uintptr_t chunk )

Set chunk.

Set chunk for the operation.

By default, OpenDAL reads the range with a single request instead of in chunks. Users can set chunk based on their own needs. 0 has the same behavior as leaving it unset.

A read with a positive chunk and an open-ended range, such as no range or one that opendal_read_options_set_range_from() sets, first stats the file to learn its length, unless content_length_hint is set. That stat carries the read's version and conditions, so each of them also needs its stat capability, such as opendal_capability.stat_with_if_modified_since for if_modified_since; otherwise the read returns OPENDAL_UNSUPPORTED.

The setter also sets has_chunk.

Parameters
optsThe opendal_read_options to modify.
chunkThe value to set.

◆ opendal_read_options_set_concurrent()

void opendal_read_options_set_concurrent ( struct opendal_read_options * opts,
uintptr_t concurrent )

Set concurrent.

Set concurrent for the operation.

OpenDAL reads a file without concurrency by default. This is not efficient for cases when users read large chunks of data. By setting concurrent together with chunk, opendal will read files concurrently on supported storage services.

By setting concurrent, opendal will fetch chunks concurrently with the given chunk size. Without chunk, OpenDAL does not read concurrently. 0 has the same behavior as 1.

Parameters
optsThe opendal_read_options to modify.
concurrentThe value to set; 0 is the default.

◆ opendal_read_options_set_content_length_hint()

void opendal_read_options_set_content_length_hint ( struct opendal_read_options * opts,
uint64_t content_length_hint )

Set content_length_hint.

Known content length of the object.

This is an execution hint that allows OpenDAL to avoid extra metadata requests while planning reads. It must not be used as an object identity or consistency condition.

The setter also sets has_content_length_hint.

Parameters
optsThe opendal_read_options to modify.
content_length_hintThe value to set.

◆ opendal_read_options_set_gap()

void opendal_read_options_set_gap ( struct opendal_read_options * opts,
uintptr_t gap )

Set gap.

A read selects one byte range, so gap, which merges nearby ranges, has no effect.

The setter also sets has_gap.

Parameters
optsThe opendal_read_options to modify.
gapThe value to set.

◆ opendal_read_options_set_if_match()

void opendal_read_options_set_if_match ( struct opendal_read_options * opts,
const char * if_match )

Set if_match.

Read only when the file has this exact ETag.

The condition succeeds when the file exists and its ETag equals this value. A file with a different ETag returns OPENDAL_CONDITION_NOT_MATCH; a missing file returns OPENDAL_NOT_FOUND. Only concrete ETag values are portable; a wildcard such as "*" has no portable meaning here.

The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.read_with_if_match.

A non-NULL if_match must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_read_with(), returns.

Parameters
optsThe opendal_read_options to modify.
if_matchThe string to borrow; NULL unsets it.

◆ opendal_read_options_set_if_modified_since()

void opendal_read_options_set_if_modified_since ( struct opendal_read_options * opts,
int64_t if_modified_since )

Set if_modified_since.

Read only when the file was modified after this timestamp.

The condition succeeds when the file exists and was modified after this time. A file not modified since this time returns OPENDAL_CONDITION_NOT_MATCH; a missing file returns OPENDAL_NOT_FOUND.

The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.read_with_if_modified_since.

The setter also sets has_if_modified_since. A value out of range fails the operation with OPENDAL_CONFIG_INVALID.

Parameters
optsThe opendal_read_options to modify.
if_modified_sinceMilliseconds since the Unix epoch.

◆ opendal_read_options_set_if_none_match()

void opendal_read_options_set_if_none_match ( struct opendal_read_options * opts,
const char * if_none_match )

Set if_none_match.

Read only when the file does not have this ETag.

With a concrete ETag value, the condition succeeds when the file exists with a different ETag. A file whose ETag equals this value returns OPENDAL_CONDITION_NOT_MATCH; a missing file returns OPENDAL_NOT_FOUND. Only concrete ETag values are portable; a wildcard such as "*" has no portable meaning here.

The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.read_with_if_none_match.

A non-NULL if_none_match must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_read_with(), returns.

Parameters
optsThe opendal_read_options to modify.
if_none_matchThe string to borrow; NULL unsets it.

◆ opendal_read_options_set_if_unmodified_since()

void opendal_read_options_set_if_unmodified_since ( struct opendal_read_options * opts,
int64_t if_unmodified_since )

Set if_unmodified_since.

Read only when the file was not modified after this timestamp.

The condition succeeds when the file exists and was not modified after this time. A file modified after this time returns OPENDAL_CONDITION_NOT_MATCH; a missing file returns OPENDAL_NOT_FOUND.

The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.read_with_if_unmodified_since.

The setter also sets has_if_unmodified_since. A value out of range fails the operation with OPENDAL_CONFIG_INVALID.

Parameters
optsThe opendal_read_options to modify.
if_unmodified_sinceMilliseconds since the Unix epoch.

◆ opendal_read_options_set_override_cache_control()

void opendal_read_options_set_override_cache_control ( struct opendal_read_options * opts,
const char * override_cache_control )

Set override_cache_control.

Request a cache-control response header override from services that support it, including for presigned read requests.

A non-NULL override_cache_control must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_read_with(), returns.

Parameters
optsThe opendal_read_options to modify.
override_cache_controlThe string to borrow; NULL unsets it.

◆ opendal_read_options_set_override_content_disposition()

void opendal_read_options_set_override_content_disposition ( struct opendal_read_options * opts,
const char * override_content_disposition )

Set override_content_disposition.

Request a content-disposition response header override from services that support it, including for presigned read requests.

A non-NULL override_content_disposition must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_read_with(), returns.

Parameters
optsThe opendal_read_options to modify.
override_content_dispositionThe string to borrow; NULL unsets it.

◆ opendal_read_options_set_override_content_type()

void opendal_read_options_set_override_content_type ( struct opendal_read_options * opts,
const char * override_content_type )

Set override_content_type.

Request a content-type response header override from services that support it, including for presigned read requests.

A non-NULL override_content_type must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_read_with(), returns.

Parameters
optsThe opendal_read_options to modify.
override_content_typeThe string to borrow; NULL unsets it.

◆ opendal_read_options_set_range()

void opendal_read_options_set_range ( struct opendal_read_options * opts,
uint64_t offset,
uint64_t length )

Set the range to length bytes from offset.

Read from this byte offset instead of from the start of the file.

An offset at or beyond the end of the file can return an empty buffer or fail the read, depending on the service and on chunk.

Read this many bytes from offset.

A length of 0 validates the other options, then returns an empty buffer without accessing storage. When length is positive, a file that ends before offset plus length fails the read.

The setter also sets has_length.

Parameters
optsThe opendal_read_options to modify.
offsetThe byte offset to read from.
lengthThe number of bytes to read.

◆ opendal_read_options_set_range_from()

void opendal_read_options_set_range_from ( struct opendal_read_options * opts,
uint64_t offset )

Set the range to start at offset and continue to the end of the file.

Read from this byte offset instead of from the start of the file.

An offset at or beyond the end of the file can return an empty buffer or fail the read, depending on the service and on chunk.

The setter also clears has_length and sets length to 0.

Parameters
optsThe opendal_read_options to modify.
offsetThe byte offset to read from.

◆ opendal_read_options_set_version()

void opendal_read_options_set_version ( struct opendal_read_options * opts,
const char * version )

Set version.

Read the given version of the file instead of the current one.

This selects which stored version the read returns; it is not a condition on the file. A version that does not exist returns OPENDAL_NOT_FOUND.

Check opendal_capability.read_with_version before using this option.

A non-NULL version must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_read_with(), returns.

Parameters
optsThe opendal_read_options to modify.
versionThe string to borrow; NULL unsets it.

◆ opendal_reader_free()

void opendal_reader_free ( struct opendal_reader * ptr)

Frees the heap memory used by the opendal_reader.

◆ opendal_reader_options_free()

void opendal_reader_options_free ( struct opendal_reader_options * opts)

Free the heap memory used by opendal_reader_options.

Parameters
optsThe opendal_reader_options to free.

◆ opendal_reader_options_new()

struct opendal_reader_options * opendal_reader_options_new ( void )

Construct a heap-allocated opendal_reader_options with default values.

Returns
A new opendal_reader_options with all options set to their defaults.
See also
opendal_reader_options_free

◆ opendal_reader_options_set_chunk()

void opendal_reader_options_set_chunk ( struct opendal_reader_options * opts,
uintptr_t chunk )

Set chunk.

Set chunk for the operation.

By default, OpenDAL reads each range with a single request instead of in chunks. Users can set chunk based on their own needs. 0 has the same behavior as leaving it unset.

opendal_operator_reader_with() with a positive chunk first stats the file to learn its length, unless content_length_hint is set. That stat carries the reader's version and conditions, so each of them also needs its stat capability, such as opendal_capability.stat_with_if_modified_since for if_modified_since; otherwise opendal_operator_reader_with() returns OPENDAL_UNSUPPORTED.

The setter also sets has_chunk.

Parameters
optsThe opendal_reader_options to modify.
chunkThe value to set.

◆ opendal_reader_options_set_concurrent()

void opendal_reader_options_set_concurrent ( struct opendal_reader_options * opts,
uintptr_t concurrent )

Set concurrent.

Set concurrent for the operation.

OpenDAL reads a file without concurrency by default. This is not efficient for cases when users read large chunks of data. By setting concurrent together with chunk, opendal will read files concurrently on supported storage services.

By setting concurrent, opendal will fetch chunks concurrently with the given chunk size. Without chunk, a reader from opendal_operator_reader_with() does not read concurrently. 0 has the same behavior as 1.

Parameters
optsThe opendal_reader_options to modify.
concurrentThe value to set; 0 is the default.

◆ opendal_reader_options_set_content_length_hint()

void opendal_reader_options_set_content_length_hint ( struct opendal_reader_options * opts,
uint64_t content_length_hint )

Set content_length_hint.

Known content length of the object.

This is an execution hint that allows OpenDAL to avoid extra metadata requests while planning reads. It must not be used as an object identity or consistency condition.

The setter also sets has_content_length_hint.

Parameters
optsThe opendal_reader_options to modify.
content_length_hintThe value to set.

◆ opendal_reader_options_set_gap()

void opendal_reader_options_set_gap ( struct opendal_reader_options * opts,
uintptr_t gap )

Set gap.

The reader reads the whole file as one range, so gap, which merges nearby ranges, has no effect.

The setter also sets has_gap.

Parameters
optsThe opendal_reader_options to modify.
gapThe value to set.

◆ opendal_reader_options_set_if_match()

void opendal_reader_options_set_if_match ( struct opendal_reader_options * opts,
const char * if_match )

Set if_match.

Read only when the file has this exact ETag.

The condition succeeds when the file exists and its ETag equals this value. A file with a different ETag returns OPENDAL_CONDITION_NOT_MATCH; a missing file returns OPENDAL_NOT_FOUND. Only concrete ETag values are portable; a wildcard such as "*" has no portable meaning here.

The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.read_with_if_match.

A non-NULL if_match must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_reader_with(), returns.

Parameters
optsThe opendal_reader_options to modify.
if_matchThe string to borrow; NULL unsets it.

◆ opendal_reader_options_set_if_modified_since()

void opendal_reader_options_set_if_modified_since ( struct opendal_reader_options * opts,
int64_t if_modified_since )

Set if_modified_since.

Read only when the file was modified after this timestamp.

The condition succeeds when the file exists and was modified after this time. A file not modified since this time returns OPENDAL_CONDITION_NOT_MATCH; a missing file returns OPENDAL_NOT_FOUND.

The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.read_with_if_modified_since.

The setter also sets has_if_modified_since. A value out of range fails the operation with OPENDAL_CONFIG_INVALID.

Parameters
optsThe opendal_reader_options to modify.
if_modified_sinceMilliseconds since the Unix epoch.

◆ opendal_reader_options_set_if_none_match()

void opendal_reader_options_set_if_none_match ( struct opendal_reader_options * opts,
const char * if_none_match )

Set if_none_match.

Read only when the file does not have this ETag.

With a concrete ETag value, the condition succeeds when the file exists with a different ETag. A file whose ETag equals this value returns OPENDAL_CONDITION_NOT_MATCH; a missing file returns OPENDAL_NOT_FOUND. Only concrete ETag values are portable; a wildcard such as "*" has no portable meaning here.

The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.read_with_if_none_match.

A non-NULL if_none_match must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_reader_with(), returns.

Parameters
optsThe opendal_reader_options to modify.
if_none_matchThe string to borrow; NULL unsets it.

◆ opendal_reader_options_set_if_unmodified_since()

void opendal_reader_options_set_if_unmodified_since ( struct opendal_reader_options * opts,
int64_t if_unmodified_since )

Set if_unmodified_since.

Read only when the file was not modified after this timestamp.

The condition succeeds when the file exists and was not modified after this time. A file modified after this time returns OPENDAL_CONDITION_NOT_MATCH; a missing file returns OPENDAL_NOT_FOUND.

The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.read_with_if_unmodified_since.

The setter also sets has_if_unmodified_since. A value out of range fails the operation with OPENDAL_CONFIG_INVALID.

Parameters
optsThe opendal_reader_options to modify.
if_unmodified_sinceMilliseconds since the Unix epoch.

◆ opendal_reader_options_set_prefetch()

void opendal_reader_options_set_prefetch ( struct opendal_reader_options * opts,
uintptr_t prefetch )

Set prefetch.

Controls read-ahead during concurrent range reads.

Up to prefetch finished reads can each free a slot for another range read before OpenDAL collects their results.

The default, 0, disables these extra slots. Reads already submitted under concurrent can still finish and wait to be collected.

Serial reads collect each result before starting the next read. Higher values can increase memory use.

Parameters
optsThe opendal_reader_options to modify.
prefetchThe value to set; 0 is the default.

◆ opendal_reader_options_set_version()

void opendal_reader_options_set_version ( struct opendal_reader_options * opts,
const char * version )

Set version.

Read the given version of the file instead of the current one.

This selects which stored version the reader returns; it is not a condition on the file. A version that does not exist returns OPENDAL_NOT_FOUND.

Check opendal_capability.read_with_version before using this option.

A non-NULL version must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_reader_with(), returns.

Parameters
optsThe opendal_reader_options to modify.
versionThe string to borrow; NULL unsets it.

◆ opendal_reader_read()

struct opendal_error * opendal_reader_read ( struct opendal_reader * self,
uint8_t * buf,
uintptr_t len,
uintptr_t * size )

Read data from the reader into buf and write the number of bytes read to *size.

At EOF, writes 0 to *size and returns NULL. On failure, writes 0 to *size and returns an opendal_error *.

◆ opendal_reader_read_with_cancel()

struct opendal_error * opendal_reader_read_with_cancel ( struct opendal_reader * self,
uint8_t * buf,
uintptr_t len,
const struct opendal_cancel_token * cancel,
uintptr_t * size )

Read data from the reader into buf, supporting cancellation via cancel.

Pass NULL for cancel to run without cancellation. At EOF, writes 0 to *size and returns NULL. On cancellation or failure, writes 0 to *size and returns an opendal_error * (OPENDAL_CANCELLED on cancellation).

◆ opendal_reader_seek()

struct opendal_error * opendal_reader_seek ( struct opendal_reader * self,
int64_t offset,
int32_t whence,
uint64_t * pos )

Seek to an offset, in bytes, in a stream, and write the new position to *pos.

On failure, writes 0 to *pos and returns an opendal_error *.

◆ opendal_reader_seek_with_cancel()

struct opendal_error * opendal_reader_seek_with_cancel ( struct opendal_reader * self,
int64_t offset,
int32_t whence,
const struct opendal_cancel_token * cancel,
uint64_t * pos )

Seek to an offset, in bytes, in a stream, supporting cancellation via cancel.

Pass NULL for cancel to run without cancellation. On cancellation or failure, writes 0 to *pos and returns an opendal_error * (OPENDAL_CANCELLED on cancellation).

◆ opendal_stat_options_free()

void opendal_stat_options_free ( struct opendal_stat_options * opts)

Free the heap memory used by opendal_stat_options.

Parameters
optsThe opendal_stat_options to free.

◆ opendal_stat_options_new()

struct opendal_stat_options * opendal_stat_options_new ( void )

Construct a heap-allocated opendal_stat_options with default values.

Returns
A new opendal_stat_options with all options set to their defaults.
See also
opendal_stat_options_free

◆ opendal_stat_options_set_if_match()

void opendal_stat_options_set_if_match ( struct opendal_stat_options * opts,
const char * if_match )

Set if_match.

Stat only when the file has this exact ETag.

The condition succeeds when the file exists and its ETag equals this value. A file with a different ETag returns OPENDAL_CONDITION_NOT_MATCH; a missing file returns OPENDAL_NOT_FOUND. Only concrete ETag values are portable; a wildcard such as "*" has no portable meaning here.

The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.stat_with_if_match.

A non-NULL if_match must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_stat_with(), returns.

Parameters
optsThe opendal_stat_options to modify.
if_matchThe string to borrow; NULL unsets it.

◆ opendal_stat_options_set_if_modified_since()

void opendal_stat_options_set_if_modified_since ( struct opendal_stat_options * opts,
int64_t if_modified_since )

Set if_modified_since.

Stat only when the file was modified after this timestamp.

The condition succeeds when the file exists and was modified after this time. A file not modified since this time returns OPENDAL_CONDITION_NOT_MATCH; a missing file returns OPENDAL_NOT_FOUND.

The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.stat_with_if_modified_since.

The setter also sets has_if_modified_since. A value out of range fails the operation with OPENDAL_CONFIG_INVALID.

Parameters
optsThe opendal_stat_options to modify.
if_modified_sinceMilliseconds since the Unix epoch.

◆ opendal_stat_options_set_if_none_match()

void opendal_stat_options_set_if_none_match ( struct opendal_stat_options * opts,
const char * if_none_match )

Set if_none_match.

Stat only when the file does not have this ETag.

With a concrete ETag value, the condition succeeds when the file exists with a different ETag. A file whose ETag equals this value returns OPENDAL_CONDITION_NOT_MATCH; a missing file returns OPENDAL_NOT_FOUND. Only concrete ETag values are portable; a wildcard such as "*" has no portable meaning here.

The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.stat_with_if_none_match.

A non-NULL if_none_match must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_stat_with(), returns.

Parameters
optsThe opendal_stat_options to modify.
if_none_matchThe string to borrow; NULL unsets it.

◆ opendal_stat_options_set_if_unmodified_since()

void opendal_stat_options_set_if_unmodified_since ( struct opendal_stat_options * opts,
int64_t if_unmodified_since )

Set if_unmodified_since.

Stat only when the file was not modified after this timestamp.

The condition succeeds when the file exists and was not modified after this time. A file modified after this time returns OPENDAL_CONDITION_NOT_MATCH; a missing file returns OPENDAL_NOT_FOUND.

The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.stat_with_if_unmodified_since.

The setter also sets has_if_unmodified_since. A value out of range fails the operation with OPENDAL_CONFIG_INVALID.

Parameters
optsThe opendal_stat_options to modify.
if_unmodified_sinceMilliseconds since the Unix epoch.

◆ opendal_stat_options_set_override_cache_control()

void opendal_stat_options_set_override_cache_control ( struct opendal_stat_options * opts,
const char * override_cache_control )

Set override_cache_control.

Request a cache-control response header override from services that support it, including for presigned stat requests.

A non-NULL override_cache_control must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_stat_with(), returns.

Parameters
optsThe opendal_stat_options to modify.
override_cache_controlThe string to borrow; NULL unsets it.

◆ opendal_stat_options_set_override_content_disposition()

void opendal_stat_options_set_override_content_disposition ( struct opendal_stat_options * opts,
const char * override_content_disposition )

Set override_content_disposition.

Request a content-disposition response header override from services that support it, including for presigned stat requests.

A non-NULL override_content_disposition must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_stat_with(), returns.

Parameters
optsThe opendal_stat_options to modify.
override_content_dispositionThe string to borrow; NULL unsets it.

◆ opendal_stat_options_set_override_content_type()

void opendal_stat_options_set_override_content_type ( struct opendal_stat_options * opts,
const char * override_content_type )

Set override_content_type.

Request a content-type response header override from services that support it, including for presigned stat requests.

A non-NULL override_content_type must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_stat_with(), returns.

Parameters
optsThe opendal_stat_options to modify.
override_content_typeThe string to borrow; NULL unsets it.

◆ opendal_stat_options_set_version()

void opendal_stat_options_set_version ( struct opendal_stat_options * opts,
const char * version )

Set version.

Stat the given version of the file instead of the current one.

This selects which stored version the stat describes; it is not a condition on the file. A version that does not exist returns OPENDAL_NOT_FOUND.

Check opendal_capability.stat_with_version before using this option.

A non-NULL version must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_stat_with(), returns.

Parameters
optsThe opendal_stat_options to modify.
versionThe string to borrow; NULL unsets it.

◆ opendal_string_free()

void opendal_string_free ( char * ptr)

Frees a heap-allocated string returned by OpenDAL C APIs.

Note
Only pass pointers returned from OpenDAL APIs that transfer string ownership.

◆ opendal_write_options_free()

void opendal_write_options_free ( struct opendal_write_options * opts)

Free the heap memory used by opendal_write_options.

Parameters
optsThe opendal_write_options to free.

◆ opendal_write_options_new()

struct opendal_write_options * opendal_write_options_new ( void )

Construct a heap-allocated opendal_write_options with default values.

Returns
A new opendal_write_options with all options set to their defaults.
See also
opendal_write_options_free

◆ opendal_write_options_set_append()

void opendal_write_options_set_append ( struct opendal_write_options * opts,
bool append )

Set append.

Sets append mode for this operation.

Capability

Check opendal_capability.write_can_append before using this option.

Behavior

  • By default, write operations overwrite existing files
  • When append is set to true:
    • New data will be appended to the end of existing file
    • If file doesn't exist, it will be created
  • If not supported, will return an error

This operation allows adding data to existing files instead of overwriting them.

Parameters
optsThe opendal_write_options to modify.
appendThe value to set.

◆ opendal_write_options_set_cache_control()

void opendal_write_options_set_cache_control ( struct opendal_write_options * opts,
const char * cache_control )

Set cache_control.

Sets Cache-Control header for this write operation.

Capability

Check opendal_capability.write_with_cache_control before using this feature.

Behavior

  • If supported, sets Cache-Control as system metadata on the target file
  • The value should follow HTTP Cache-Control header format
  • If not supported, the value will be ignored

This operation allows controlling caching behavior for the written content.

Use Cases

  • Setting browser cache duration
  • Configuring CDN behavior
  • Optimizing content delivery
  • Managing cache invalidation

References

A non-NULL cache_control must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_write_with(), returns.

Parameters
optsThe opendal_write_options to modify.
cache_controlThe string to borrow; NULL unsets it.

◆ opendal_write_options_set_chunk()

void opendal_write_options_set_chunk ( struct opendal_write_options * opts,
uintptr_t chunk )

Set chunk.

Sets chunk size for buffered writes.

Capability

Check opendal_capability.write_multi_min_size and opendal_capability.write_multi_max_size for size limits.

Behavior

  • By default, OpenDAL buffers data until it reaches the service's opendal_capability.write_multi_min_size and then writes everything buffered at once; a service without that minimum receives each write as it arrives
  • 0 has the same behavior as leaving it unset
  • When chunk size is set:
    • Data will be buffered until reaching chunk size
    • Each chunk reaches the service writer as one write; a service may add requests, such as the ones that start and complete an S3 multipart upload
    • Last chunk may be smaller than chunk size
  • Important considerations:

Performance Impact

Setting appropriate chunk size can:

  • Reduce number of API calls
  • Improve overall throughput
  • Lower operation costs
  • Better utilize network bandwidth

The setter also sets has_chunk.

Parameters
optsThe opendal_write_options to modify.
chunkThe value to set.

◆ opendal_write_options_set_concurrent()

void opendal_write_options_set_concurrent ( struct opendal_write_options * opts,
uintptr_t concurrent )

Set concurrent.

Sets concurrent write operations for this writer.

Behavior

  • By default, OpenDAL writes files sequentially
  • 0 has the same behavior as 1
  • When concurrent is greater than 1:
    • Multiple write operations can execute in parallel
    • Write operations return immediately without waiting if tasks space are available
    • Close operation ensures all writes complete in order
    • Memory usage increases with concurrency level
  • If not supported, falls back to sequential writes

opendal_operator_write_with() without chunk passes the whole buffer to the service writer as one write. A service that splits the buffer internally, such as fs with direct_io on Linux, can write the parts concurrently.

This feature significantly improves performance when:

  • Writing large files
  • Network latency is high
  • Storage service supports concurrent uploads like multipart uploads

Performance Impact

Setting appropriate concurrency can:

  • Increase write throughput
  • Reduce total write time
  • Better utilize available bandwidth
  • Trade memory for performance
Parameters
optsThe opendal_write_options to modify.
concurrentThe value to set; 0 is the default.

◆ opendal_write_options_set_content_disposition()

void opendal_write_options_set_content_disposition ( struct opendal_write_options * opts,
const char * content_disposition )

Set content_disposition.

Sets Content-Disposition header for this write request.

Capability

Check opendal_capability.write_with_content_disposition before using this feature.

Behavior

  • If supported, sets Content-Disposition as system metadata on the target file
  • The value should follow HTTP Content-Disposition header format
  • Common values include:
    • inline - Content displayed within browser
    • attachment - Content downloaded as file
    • attachment; filename="example.jpg" - Downloaded with specified filename
  • If not supported, the value will be ignored

This operation allows controlling how the content should be displayed or downloaded.

A non-NULL content_disposition must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_write_with(), returns.

Parameters
optsThe opendal_write_options to modify.
content_dispositionThe string to borrow; NULL unsets it.

◆ opendal_write_options_set_content_encoding()

void opendal_write_options_set_content_encoding ( struct opendal_write_options * opts,
const char * content_encoding )

Set content_encoding.

Sets Content-Encoding header for this write request.

Capability

Check opendal_capability.write_with_content_encoding before using this feature.

Behavior

  • If supported, sets Content-Encoding as system metadata on the target file
  • The value should follow HTTP Content-Encoding header format
  • Common values include:
    • gzip - Content encoded using gzip compression
    • deflate - Content encoded using deflate compression
    • br - Content encoded using Brotli compression
    • identity - No encoding applied (default value)
  • If not supported, the value will be ignored

This operation allows specifying the encoding applied to the content being written.

A non-NULL content_encoding must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_write_with(), returns.

Parameters
optsThe opendal_write_options to modify.
content_encodingThe string to borrow; NULL unsets it.

◆ opendal_write_options_set_content_type()

void opendal_write_options_set_content_type ( struct opendal_write_options * opts,
const char * content_type )

Set content_type.

Sets Content-Type header for this write operation.

Capability

Check opendal_capability.write_with_content_type before using this feature.

Behavior

  • If supported, sets Content-Type as system metadata on the target file
  • The value should follow MIME type format (e.g. "text/plain", "image/jpeg")
  • If not supported, the value will be ignored

This operation allows specifying the media type of the content being written.

A non-NULL content_type must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_write_with(), returns.

Parameters
optsThe opendal_write_options to modify.
content_typeThe string to borrow; NULL unsets it.

◆ opendal_write_options_set_if_match()

void opendal_write_options_set_if_match ( struct opendal_write_options * opts,
const char * if_match )

Set if_match.

Write only when the file at the write path has this exact ETag.

The condition succeeds when the file exists and its ETag equals this value. A file with a different ETag, or a missing file, fails the write with OPENDAL_CONDITION_NOT_MATCH. Only concrete ETag values are portable; a wildcard such as "*" has no portable meaning here.

The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.write_with_if_match.

A non-NULL if_match must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_write_with(), returns.

Parameters
optsThe opendal_write_options to modify.
if_matchThe string to borrow; NULL unsets it.

◆ opendal_write_options_set_if_none_match()

void opendal_write_options_set_if_none_match ( struct opendal_write_options * opts,
const char * if_none_match )

Set if_none_match.

Write only when the file at the write path does not have this ETag.

With a concrete ETag value, the condition succeeds when the file has a different ETag or does not exist; the write then replaces or creates the file. A file whose ETag equals this value fails the write with OPENDAL_CONDITION_NOT_MATCH. Only concrete ETag values are portable; a wildcard such as "*" has no portable meaning here.

The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.write_with_if_none_match. Some services, such as s3, support if_not_exists but not if_none_match; use if_not_exists when you only need to guard against an existing file.

A non-NULL if_none_match must point to a readable, nul-terminated UTF-8 string. The setter stores it without copying it, so the string must stay valid until a function that takes opts, such as opendal_operator_write_with(), returns.

Parameters
optsThe opendal_write_options to modify.
if_none_matchThe string to borrow; NULL unsets it.

◆ opendal_write_options_set_if_not_exists()

void opendal_write_options_set_if_not_exists ( struct opendal_write_options * opts,
bool if_not_exists )

Set if_not_exists.

Write only when no file exists at the write path.

The condition succeeds when the path is empty, so the write creates the file. An existing file fails the write with OPENDAL_CONDITION_NOT_MATCH.

The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.write_with_if_not_exists.

Parameters
optsThe opendal_write_options to modify.
if_not_existsThe value to set.

◆ opendal_write_options_set_user_metadata()

void opendal_write_options_set_user_metadata ( struct opendal_write_options * opts,
const struct opendal_write_user_metadata_pair * pairs,
uintptr_t len )

Set user_metadata.

Sets user metadata for this write request.

Capability

Check opendal_capability.write_with_user_metadata before using this feature.

Behavior

  • If supported, the user metadata will be attached to the object during write
  • Accepts key-value pairs where both key and value are strings
  • Some services, such as s3, return keys in lowercase
  • Services may have limitations for user metadata, for example:
    • Key length is typically limited (e.g., 1024 bytes)
    • Value length is typically limited (e.g., 4096 bytes)
    • Total metadata size might be limited
    • Some characters might be forbidden in keys
  • If not supported, the metadata will be ignored

User metadata provides a way to attach custom metadata to objects during write operations. When the service exposes user metadata, opendal_metadata_get_user_metadata() on the result of a later opendal_operator_stat() returns it.

The setter stores pairs without copying the pairs or their strings, so they must stay valid until a function that takes opts, such as opendal_operator_write_with(), returns. A pair whose key or value is NULL is skipped, and a later pair replaces an earlier pair with the same key.

Parameters
optsThe opendal_write_options to modify.
pairsThe pairs to borrow; NULL unsets it.
lenThe number of pairs at pairs; 0 unsets it.

◆ opendal_writer_close()

struct opendal_error * opendal_writer_close ( struct opendal_writer * ptr)

Close the writer and make sure all data have been stored.

◆ opendal_writer_close_with_cancel()

struct opendal_error * opendal_writer_close_with_cancel ( struct opendal_writer * ptr,
const struct opendal_cancel_token * cancel,
struct opendal_metadata ** meta )

Close the writer, supporting cancellation via cancel and optional metadata output.

Pass NULL for cancel to run without cancellation. Pass NULL for meta to discard the written object's metadata; when non-null, *meta receives the allocated opendal_metadata * on success or NULL on cancellation or failure.

If cancelled mid-flight, the finalization state on the backend is unknown; release the handle with opendal_writer_free and start a new writer instead of continuing to write or close, which can duplicate or corrupt data on streaming or append backends.

Parameters
ptrThe opendal_writer to close (NULL is a no-op returning NULL)
cancelOptional cancel token, or NULL
metaOptional output pointer for the written object's metadata, or NULL
Returns
NULL on success, or an opendal_error * on cancellation or failure.

◆ opendal_writer_close_with_metadata()

struct opendal_error * opendal_writer_close_with_metadata ( struct opendal_writer * ptr,
struct opendal_metadata ** meta )

Close the writer and write the written object's metadata to *meta.

Like opendal_writer_close, but on success writes the metadata of the written object (e.g. etag, version, last modified) to *meta instead of discarding it.

Parameters
ptrThe opendal_writer to close
metaOutput pointer receiving the allocated opendal_metadata * on success, or NULL on failure
Returns
NULL on success, or an opendal_error * on failure.
Note
The returned metadata must be freed with opendal_metadata_free().

◆ opendal_writer_free()

void opendal_writer_free ( struct opendal_writer * ptr)

Frees the heap memory used by the opendal_writer.

◆ opendal_writer_write()

struct opendal_error * opendal_writer_write ( struct opendal_writer * self,
const struct opendal_bytes * bytes,
uintptr_t * size )

Write data to the writer and write the number of bytes written to *size.

On failure, writes 0 to *size and returns an opendal_error *.

◆ opendal_writer_write_with_cancel()

struct opendal_error * opendal_writer_write_with_cancel ( struct opendal_writer * self,
const struct opendal_bytes * bytes,
const struct opendal_cancel_token * cancel,
uintptr_t * size )

Write data to the writer, supporting cancellation via cancel.

Pass NULL for cancel to run without cancellation. On cancellation or failure, writes 0 to *size and returns an opendal_error * (OPENDAL_CANCELLED on cancellation).

If cancelled mid-flight, the backend may already have accepted part or all of the write; release the handle with opendal_writer_free and start a new writer instead of continuing to write or close, which can duplicate or corrupt data on streaming or append backends.