opendal/
lib.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18#![doc(
19    html_logo_url = "https://raw.githubusercontent.com/apache/opendal/main/website/static/img/logo.svg"
20)]
21#![cfg_attr(docsrs, feature(doc_cfg))]
22//! Facade crate that re-exports all public APIs from `opendal-core` and optional services/layers.
23#![deny(missing_docs)]
24
25pub use opendal_core::*;
26
27#[cfg(feature = "tests")]
28pub extern crate opendal_testkit as tests;
29
30/// Initialize the global [`OperatorRegistry`] with enabled services.
31///
32/// This function is safe to call multiple times and will only perform
33/// initialization once.
34///
35/// # Notes
36///
37/// Some bindings link `opendal` as a `staticlib`, where `#[ctor::ctor]`
38/// initializers may not be executed due to linker behavior. Those bindings
39/// should call this function explicitly before using `Operator::from_uri` or
40/// `Operator::via_iter`.
41pub fn init_default_registry() {
42    static DEFAULT_REGISTRY_INIT: std::sync::Once = std::sync::Once::new();
43    DEFAULT_REGISTRY_INIT.call_once(|| init_default_registry_inner(OperatorRegistry::get()));
44}
45
46fn init_default_registry_inner(registry: &OperatorRegistry) {
47    opendal_core::services::register_memory_service(registry);
48
49    #[cfg(feature = "services-aliyun-drive")]
50    opendal_service_aliyun_drive::register_aliyun_drive_service(registry);
51
52    #[cfg(feature = "services-alluxio")]
53    opendal_service_alluxio::register_alluxio_service(registry);
54
55    #[cfg(feature = "services-azblob")]
56    opendal_service_azblob::register_azblob_service(registry);
57
58    #[cfg(feature = "services-azdls")]
59    opendal_service_azdls::register_azdls_service(registry);
60
61    #[cfg(feature = "services-azfile")]
62    opendal_service_azfile::register_azfile_service(registry);
63
64    #[cfg(feature = "services-b2")]
65    opendal_service_b2::register_b2_service(registry);
66
67    #[cfg(feature = "services-cacache")]
68    opendal_service_cacache::register_cacache_service(registry);
69
70    #[cfg(feature = "services-cloudflare-kv")]
71    opendal_service_cloudflare_kv::register_cloudflare_kv_service(registry);
72
73    #[cfg(feature = "services-compfs")]
74    opendal_service_compfs::register_compfs_service(registry);
75
76    #[cfg(feature = "services-cos")]
77    opendal_service_cos::register_cos_service(registry);
78
79    #[cfg(feature = "services-d1")]
80    opendal_service_d1::register_d1_service(registry);
81
82    #[cfg(feature = "services-dashmap")]
83    opendal_service_dashmap::register_dashmap_service(registry);
84
85    #[cfg(feature = "services-dbfs")]
86    opendal_service_dbfs::register_dbfs_service(registry);
87
88    #[cfg(feature = "services-dropbox")]
89    opendal_service_dropbox::register_dropbox_service(registry);
90
91    #[cfg(feature = "services-etcd")]
92    opendal_service_etcd::register_etcd_service(registry);
93
94    #[cfg(feature = "services-foundationdb")]
95    opendal_service_foundationdb::register_foundationdb_service(registry);
96
97    #[cfg(feature = "services-foyer")]
98    opendal_service_foyer::register_foyer_service(registry);
99
100    #[cfg(feature = "services-fs")]
101    opendal_service_fs::register_fs_service(registry);
102
103    #[cfg(feature = "services-ftp")]
104    opendal_service_ftp::register_ftp_service(registry);
105
106    #[cfg(feature = "services-gcs")]
107    opendal_service_gcs::register_gcs_service(registry);
108
109    #[cfg(feature = "services-gdrive")]
110    opendal_service_gdrive::register_gdrive_service(registry);
111
112    #[cfg(feature = "services-ghac")]
113    opendal_service_ghac::register_ghac_service(registry);
114
115    #[cfg(feature = "services-github")]
116    opendal_service_github::register_github_service(registry);
117
118    #[cfg(feature = "services-goosefs")]
119    opendal_service_goosefs::register_goosefs_service(registry);
120
121    #[cfg(feature = "services-gridfs")]
122    opendal_service_gridfs::register_gridfs_service(registry);
123
124    #[cfg(feature = "services-hdfs")]
125    opendal_service_hdfs::register_hdfs_service(registry);
126
127    #[cfg(feature = "services-hdfs-native")]
128    opendal_service_hdfs_native::register_hdfs_native_service(registry);
129
130    #[cfg(feature = "services-http")]
131    opendal_service_http::register_http_service(registry);
132
133    #[cfg(feature = "services-hf")]
134    opendal_service_hf::register_hf_service(registry);
135
136    #[cfg(feature = "services-ipfs")]
137    opendal_service_ipfs::register_ipfs_service(registry);
138
139    #[cfg(feature = "services-ipmfs")]
140    opendal_service_ipmfs::register_ipmfs_service(registry);
141
142    #[cfg(feature = "services-koofr")]
143    opendal_service_koofr::register_koofr_service(registry);
144
145    #[cfg(feature = "services-lakefs")]
146    opendal_service_lakefs::register_lakefs_service(registry);
147
148    #[cfg(feature = "services-memcached")]
149    opendal_service_memcached::register_memcached_service(registry);
150
151    #[cfg(feature = "services-mini-moka")]
152    opendal_service_mini_moka::register_mini_moka_service(registry);
153
154    #[cfg(feature = "services-moka")]
155    opendal_service_moka::register_moka_service(registry);
156
157    #[cfg(feature = "services-mongodb")]
158    opendal_service_mongodb::register_mongodb_service(registry);
159
160    #[cfg(feature = "services-monoiofs")]
161    opendal_service_monoiofs::register_monoiofs_service(registry);
162
163    #[cfg(feature = "services-mysql")]
164    opendal_service_mysql::register_mysql_service(registry);
165
166    #[cfg(feature = "services-obs")]
167    opendal_service_obs::register_obs_service(registry);
168
169    #[cfg(feature = "services-onedrive")]
170    opendal_service_onedrive::register_onedrive_service(registry);
171
172    #[cfg(feature = "services-oss")]
173    opendal_service_oss::register_oss_service(registry);
174
175    #[cfg(feature = "services-pcloud")]
176    opendal_service_pcloud::register_pcloud_service(registry);
177
178    #[cfg(feature = "services-persy")]
179    opendal_service_persy::register_persy_service(registry);
180
181    #[cfg(feature = "services-postgresql")]
182    opendal_service_postgresql::register_postgresql_service(registry);
183
184    #[cfg(feature = "services-redb")]
185    opendal_service_redb::register_redb_service(registry);
186
187    #[cfg(feature = "services-rocksdb")]
188    opendal_service_rocksdb::register_rocksdb_service(registry);
189
190    #[cfg(feature = "services-s3")]
191    opendal_service_s3::register_s3_service(registry);
192
193    #[cfg(feature = "services-seafile")]
194    opendal_service_seafile::register_seafile_service(registry);
195
196    #[cfg(feature = "services-sftp")]
197    opendal_service_sftp::register_sftp_service(registry);
198
199    #[cfg(feature = "services-sled")]
200    opendal_service_sled::register_sled_service(registry);
201
202    #[cfg(feature = "services-sqlite")]
203    opendal_service_sqlite::register_sqlite_service(registry);
204
205    #[cfg(feature = "services-surrealdb")]
206    opendal_service_surrealdb::register_surrealdb_service(registry);
207
208    #[cfg(feature = "services-swift")]
209    opendal_service_swift::register_swift_service(registry);
210
211    #[cfg(feature = "services-tikv")]
212    opendal_service_tikv::register_tikv_service(registry);
213
214    #[cfg(feature = "services-tos")]
215    opendal_service_tos::register_tos_service(registry);
216
217    #[cfg(feature = "services-upyun")]
218    opendal_service_upyun::register_upyun_service(registry);
219
220    #[cfg(feature = "services-vercel-artifacts")]
221    opendal_service_vercel_artifacts::register_vercel_artifacts_service(registry);
222
223    #[cfg(feature = "services-vercel-blob")]
224    opendal_service_vercel_blob::register_vercel_blob_service(registry);
225
226    #[cfg(feature = "services-webdav")]
227    opendal_service_webdav::register_webdav_service(registry);
228
229    #[cfg(feature = "services-webhdfs")]
230    opendal_service_webhdfs::register_webhdfs_service(registry);
231
232    #[cfg(feature = "services-yandex-disk")]
233    opendal_service_yandex_disk::register_yandex_disk_service(registry);
234
235    #[cfg(all(target_arch = "wasm32", feature = "services-opfs"))]
236    opendal_service_opfs::register_opfs_service(registry);
237
238    #[cfg(any(feature = "services-redis", feature = "services-redis-native-tls"))]
239    opendal_service_redis::register_redis_service(registry);
240}
241
242#[cfg(feature = "auto-register-services")]
243#[ctor::ctor(unsafe)]
244fn register_default_operator_registry() {
245    init_default_registry();
246}
247
248/// Re-export of service implementations.
249pub mod services {
250    pub use opendal_core::services::*;
251    #[cfg(feature = "services-aliyun-drive")]
252    pub use opendal_service_aliyun_drive::*;
253    #[cfg(feature = "services-alluxio")]
254    pub use opendal_service_alluxio::*;
255    #[cfg(feature = "services-azblob")]
256    pub use opendal_service_azblob::*;
257    #[cfg(feature = "services-azdls")]
258    pub use opendal_service_azdls::*;
259    #[cfg(feature = "services-azfile")]
260    pub use opendal_service_azfile::*;
261    #[cfg(feature = "services-b2")]
262    pub use opendal_service_b2::*;
263    #[cfg(feature = "services-cacache")]
264    pub use opendal_service_cacache::*;
265    #[cfg(feature = "services-cloudflare-kv")]
266    pub use opendal_service_cloudflare_kv::*;
267    #[cfg(feature = "services-compfs")]
268    pub use opendal_service_compfs::*;
269    #[cfg(feature = "services-cos")]
270    pub use opendal_service_cos::*;
271    #[cfg(feature = "services-d1")]
272    pub use opendal_service_d1::*;
273    #[cfg(feature = "services-dashmap")]
274    pub use opendal_service_dashmap::*;
275    #[cfg(feature = "services-dbfs")]
276    pub use opendal_service_dbfs::*;
277    #[cfg(feature = "services-dropbox")]
278    pub use opendal_service_dropbox::*;
279    #[cfg(feature = "services-etcd")]
280    pub use opendal_service_etcd::*;
281    #[cfg(feature = "services-foundationdb")]
282    pub use opendal_service_foundationdb::*;
283    #[cfg(feature = "services-foyer")]
284    pub use opendal_service_foyer::*;
285    #[cfg(feature = "services-fs")]
286    pub use opendal_service_fs::*;
287    #[cfg(feature = "services-ftp")]
288    pub use opendal_service_ftp::*;
289    #[cfg(feature = "services-gcs")]
290    pub use opendal_service_gcs::*;
291    #[cfg(feature = "services-gdrive")]
292    pub use opendal_service_gdrive::*;
293    #[cfg(feature = "services-ghac")]
294    pub use opendal_service_ghac::*;
295    #[cfg(feature = "services-github")]
296    pub use opendal_service_github::*;
297    #[cfg(feature = "services-goosefs")]
298    pub use opendal_service_goosefs::*;
299    #[cfg(feature = "services-gridfs")]
300    pub use opendal_service_gridfs::*;
301    #[cfg(feature = "services-hdfs")]
302    pub use opendal_service_hdfs::*;
303    #[cfg(feature = "services-hdfs-native")]
304    pub use opendal_service_hdfs_native::*;
305    #[cfg(feature = "services-hf")]
306    pub use opendal_service_hf::*;
307    #[cfg(feature = "services-http")]
308    pub use opendal_service_http::*;
309    #[cfg(feature = "services-ipfs")]
310    pub use opendal_service_ipfs::*;
311    #[cfg(feature = "services-ipmfs")]
312    pub use opendal_service_ipmfs::*;
313    #[cfg(feature = "services-koofr")]
314    pub use opendal_service_koofr::*;
315    #[cfg(feature = "services-lakefs")]
316    pub use opendal_service_lakefs::*;
317    #[cfg(feature = "services-memcached")]
318    pub use opendal_service_memcached::*;
319    #[cfg(feature = "services-mini-moka")]
320    pub use opendal_service_mini_moka::*;
321    #[cfg(feature = "services-moka")]
322    pub use opendal_service_moka::*;
323    #[cfg(feature = "services-mongodb")]
324    pub use opendal_service_mongodb::*;
325    #[cfg(feature = "services-monoiofs")]
326    pub use opendal_service_monoiofs::*;
327    #[cfg(feature = "services-mysql")]
328    pub use opendal_service_mysql::*;
329    #[cfg(feature = "services-obs")]
330    pub use opendal_service_obs::*;
331    #[cfg(feature = "services-onedrive")]
332    pub use opendal_service_onedrive::*;
333    #[cfg(all(target_arch = "wasm32", feature = "services-opfs"))]
334    pub use opendal_service_opfs::*;
335    #[cfg(feature = "services-oss")]
336    pub use opendal_service_oss::*;
337    #[cfg(feature = "services-pcloud")]
338    pub use opendal_service_pcloud::*;
339    #[cfg(feature = "services-persy")]
340    pub use opendal_service_persy::*;
341    #[cfg(feature = "services-postgresql")]
342    pub use opendal_service_postgresql::*;
343    #[cfg(feature = "services-redb")]
344    pub use opendal_service_redb::*;
345    #[cfg(feature = "services-redis")]
346    pub use opendal_service_redis::*;
347    #[cfg(feature = "services-rocksdb")]
348    pub use opendal_service_rocksdb::*;
349    #[cfg(feature = "services-s3")]
350    pub use opendal_service_s3::*;
351    #[cfg(feature = "services-seafile")]
352    pub use opendal_service_seafile::*;
353    #[cfg(feature = "services-sftp")]
354    pub use opendal_service_sftp::*;
355    #[cfg(feature = "services-sled")]
356    pub use opendal_service_sled::*;
357    #[cfg(feature = "services-sqlite")]
358    pub use opendal_service_sqlite::*;
359    #[cfg(feature = "services-surrealdb")]
360    pub use opendal_service_surrealdb::*;
361    #[cfg(feature = "services-swift")]
362    pub use opendal_service_swift::*;
363    #[cfg(feature = "services-tikv")]
364    pub use opendal_service_tikv::*;
365    #[cfg(feature = "services-tos")]
366    pub use opendal_service_tos::*;
367    #[cfg(feature = "services-upyun")]
368    pub use opendal_service_upyun::*;
369    #[cfg(feature = "services-vercel-artifacts")]
370    pub use opendal_service_vercel_artifacts::*;
371    #[cfg(feature = "services-vercel-blob")]
372    pub use opendal_service_vercel_blob::*;
373    #[cfg(feature = "services-webdav")]
374    pub use opendal_service_webdav::*;
375    #[cfg(feature = "services-webhdfs")]
376    pub use opendal_service_webhdfs::*;
377    #[cfg(feature = "services-yandex-disk")]
378    pub use opendal_service_yandex_disk::*;
379}
380
381/// Re-export of layers.
382pub mod layers {
383    pub use opendal_core::layers::*;
384    #[cfg(feature = "layers-async-backtrace")]
385    pub use opendal_layer_async_backtrace::*;
386    #[cfg(feature = "layers-await-tree")]
387    pub use opendal_layer_await_tree::*;
388    #[cfg(feature = "layers-capability-check")]
389    pub use opendal_layer_capability_check::*;
390    #[cfg(feature = "layers-chaos")]
391    pub use opendal_layer_chaos::*;
392    #[cfg(feature = "layers-concurrent-limit")]
393    pub use opendal_layer_concurrent_limit::*;
394    #[cfg(all(target_os = "linux", feature = "layers-dtrace"))]
395    pub use opendal_layer_dtrace::*;
396    #[cfg(feature = "layers-fastmetrics")]
397    pub use opendal_layer_fastmetrics::*;
398    #[cfg(feature = "layers-fastrace")]
399    pub use opendal_layer_fastrace::*;
400    #[cfg(feature = "layers-foyer")]
401    pub use opendal_layer_foyer::*;
402    #[cfg(feature = "layers-hotpath")]
403    pub use opendal_layer_hotpath::*;
404    #[cfg(feature = "layers-immutable-index")]
405    pub use opendal_layer_immutable_index::*;
406    #[cfg(feature = "layers-logging")]
407    pub use opendal_layer_logging::*;
408    #[cfg(feature = "layers-metrics")]
409    pub use opendal_layer_metrics::*;
410    #[cfg(feature = "layers-mime-guess")]
411    pub use opendal_layer_mime_guess::*;
412    #[cfg(feature = "layers-otel-metrics")]
413    pub use opendal_layer_otelmetrics::*;
414    #[cfg(feature = "layers-otel-trace")]
415    pub use opendal_layer_oteltrace::*;
416    #[cfg(feature = "layers-prometheus")]
417    pub use opendal_layer_prometheus::*;
418    #[cfg(feature = "layers-prometheus-client")]
419    pub use opendal_layer_prometheus_client::*;
420    #[cfg(feature = "layers-retry")]
421    pub use opendal_layer_retry::*;
422    #[cfg(feature = "layers-route")]
423    pub use opendal_layer_route::*;
424    #[cfg(feature = "layers-tail-cut")]
425    pub use opendal_layer_tail_cut::*;
426    #[cfg(feature = "layers-throttle")]
427    pub use opendal_layer_throttle::*;
428    #[cfg(feature = "layers-timeout")]
429    pub use opendal_layer_timeout::*;
430    #[cfg(feature = "layers-tracing")]
431    pub use opendal_layer_tracing::*;
432}