1#![doc(html_logo_url = "https://opendal.apache.org/img/logo.svg")]
19#![doc = include_str!("../README.md")]
20#![cfg_attr(docsrs, feature(doc_cfg))]
21#![cfg_attr(docsrs, doc(auto_cfg))]
22#![deny(missing_docs)]
23
24pub use opendal_core::*;
25
26pub mod executors {
28 #[cfg(all(feature = "executors-compio", not(target_arch = "wasm32")))]
29 pub use opendal_executor_compio::CompioExecutor;
30 #[cfg(feature = "executors-tokio")]
31 pub use opendal_executor_tokio::TokioExecutor;
32}
33
34#[cfg(any(
35 feature = "http-transport-cyper-native-tls",
36 feature = "http-transport-cyper-rustls"
37))]
38pub use opendal_http_transport_cyper::CyperTransport;
39
40#[cfg(feature = "tests")]
41pub extern crate opendal_testkit as tests;
42
43pub fn install_default() {
68 static DEFAULTS_INIT: std::sync::Once = std::sync::Once::new();
69 DEFAULTS_INIT.call_once(|| {
70 init_default_registry();
71
72 #[cfg(feature = "executors-tokio")]
73 opendal_executor_tokio::install_default();
74
75 #[cfg(any(
76 feature = "http-transport-reqwest",
77 feature = "http-transport-reqwest-native-tls",
78 feature = "http-transport-reqwest-rustls",
79 feature = "http-transport-reqwest-rustls-no-provider"
80 ))]
81 {
82 opendal_http_transport_reqwest::install_default();
83 opendal_http_transport_reqwest::register_http_context(OperatorRegistry::get());
84 }
85 });
86}
87
88#[cfg(all(
89 test,
90 feature = "auto-register-services",
91 feature = "executors-tokio",
92 not(target_arch = "wasm32")
93))]
94mod default_executor_tests {
95 #[tokio::test]
96 async fn default_executor_runs_concurrent_reads() -> crate::Result<()> {
97 let op = crate::Operator::via_iter("memory", [])?;
98 op.write("file", "abcdefgh").await?;
99 let content = op
100 .read_with("file")
101 .range(0..8)
102 .chunk(2)
103 .concurrent(2)
104 .await?;
105 assert_eq!(content.to_bytes(), "abcdefgh");
106 Ok(())
107 }
108}
109
110pub fn init_default_registry() {
130 static DEFAULT_REGISTRY_INIT: std::sync::Once = std::sync::Once::new();
131 DEFAULT_REGISTRY_INIT.call_once(|| init_default_registry_inner(OperatorRegistry::get()));
132}
133
134fn init_default_registry_inner(registry: &OperatorRegistry) {
135 opendal_core::services::register_memory_service(registry);
136
137 #[cfg(feature = "services-aliyun-drive")]
138 opendal_service_aliyun_drive::register_aliyun_drive_service(registry);
139
140 #[cfg(feature = "services-azblob")]
141 opendal_service_azblob::register_azblob_service(registry);
142
143 #[cfg(feature = "services-azdls")]
144 opendal_service_azdls::register_azdls_service(registry);
145
146 #[cfg(feature = "services-azfile")]
147 opendal_service_azfile::register_azfile_service(registry);
148
149 #[cfg(feature = "services-b2")]
150 opendal_service_b2::register_b2_service(registry);
151
152 #[cfg(feature = "services-b2-s3")]
153 opendal_service_s3::register_b2_s3_service(registry);
154
155 #[cfg(feature = "services-cacache")]
156 opendal_service_cacache::register_cacache_service(registry);
157
158 #[cfg(feature = "services-cloudflare-kv")]
159 opendal_service_cloudflare_kv::register_cloudflare_kv_service(registry);
160
161 #[cfg(feature = "services-compfs")]
162 opendal_service_compfs::register_compfs_service(registry);
163
164 #[cfg(feature = "services-cos")]
165 opendal_service_cos::register_cos_service(registry);
166
167 #[cfg(feature = "services-cos-s3")]
168 opendal_service_s3::register_cos_s3_service(registry);
169
170 #[cfg(feature = "services-d1")]
171 opendal_service_d1::register_d1_service(registry);
172
173 #[cfg(feature = "services-dashmap")]
174 opendal_service_dashmap::register_dashmap_service(registry);
175
176 #[cfg(feature = "services-dbfs")]
177 opendal_service_dbfs::register_dbfs_service(registry);
178
179 #[cfg(feature = "services-dropbox")]
180 opendal_service_dropbox::register_dropbox_service(registry);
181
182 #[cfg(feature = "services-etcd")]
183 opendal_service_etcd::register_etcd_service(registry);
184
185 #[cfg(feature = "services-foundationdb")]
186 opendal_service_foundationdb::register_foundationdb_service(registry);
187
188 #[cfg(feature = "services-foyer")]
189 opendal_service_foyer::register_foyer_service(registry);
190
191 #[cfg(feature = "services-fs")]
192 opendal_service_fs::register_fs_service(registry);
193
194 #[cfg(feature = "services-ftp")]
195 opendal_service_ftp::register_ftp_service(registry);
196
197 #[cfg(feature = "services-gcs")]
198 opendal_service_gcs::register_gcs_service(registry);
199
200 #[cfg(feature = "services-gcs-s3")]
201 opendal_service_s3::register_gcs_s3_service(registry);
202
203 #[cfg(feature = "services-gcs-grpc")]
204 opendal_service_gcs_grpc::register_gcs_grpc_service(registry);
205
206 #[cfg(feature = "services-gdrive")]
207 opendal_service_gdrive::register_gdrive_service(registry);
208
209 #[cfg(feature = "services-ghac")]
210 opendal_service_ghac::register_ghac_service(registry);
211
212 #[cfg(feature = "services-git")]
213 opendal_service_git::register_git_service(registry);
214
215 #[cfg(feature = "services-github")]
216 opendal_service_github::register_github_service(registry);
217
218 #[cfg(feature = "services-goosefs")]
219 opendal_service_goosefs::register_goosefs_service(registry);
220
221 #[cfg(feature = "services-gridfs")]
222 opendal_service_gridfs::register_gridfs_service(registry);
223
224 #[cfg(feature = "services-hdfs")]
225 opendal_service_hdfs::register_hdfs_service(registry);
226
227 #[cfg(feature = "services-hdfs-native")]
228 opendal_service_hdfs_native::register_hdfs_native_service(registry);
229
230 #[cfg(feature = "services-http")]
231 opendal_service_http::register_http_service(registry);
232
233 #[cfg(feature = "services-hf")]
234 opendal_service_hf::register_hf_service(registry);
235
236 #[cfg(all(feature = "services-hf3fs", target_os = "linux"))]
237 opendal_service_hf3fs::register_hf3fs_service(registry);
238
239 #[cfg(feature = "services-ipfs")]
240 opendal_service_ipfs::register_ipfs_service(registry);
241
242 #[cfg(feature = "services-ipmfs")]
243 opendal_service_ipmfs::register_ipmfs_service(registry);
244
245 #[cfg(feature = "services-koofr")]
246 opendal_service_koofr::register_koofr_service(registry);
247
248 #[cfg(feature = "services-lakefs")]
249 opendal_service_lakefs::register_lakefs_service(registry);
250
251 #[cfg(feature = "services-lakefs-s3")]
252 opendal_service_s3::register_lakefs_s3_service(registry);
253
254 #[cfg(feature = "services-memcached")]
255 opendal_service_memcached::register_memcached_service(registry);
256
257 #[cfg(feature = "services-mini-moka")]
258 opendal_service_mini_moka::register_mini_moka_service(registry);
259
260 #[cfg(feature = "services-moka")]
261 opendal_service_moka::register_moka_service(registry);
262
263 #[cfg(feature = "services-mongodb")]
264 opendal_service_mongodb::register_mongodb_service(registry);
265
266 #[cfg(feature = "services-monoiofs")]
267 opendal_service_monoiofs::register_monoiofs_service(registry);
268
269 #[cfg(feature = "services-mysql")]
270 opendal_service_mysql::register_mysql_service(registry);
271
272 #[cfg(feature = "services-obs")]
273 opendal_service_obs::register_obs_service(registry);
274
275 #[cfg(feature = "services-obs-s3")]
276 opendal_service_s3::register_obs_s3_service(registry);
277
278 #[cfg(feature = "services-onedrive")]
279 opendal_service_onedrive::register_onedrive_service(registry);
280
281 #[cfg(feature = "services-oss")]
282 opendal_service_oss::register_oss_service(registry);
283
284 #[cfg(feature = "services-oss-s3")]
285 opendal_service_s3::register_oss_s3_service(registry);
286
287 #[cfg(feature = "services-pcloud")]
288 opendal_service_pcloud::register_pcloud_service(registry);
289
290 #[cfg(feature = "services-persy")]
291 opendal_service_persy::register_persy_service(registry);
292
293 #[cfg(feature = "services-postgresql")]
294 opendal_service_postgresql::register_postgresql_service(registry);
295
296 #[cfg(feature = "services-redb")]
297 opendal_service_redb::register_redb_service(registry);
298
299 #[cfg(feature = "services-remotestorage")]
300 opendal_service_remotestorage::register_remotestorage_service(registry);
301
302 #[cfg(feature = "services-rocksdb")]
303 opendal_service_rocksdb::register_rocksdb_service(registry);
304
305 #[cfg(feature = "services-s3")]
306 opendal_service_s3::register_s3_service(registry);
307
308 #[cfg(feature = "services-r2")]
309 opendal_service_s3::register_r2_service(registry);
310
311 #[cfg(feature = "services-minio")]
312 opendal_service_s3::register_minio_service(registry);
313
314 #[cfg(feature = "services-akamai")]
315 opendal_service_s3::register_akamai_service(registry);
316
317 #[cfg(feature = "services-ceph-rgw")]
318 opendal_service_s3::register_ceph_rgw_service(registry);
319
320 #[cfg(feature = "services-exoscale")]
321 opendal_service_s3::register_exoscale_service(registry);
322
323 #[cfg(feature = "services-garage")]
324 opendal_service_s3::register_garage_service(registry);
325
326 #[cfg(feature = "services-hetzner")]
327 opendal_service_s3::register_hetzner_service(registry);
328
329 #[cfg(feature = "services-ibm-cos")]
330 opendal_service_s3::register_ibm_cos_service(registry);
331
332 #[cfg(feature = "services-idrive-e2")]
333 opendal_service_s3::register_idrive_e2_service(registry);
334
335 #[cfg(feature = "services-ionos")]
336 opendal_service_s3::register_ionos_service(registry);
337
338 #[cfg(feature = "services-neon")]
339 opendal_service_s3::register_neon_service(registry);
340
341 #[cfg(feature = "services-oci")]
342 opendal_service_s3::register_oci_service(registry);
343
344 #[cfg(feature = "services-ovhcloud")]
345 opendal_service_s3::register_ovhcloud_service(registry);
346
347 #[cfg(feature = "services-qingstor")]
348 opendal_service_s3::register_qingstor_service(registry);
349
350 #[cfg(feature = "services-rustfs")]
351 opendal_service_s3::register_rustfs_service(registry);
352
353 #[cfg(feature = "services-scaleway")]
354 opendal_service_s3::register_scaleway_service(registry);
355
356 #[cfg(feature = "services-seaweedfs")]
357 opendal_service_s3::register_seaweedfs_service(registry);
358
359 #[cfg(feature = "services-spaces")]
360 opendal_service_s3::register_spaces_service(registry);
361
362 #[cfg(feature = "services-storj")]
363 opendal_service_s3::register_storj_service(registry);
364
365 #[cfg(feature = "services-supabase")]
366 opendal_service_s3::register_supabase_service(registry);
367
368 #[cfg(feature = "services-tigris")]
369 opendal_service_s3::register_tigris_service(registry);
370
371 #[cfg(feature = "services-wasabi")]
372 opendal_service_s3::register_wasabi_service(registry);
373
374 #[cfg(feature = "services-seafile")]
375 opendal_service_seafile::register_seafile_service(registry);
376
377 #[cfg(feature = "services-sftp")]
378 opendal_service_sftp::register_sftp_service(registry);
379
380 #[cfg(feature = "services-sled")]
381 opendal_service_sled::register_sled_service(registry);
382
383 #[cfg(feature = "services-sqlite")]
384 opendal_service_sqlite::register_sqlite_service(registry);
385
386 #[cfg(feature = "services-surrealdb")]
387 opendal_service_surrealdb::register_surrealdb_service(registry);
388
389 #[cfg(feature = "services-swift")]
390 opendal_service_swift::register_swift_service(registry);
391
392 #[cfg(feature = "services-swift-s3api")]
393 opendal_service_s3::register_swift_s3api_service(registry);
394
395 #[cfg(feature = "services-tikv")]
396 opendal_service_tikv::register_tikv_service(registry);
397
398 #[cfg(feature = "services-tos")]
399 opendal_service_tos::register_tos_service(registry);
400
401 #[cfg(feature = "services-tos-s3")]
402 opendal_service_s3::register_tos_s3_service(registry);
403
404 #[cfg(feature = "services-upyun")]
405 opendal_service_upyun::register_upyun_service(registry);
406
407 #[cfg(feature = "services-vercel-artifacts")]
408 opendal_service_vercel_artifacts::register_vercel_artifacts_service(registry);
409
410 #[cfg(feature = "services-vercel-blob")]
411 opendal_service_vercel_blob::register_vercel_blob_service(registry);
412
413 #[cfg(feature = "services-webdav")]
414 opendal_service_webdav::register_webdav_service(registry);
415
416 #[cfg(feature = "services-webhdfs")]
417 opendal_service_webhdfs::register_webhdfs_service(registry);
418
419 #[cfg(feature = "services-yandex-disk")]
420 opendal_service_yandex_disk::register_yandex_disk_service(registry);
421
422 #[cfg(all(target_arch = "wasm32", feature = "services-opfs"))]
423 opendal_service_opfs::register_opfs_service(registry);
424
425 #[cfg(any(feature = "services-redis", feature = "services-redis-native-tls"))]
426 opendal_service_redis::register_redis_service(registry);
427
428 #[cfg(feature = "layers-chaos")]
429 opendal_layer_chaos::register_chaos_layer(registry);
430
431 #[cfg(feature = "layers-concurrent-limit")]
432 opendal_layer_concurrent_limit::register_concurrent_limit_layer(registry);
433
434 #[cfg(feature = "layers-logging")]
435 opendal_layer_logging::register_logging_layer(registry);
436
437 #[cfg(feature = "layers-mime-guess")]
438 opendal_layer_mime_guess::register_mime_guess_layer(registry);
439
440 #[cfg(feature = "layers-retry")]
441 opendal_layer_retry::register_retry_layer(registry);
442
443 #[cfg(feature = "layers-throttle")]
444 opendal_layer_throttle::register_throttle_layer(registry);
445
446 #[cfg(feature = "layers-timeout")]
447 opendal_layer_timeout::register_timeout_layer(registry);
448
449 #[cfg(feature = "layers-tracing")]
450 opendal_layer_tracing::register_tracing_layer(registry);
451}
452
453#[cfg(feature = "auto-register-services")]
454#[ctor::ctor(unsafe)]
455fn register_default_operator_registry() {
456 install_default();
457}
458
459pub mod services {
469 pub use opendal_core::services::*;
470 #[cfg(feature = "services-aliyun-drive")]
471 pub use opendal_service_aliyun_drive::*;
472 #[cfg(feature = "services-azblob")]
473 pub use opendal_service_azblob::*;
474 #[cfg(feature = "services-azdls")]
475 pub use opendal_service_azdls::*;
476 #[cfg(feature = "services-azfile")]
477 pub use opendal_service_azfile::*;
478 #[cfg(feature = "services-b2")]
479 pub use opendal_service_b2::*;
480 #[cfg(feature = "services-cacache")]
481 pub use opendal_service_cacache::*;
482 #[cfg(feature = "services-cloudflare-kv")]
483 pub use opendal_service_cloudflare_kv::*;
484 #[cfg(feature = "services-compfs")]
485 pub use opendal_service_compfs::*;
486 #[cfg(feature = "services-cos")]
487 pub use opendal_service_cos::*;
488 #[cfg(feature = "services-d1")]
489 pub use opendal_service_d1::*;
490 #[cfg(feature = "services-dashmap")]
491 pub use opendal_service_dashmap::*;
492 #[cfg(feature = "services-dbfs")]
493 pub use opendal_service_dbfs::*;
494 #[cfg(feature = "services-dropbox")]
495 pub use opendal_service_dropbox::*;
496 #[cfg(feature = "services-etcd")]
497 pub use opendal_service_etcd::*;
498 #[cfg(feature = "services-foundationdb")]
499 pub use opendal_service_foundationdb::*;
500 #[cfg(feature = "services-foyer")]
501 pub use opendal_service_foyer::*;
502 #[cfg(feature = "services-fs")]
503 pub use opendal_service_fs::*;
504 #[cfg(feature = "services-ftp")]
505 pub use opendal_service_ftp::*;
506 #[cfg(feature = "services-gcs")]
507 pub use opendal_service_gcs::*;
508 #[cfg(feature = "services-gcs-grpc")]
509 pub use opendal_service_gcs_grpc::*;
510 #[cfg(feature = "services-gdrive")]
511 pub use opendal_service_gdrive::*;
512 #[cfg(feature = "services-ghac")]
513 pub use opendal_service_ghac::*;
514 #[cfg(feature = "services-git")]
515 pub use opendal_service_git::*;
516 #[cfg(feature = "services-github")]
517 pub use opendal_service_github::*;
518 #[cfg(feature = "services-goosefs")]
519 pub use opendal_service_goosefs::*;
520 #[cfg(feature = "services-gridfs")]
521 pub use opendal_service_gridfs::*;
522 #[cfg(feature = "services-hdfs")]
523 pub use opendal_service_hdfs::*;
524 #[cfg(feature = "services-hdfs-native")]
525 pub use opendal_service_hdfs_native::*;
526 #[cfg(feature = "services-hf")]
527 pub use opendal_service_hf::*;
528 #[cfg(all(feature = "services-hf3fs", target_os = "linux"))]
529 pub use opendal_service_hf3fs::*;
530 #[cfg(feature = "services-http")]
531 pub use opendal_service_http::*;
532 #[cfg(feature = "services-ipfs")]
533 pub use opendal_service_ipfs::*;
534 #[cfg(feature = "services-ipmfs")]
535 pub use opendal_service_ipmfs::*;
536 #[cfg(feature = "services-koofr")]
537 pub use opendal_service_koofr::*;
538 #[cfg(feature = "services-lakefs")]
539 pub use opendal_service_lakefs::*;
540 #[cfg(feature = "services-memcached")]
541 pub use opendal_service_memcached::*;
542 #[cfg(feature = "services-mini-moka")]
543 pub use opendal_service_mini_moka::*;
544 #[cfg(feature = "services-moka")]
545 pub use opendal_service_moka::*;
546 #[cfg(feature = "services-mongodb")]
547 pub use opendal_service_mongodb::*;
548 #[cfg(feature = "services-monoiofs")]
549 pub use opendal_service_monoiofs::*;
550 #[cfg(feature = "services-mysql")]
551 pub use opendal_service_mysql::*;
552 #[cfg(feature = "services-obs")]
553 pub use opendal_service_obs::*;
554 #[cfg(feature = "services-onedrive")]
555 pub use opendal_service_onedrive::*;
556 #[cfg(all(target_arch = "wasm32", feature = "services-opfs"))]
557 pub use opendal_service_opfs::*;
558 #[cfg(feature = "services-oss")]
559 pub use opendal_service_oss::*;
560 #[cfg(feature = "services-pcloud")]
561 pub use opendal_service_pcloud::*;
562 #[cfg(feature = "services-persy")]
563 pub use opendal_service_persy::*;
564 #[cfg(feature = "services-postgresql")]
565 pub use opendal_service_postgresql::*;
566 #[cfg(feature = "services-redb")]
567 pub use opendal_service_redb::*;
568 #[cfg(feature = "services-redis")]
569 pub use opendal_service_redis::*;
570 #[cfg(feature = "services-remotestorage")]
571 pub use opendal_service_remotestorage::*;
572 #[cfg(feature = "services-rocksdb")]
573 pub use opendal_service_rocksdb::*;
574 #[cfg(feature = "services-akamai")]
575 pub use opendal_service_s3::{AKAMAI_SCHEME, Akamai, AkamaiConfig, register_akamai_service};
576 #[cfg(feature = "services-b2-s3")]
577 pub use opendal_service_s3::{B2_S3_SCHEME, B2S3, B2S3Config, register_b2_s3_service};
578 #[cfg(feature = "services-ceph-rgw")]
579 pub use opendal_service_s3::{
580 CEPH_RGW_SCHEME, CephRgw, CephRgwConfig, register_ceph_rgw_service,
581 };
582 #[cfg(feature = "services-cos-s3")]
583 pub use opendal_service_s3::{COS_S3_SCHEME, CosS3, CosS3Config, register_cos_s3_service};
584 #[cfg(feature = "services-exoscale")]
585 pub use opendal_service_s3::{
586 EXOSCALE_SCHEME, Exoscale, ExoscaleConfig, register_exoscale_service,
587 };
588 #[cfg(feature = "services-garage")]
589 pub use opendal_service_s3::{GARAGE_SCHEME, Garage, GarageConfig, register_garage_service};
590 #[cfg(feature = "services-gcs-s3")]
591 pub use opendal_service_s3::{GCS_S3_SCHEME, GcsS3, GcsS3Config, register_gcs_s3_service};
592 #[cfg(feature = "services-hetzner")]
593 pub use opendal_service_s3::{
594 HETZNER_SCHEME, Hetzner, HetznerConfig, register_hetzner_service,
595 };
596 #[cfg(feature = "services-ibm-cos")]
597 pub use opendal_service_s3::{IBM_COS_SCHEME, IbmCos, IbmCosConfig, register_ibm_cos_service};
598 #[cfg(feature = "services-idrive-e2")]
599 pub use opendal_service_s3::{
600 IDRIVE_E2_SCHEME, IdriveE2, IdriveE2Config, register_idrive_e2_service,
601 };
602 #[cfg(feature = "services-ionos")]
603 pub use opendal_service_s3::{IONOS_SCHEME, Ionos, IonosConfig, register_ionos_service};
604 #[cfg(feature = "services-lakefs-s3")]
605 pub use opendal_service_s3::{
606 LAKEFS_S3_SCHEME, LakefsS3, LakefsS3Config, register_lakefs_s3_service,
607 };
608 #[cfg(feature = "services-minio")]
609 pub use opendal_service_s3::{MINIO_SCHEME, Minio, MinioConfig, register_minio_service};
610 #[cfg(feature = "services-neon")]
611 pub use opendal_service_s3::{NEON_SCHEME, Neon, NeonConfig, register_neon_service};
612 #[cfg(feature = "services-obs-s3")]
613 pub use opendal_service_s3::{OBS_S3_SCHEME, ObsS3, ObsS3Config, register_obs_s3_service};
614 #[cfg(feature = "services-oci")]
615 pub use opendal_service_s3::{OCI_SCHEME, Oci, OciConfig, register_oci_service};
616 #[cfg(feature = "services-oss-s3")]
617 pub use opendal_service_s3::{OSS_S3_SCHEME, OssS3, OssS3Config, register_oss_s3_service};
618 #[cfg(feature = "services-ovhcloud")]
619 pub use opendal_service_s3::{
620 OVHCLOUD_SCHEME, Ovhcloud, OvhcloudConfig, register_ovhcloud_service,
621 };
622 #[cfg(feature = "services-qingstor")]
623 pub use opendal_service_s3::{
624 QINGSTOR_SCHEME, Qingstor, QingstorConfig, register_qingstor_service,
625 };
626 #[cfg(feature = "services-r2")]
627 pub use opendal_service_s3::{R2, R2_SCHEME, R2Config, register_r2_service};
628 #[cfg(feature = "services-rustfs")]
629 pub use opendal_service_s3::{RUSTFS_SCHEME, Rustfs, RustfsConfig, register_rustfs_service};
630 #[cfg(feature = "services-s3")]
631 pub use opendal_service_s3::{S3, S3_SCHEME, S3Config, register_s3_service, reqsign_aws_v4};
632 #[cfg(feature = "services-scaleway")]
633 pub use opendal_service_s3::{
634 SCALEWAY_SCHEME, Scaleway, ScalewayConfig, register_scaleway_service,
635 };
636 #[cfg(feature = "services-seaweedfs")]
637 pub use opendal_service_s3::{
638 SEAWEEDFS_SCHEME, Seaweedfs, SeaweedfsConfig, register_seaweedfs_service,
639 };
640 #[cfg(feature = "services-spaces")]
641 pub use opendal_service_s3::{SPACES_SCHEME, Spaces, SpacesConfig, register_spaces_service};
642 #[cfg(feature = "services-storj")]
643 pub use opendal_service_s3::{STORJ_SCHEME, Storj, StorjConfig, register_storj_service};
644 #[cfg(feature = "services-supabase")]
645 pub use opendal_service_s3::{
646 SUPABASE_SCHEME, Supabase, SupabaseConfig, register_supabase_service,
647 };
648 #[cfg(feature = "services-swift-s3api")]
649 pub use opendal_service_s3::{
650 SWIFT_S3API_SCHEME, SwiftS3api, SwiftS3apiConfig, register_swift_s3api_service,
651 };
652 #[cfg(feature = "services-tigris")]
653 pub use opendal_service_s3::{TIGRIS_SCHEME, Tigris, TigrisConfig, register_tigris_service};
654 #[cfg(feature = "services-tos-s3")]
655 pub use opendal_service_s3::{TOS_S3_SCHEME, TosS3, TosS3Config, register_tos_s3_service};
656 #[cfg(feature = "services-wasabi")]
657 pub use opendal_service_s3::{WASABI_SCHEME, Wasabi, WasabiConfig, register_wasabi_service};
658 #[cfg(feature = "services-seafile")]
659 pub use opendal_service_seafile::*;
660 #[cfg(feature = "services-sftp")]
661 pub use opendal_service_sftp::*;
662 #[cfg(feature = "services-sled")]
663 pub use opendal_service_sled::*;
664 #[cfg(feature = "services-sqlite")]
665 pub use opendal_service_sqlite::*;
666 #[cfg(feature = "services-surrealdb")]
667 pub use opendal_service_surrealdb::*;
668 #[cfg(feature = "services-swift")]
669 pub use opendal_service_swift::*;
670 #[cfg(feature = "services-tikv")]
671 pub use opendal_service_tikv::*;
672 #[cfg(feature = "services-tos")]
673 pub use opendal_service_tos::*;
674 #[cfg(feature = "services-upyun")]
675 pub use opendal_service_upyun::*;
676 #[cfg(feature = "services-vercel-artifacts")]
677 pub use opendal_service_vercel_artifacts::*;
678 #[cfg(feature = "services-vercel-blob")]
679 pub use opendal_service_vercel_blob::*;
680 #[cfg(feature = "services-webdav")]
681 pub use opendal_service_webdav::*;
682 #[cfg(feature = "services-webhdfs")]
683 pub use opendal_service_webhdfs::*;
684 #[cfg(feature = "services-yandex-disk")]
685 pub use opendal_service_yandex_disk::*;
686}
687
688#[cfg(test)]
689mod service_feature_tests {
690 use super::*;
691
692 #[test]
693 fn registers_enabled_s3_provider_schemes() {
694 init_default_registry();
695 let schemes = OperatorRegistry::get().schemes();
696
697 assert!(schemes.contains("memory"));
698
699 #[cfg(feature = "services-s3")]
700 {
701 let chain =
702 reqsign_core::ProvideCredentialChain::<services::reqsign_aws_v4::Credential>::new();
703 let _ = services::S3::default().credential_provider_chain(chain);
704 assert!(schemes.contains("s3"));
705 }
706 #[cfg(not(feature = "services-s3"))]
707 assert!(!schemes.contains("s3"));
708
709 #[cfg(feature = "services-r2")]
710 {
711 let _ = services::R2::default();
712 assert!(schemes.contains("r2"));
713 }
714 #[cfg(not(feature = "services-r2"))]
715 assert!(!schemes.contains("r2"));
716
717 #[cfg(feature = "services-minio")]
718 {
719 let _ = services::Minio::default();
720 assert!(schemes.contains("minio"));
721 }
722 #[cfg(not(feature = "services-minio"))]
723 assert!(!schemes.contains("minio"));
724
725 for (scheme, enabled) in [
726 ("akamai", cfg!(feature = "services-akamai")),
727 ("ceph-rgw", cfg!(feature = "services-ceph-rgw")),
728 ("exoscale", cfg!(feature = "services-exoscale")),
729 ("garage", cfg!(feature = "services-garage")),
730 ("hetzner", cfg!(feature = "services-hetzner")),
731 ("ibm-cos", cfg!(feature = "services-ibm-cos")),
732 ("idrive-e2", cfg!(feature = "services-idrive-e2")),
733 ("ionos", cfg!(feature = "services-ionos")),
734 ("neon", cfg!(feature = "services-neon")),
735 ("oci", cfg!(feature = "services-oci")),
736 ("ovhcloud", cfg!(feature = "services-ovhcloud")),
737 ("qingstor", cfg!(feature = "services-qingstor")),
738 ("rustfs", cfg!(feature = "services-rustfs")),
739 ("scaleway", cfg!(feature = "services-scaleway")),
740 ("seaweedfs", cfg!(feature = "services-seaweedfs")),
741 ("spaces", cfg!(feature = "services-spaces")),
742 ("storj", cfg!(feature = "services-storj")),
743 ("supabase", cfg!(feature = "services-supabase")),
744 ("tigris", cfg!(feature = "services-tigris")),
745 ("wasabi", cfg!(feature = "services-wasabi")),
746 ("b2-s3", cfg!(feature = "services-b2-s3")),
747 ("cos-s3", cfg!(feature = "services-cos-s3")),
748 ("gcs-s3", cfg!(feature = "services-gcs-s3")),
749 ("lakefs-s3", cfg!(feature = "services-lakefs-s3")),
750 ("obs-s3", cfg!(feature = "services-obs-s3")),
751 ("oss-s3", cfg!(feature = "services-oss-s3")),
752 ("swift-s3api", cfg!(feature = "services-swift-s3api")),
753 ("tos-s3", cfg!(feature = "services-tos-s3")),
754 ("b2", cfg!(feature = "services-b2")),
755 ("cos", cfg!(feature = "services-cos")),
756 ("cosn", cfg!(feature = "services-cos")),
757 ("gcs", cfg!(feature = "services-gcs")),
758 ("gcs-grpc", cfg!(feature = "services-gcs-grpc")),
759 ("lakefs", cfg!(feature = "services-lakefs")),
760 ("obs", cfg!(feature = "services-obs")),
761 ("oss", cfg!(feature = "services-oss")),
762 ("swift", cfg!(feature = "services-swift")),
763 ("tos", cfg!(feature = "services-tos")),
764 ] {
765 assert_eq!(schemes.contains(scheme), enabled, "{scheme}");
766 }
767
768 #[cfg(feature = "services-obs")]
769 {
770 let op = Operator::from_uri((
771 "obs://example-bucket/root",
772 [("endpoint", "https://obs.cn-north-1.myhuaweicloud.com")],
773 ))
774 .unwrap();
775 assert_eq!(op.info().scheme(), "obs");
776 assert_eq!(op.info().name(), "example-bucket");
777 assert_eq!(op.info().root(), "/root/");
778 }
779
780 #[cfg(feature = "services-obs-s3")]
781 {
782 let op = Operator::from_uri("obs-s3://example-bucket/root?region=cn-north-1").unwrap();
783 assert_eq!(op.info().scheme(), "obs-s3");
784 assert_eq!(op.info().name(), "example-bucket");
785 assert_eq!(op.info().root(), "/root/");
786
787 let op = Operator::via_iter(
788 "obs-s3",
789 [
790 ("bucket".to_owned(), "example-bucket".to_owned()),
791 ("region".to_owned(), "cn-north-1".to_owned()),
792 ],
793 )
794 .unwrap();
795 assert_eq!(op.info().scheme(), "obs-s3");
796 assert_eq!(op.info().name(), "example-bucket");
797 assert_eq!(op.info().root(), "/");
798 }
799
800 #[cfg(feature = "services-tigris")]
801 {
802 let op = Operator::from_uri("tigris://example-bucket/root").unwrap();
803 assert_eq!(op.info().scheme(), "tigris");
804 assert_eq!(op.info().name(), "example-bucket");
805 assert_eq!(op.info().root(), "/root/");
806 }
807 }
808
809 #[cfg(all(
810 feature = "services-b2",
811 feature = "services-cos",
812 feature = "services-gcs",
813 feature = "services-lakefs",
814 feature = "services-oss",
815 feature = "services-swift",
816 feature = "services-tos",
817 ))]
818 #[test]
819 fn native_uris_still_use_native_builders() -> Result<()> {
820 init_default_registry();
821
822 type Options<'a> = &'a [(&'a str, &'a str)];
823 let cases: &[(&str, Options<'_>, &str)] = &[
824 (
825 "b2://example-bucket/root",
826 &[
827 ("bucket_id", "bucket-id"),
828 ("application_key_id", "app-id"),
829 ("application_key", "app-key"),
830 ],
831 "b2",
832 ),
833 (
834 "cos://example-bucket-1250000000/root",
835 &[("endpoint", "https://cos.ap-guangzhou.myqcloud.com")],
836 "cos",
837 ),
838 (
839 "cosn://example-bucket-1250000000/root",
840 &[("endpoint", "https://cos.ap-guangzhou.myqcloud.com")],
841 "cos",
842 ),
843 ("gcs://example-bucket/root", &[], "gcs"),
844 (
845 "lakefs://lakefs.example.com/repo/dev/root",
846 &[("username", "test-user"), ("password", "test-secret")],
847 "lakefs",
848 ),
849 (
850 "oss://example-bucket/root",
851 &[("endpoint", "https://oss-cn-hangzhou.aliyuncs.com")],
852 "oss",
853 ),
854 (
855 "swift://swift.example.com/container/root",
856 &[("token", "swift-token")],
857 "swift",
858 ),
859 ("tos://example-bucket/root", &[], "tos"),
860 ];
861 for &(uri, options, scheme) in cases {
862 let op = Operator::from_uri((uri, options.iter().copied()))?;
863 assert_eq!(op.info().scheme(), scheme, "{uri}");
864 }
865 #[cfg(feature = "services-gcs-grpc")]
866 {
867 let op = Operator::from_uri("gcs-grpc://example-bucket/root")?;
868 assert_eq!(op.info().scheme(), "gcs-grpc");
869 }
870 Ok(())
871 }
872
873 #[cfg(feature = "services-garage")]
874 #[test]
875 fn garage_builds_from_uri_iter_and_typed_config() {
876 use crate::services::{GARAGE_SCHEME, Garage, GarageConfig};
877
878 let options = [("endpoint", "http://127.0.0.1:3900"), ("region", "garage")];
879 let from_uri = Operator::from_uri(("garage://example-bucket/root", options)).unwrap();
880 let from_iter = Operator::via_iter(
881 GARAGE_SCHEME,
882 options
883 .into_iter()
884 .chain([("bucket", "example-bucket"), ("root", "root")])
885 .map(|(key, value)| (key.to_owned(), value.to_owned())),
886 )
887 .unwrap();
888 let mut config = GarageConfig::default();
889 config.bucket = "example-bucket".into();
890 config.root = Some("root".into());
891 config.endpoint = "http://127.0.0.1:3900".into();
892 config.region = "garage".into();
893 let from_config = Operator::from_config(config).unwrap();
894 let from_builder = Operator::new(
895 Garage::default()
896 .bucket("example-bucket")
897 .root("root")
898 .endpoint("http://127.0.0.1:3900")
899 .region("garage"),
900 )
901 .unwrap();
902
903 for op in [from_uri, from_iter, from_config, from_builder] {
904 assert_eq!(op.info().scheme(), GARAGE_SCHEME);
905 assert_eq!(op.info().name(), "example-bucket");
906 assert_eq!(op.info().root(), "/root/");
907 }
908 }
909}
910
911pub mod layers {
918 pub use opendal_core::layers::*;
919 #[cfg(feature = "layers-aimd")]
920 pub use opendal_layer_aimd::*;
921 #[cfg(feature = "layers-async-backtrace")]
922 pub use opendal_layer_async_backtrace::*;
923 #[cfg(feature = "layers-await-tree")]
924 pub use opendal_layer_await_tree::*;
925 #[cfg(feature = "layers-cache")]
926 pub use opendal_layer_cache::{CacheDecision, CacheLayer, CachePolicy, CacheReadRequest};
927 #[cfg(feature = "layers-capability-check")]
928 pub use opendal_layer_capability_check::*;
929 #[cfg(feature = "layers-chaos")]
930 pub use opendal_layer_chaos::*;
931 #[cfg(feature = "layers-checksum")]
932 pub use opendal_layer_checksum::ChecksumLayer;
933 #[cfg(feature = "layers-concurrent-limit")]
934 pub use opendal_layer_concurrent_limit::*;
935 #[cfg(all(target_os = "linux", feature = "layers-dtrace"))]
936 pub use opendal_layer_dtrace::*;
937 #[cfg(feature = "layers-fastmetrics")]
938 pub use opendal_layer_fastmetrics::*;
939 #[cfg(feature = "layers-fastrace")]
940 pub use opendal_layer_fastrace::*;
941 #[cfg(feature = "layers-foyer")]
942 pub use opendal_layer_foyer::*;
943 #[cfg(feature = "layers-hedge")]
944 pub use opendal_layer_hedge::*;
945 #[cfg(feature = "layers-hotpath")]
946 pub use opendal_layer_hotpath::*;
947 #[cfg(feature = "layers-immutable-index")]
948 pub use opendal_layer_immutable_index::*;
949 #[cfg(feature = "layers-logging")]
950 pub use opendal_layer_logging::*;
951 #[cfg(feature = "layers-metrics")]
952 pub use opendal_layer_metrics::*;
953 #[cfg(feature = "layers-mime-guess")]
954 pub use opendal_layer_mime_guess::*;
955 #[cfg(feature = "layers-otel-metrics")]
956 pub use opendal_layer_otelmetrics::*;
957 #[cfg(feature = "layers-otel-trace")]
958 pub use opendal_layer_oteltrace::*;
959 #[cfg(feature = "layers-prometheus")]
960 pub use opendal_layer_prometheus::*;
961 #[cfg(feature = "layers-prometheus-client")]
962 pub use opendal_layer_prometheus_client::*;
963 #[cfg(feature = "layers-retry")]
964 pub use opendal_layer_retry::*;
965 #[cfg(feature = "layers-route")]
966 pub use opendal_layer_route::*;
967 #[cfg(feature = "layers-sanity-check")]
968 pub use opendal_layer_sanity_check::*;
969 #[cfg(feature = "layers-tail-cut")]
970 pub use opendal_layer_tail_cut::*;
971 #[cfg(feature = "layers-throttle")]
972 pub use opendal_layer_throttle::*;
973 #[cfg(feature = "layers-timeout")]
974 pub use opendal_layer_timeout::*;
975 #[cfg(feature = "layers-tracing")]
976 pub use opendal_layer_tracing::*;
977}