Apache OpenDALâ„¢ C Binding
The C binding for Apache OpenDALâ„¢
opendal.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 
21 #ifndef _OPENDAL_H
22 #define _OPENDAL_H
23 
24 #include <stdint.h>
25 #include <stddef.h>
26 #include <stdbool.h>
27 
33 typedef enum opendal_code {
75 
85 typedef struct BlockingLister BlockingLister;
86 
145 typedef struct BlockingOperator BlockingOperator;
146 
188 typedef struct Entry Entry;
189 
190 typedef struct HashMap_String__String HashMap_String__String;
191 
201 typedef struct Metadata Metadata;
202 
206 typedef struct OperatorInfo OperatorInfo;
207 
215 typedef struct StdReader StdReader;
216 
226 typedef struct opendal_bytes {
230  const uint8_t *data;
234  uintptr_t len;
235 } opendal_bytes;
236 
256 typedef struct opendal_error {
257  enum opendal_code code;
258  struct opendal_bytes message;
259 } opendal_error;
260 
269 typedef struct opendal_entry {
270  struct Entry *inner;
271 } opendal_entry;
272 
280 typedef struct opendal_result_lister_next {
284  struct opendal_entry *entry;
288  struct opendal_error *error;
289 } opendal_result_lister_next;
290 
300 typedef struct opendal_lister {
301  struct BlockingLister *inner;
302 } opendal_lister;
303 
315 typedef struct opendal_metadata {
320  struct Metadata *inner;
321 } opendal_metadata;
322 
336 typedef struct opendal_operator {
341  const struct BlockingOperator *ptr;
342 } opendal_operator;
343 
356 typedef struct opendal_result_operator_new {
360  struct opendal_operator *op;
364  struct opendal_error *error;
365 } opendal_result_operator_new;
366 
377 typedef struct opendal_operator_options {
382  struct HashMap_String__String *inner;
383 } opendal_operator_options;
384 
393 typedef struct opendal_result_read {
397  struct opendal_bytes *data;
401  struct opendal_error *error;
402 } opendal_result_read;
403 
410 typedef struct opendal_reader {
411  struct StdReader *inner;
412 } opendal_reader;
413 
420 typedef struct opendal_result_operator_reader {
424  struct opendal_reader *reader;
428  struct opendal_error *error;
429 } opendal_result_operator_reader;
430 
441 typedef struct opendal_result_is_exist {
445  bool is_exist;
449  struct opendal_error *error;
450 } opendal_result_is_exist;
451 
459 typedef struct opendal_result_stat {
463  struct opendal_metadata *meta;
467  struct opendal_error *error;
468 } opendal_result_stat;
469 
477 typedef struct opendal_result_list {
481  struct opendal_lister *lister;
485  struct opendal_error *error;
486 } opendal_result_list;
487 
492 typedef struct opendal_operator_info {
493  struct OperatorInfo *inner;
494 } opendal_operator_info;
495 
500 typedef struct opendal_capability {
504  bool stat;
508  bool stat_with_if_match;
512  bool stat_with_if_none_match;
516  bool read;
520  bool read_with_if_match;
524  bool read_with_if_none_match;
528  bool read_with_override_cache_control;
532  bool read_with_override_content_disposition;
536  bool read_with_override_content_type;
540  bool write;
544  bool write_can_multi;
548  bool write_can_empty;
552  bool write_can_append;
556  bool write_with_content_type;
560  bool write_with_content_disposition;
564  bool write_with_cache_control;
572  uintptr_t write_multi_max_size;
580  uintptr_t write_multi_min_size;
588  uintptr_t write_multi_align_size;
596  uintptr_t write_total_max_size;
600  bool create_dir;
604  bool delete_;
608  bool copy;
612  bool rename;
616  bool list;
620  bool list_with_limit;
624  bool list_with_start_after;
628  bool list_with_recursive;
632  bool presign;
636  bool presign_read;
640  bool presign_stat;
644  bool presign_write;
648  bool batch;
652  bool batch_delete;
658  uintptr_t batch_max_operations;
662  bool blocking;
663 } opendal_capability;
664 
670 typedef struct opendal_result_reader_read {
674  uintptr_t size;
678  struct opendal_error *error;
679 } opendal_result_reader_read;
680 
681 #ifdef __cplusplus
682 extern "C" {
683 #endif // __cplusplus
684 
688 void opendal_error_free(struct opendal_error *ptr);
689 
699 struct opendal_result_lister_next opendal_lister_next(const struct opendal_lister *self);
700 
704 void opendal_lister_free(const struct opendal_lister *p);
705 
709 void opendal_metadata_free(struct opendal_metadata *ptr);
710 
724 uint64_t opendal_metadata_content_length(const struct opendal_metadata *self);
725 
739 bool opendal_metadata_is_file(const struct opendal_metadata *self);
740 
759 bool opendal_metadata_is_dir(const struct opendal_metadata *self);
760 
774 int64_t opendal_metadata_last_modified_ms(const struct opendal_metadata *self);
775 
793 void opendal_operator_free(const struct opendal_operator *op);
794 
834 struct opendal_result_operator_new opendal_operator_new(const char *scheme,
835  const struct opendal_operator_options *options);
836 
883 struct opendal_error *opendal_operator_write(const struct opendal_operator *op,
884  const char *path,
885  struct opendal_bytes bytes);
886 
927 struct opendal_result_read opendal_operator_read(const struct opendal_operator *op,
928  const char *path);
929 
968 struct opendal_result_operator_reader opendal_operator_reader(const struct opendal_operator *op,
969  const char *path);
970 
1013 struct opendal_error *opendal_operator_delete(const struct opendal_operator *op, const char *path);
1014 
1054 struct opendal_result_is_exist opendal_operator_is_exist(const struct opendal_operator *op,
1055  const char *path);
1056 
1095 struct opendal_result_stat opendal_operator_stat(const struct opendal_operator *op,
1096  const char *path);
1097 
1148 struct opendal_result_list opendal_operator_list(const struct opendal_operator *op,
1149  const char *path);
1150 
1186 struct opendal_error *opendal_operator_create_dir(const struct opendal_operator *op,
1187  const char *path);
1188 
1232 struct opendal_error *opendal_operator_rename(const struct opendal_operator *op,
1233  const char *src,
1234  const char *dest);
1235 
1279 struct opendal_error *opendal_operator_copy(const struct opendal_operator *op,
1280  const char *src,
1281  const char *dest);
1282 
1301 struct opendal_operator_info *opendal_operator_info_new(const struct opendal_operator *op);
1302 
1306 void opendal_operator_info_free(struct opendal_operator_info *ptr);
1307 
1313 char *opendal_operator_info_get_scheme(const struct opendal_operator_info *self);
1314 
1320 char *opendal_operator_info_get_root(const struct opendal_operator_info *self);
1321 
1328 char *opendal_operator_info_get_name(const struct opendal_operator_info *self);
1329 
1333 struct opendal_capability opendal_operator_info_get_full_capability(const struct opendal_operator_info *self);
1334 
1338 struct opendal_capability opendal_operator_info_get_native_capability(const struct opendal_operator_info *self);
1339 
1343 void opendal_bytes_free(struct opendal_bytes *bs);
1344 
1353 struct opendal_operator_options *opendal_operator_options_new(void);
1354 
1374 void opendal_operator_options_set(struct opendal_operator_options *self,
1375  const char *key,
1376  const char *value);
1377 
1381 void opendal_operator_options_free(const struct opendal_operator_options *options);
1382 
1390 char *opendal_entry_path(const struct opendal_entry *self);
1391 
1401 char *opendal_entry_name(const struct opendal_entry *self);
1402 
1406 void opendal_entry_free(struct opendal_entry *ptr);
1407 
1411 struct opendal_result_reader_read opendal_reader_read(const struct opendal_reader *reader,
1412  uint8_t *buf,
1413  uintptr_t len);
1414 
1418 void opendal_reader_free(struct opendal_reader *ptr);
1419 
1420 #ifdef __cplusplus
1421 } // extern "C"
1422 #endif // __cplusplus
1423 
1424 #endif /* _OPENDAL_H */
struct BlockingLister BlockingLister
Definition: opendal.h:85
opendal_code
The error code for all opendal APIs in C binding.
Definition: opendal.h:33
@ OPENDAL_UNSUPPORTED
Definition: opendal.h:41
@ OPENDAL_NOT_FOUND
Definition: opendal.h:49
@ OPENDAL_IS_A_DIRECTORY
Definition: opendal.h:57
@ OPENDAL_UNEXPECTED
Definition: opendal.h:37
@ OPENDAL_PERMISSION_DENIED
Definition: opendal.h:53
@ OPENDAL_ALREADY_EXISTS
Definition: opendal.h:65
@ OPENDAL_IS_SAME_FILE
Definition: opendal.h:73
@ OPENDAL_NOT_A_DIRECTORY
Definition: opendal.h:61
@ OPENDAL_RATE_LIMITED
Definition: opendal.h:69
@ OPENDAL_CONFIG_INVALID
Definition: opendal.h:45