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-fs")]
98    opendal_service_fs::register_fs_service(registry);
99
100    #[cfg(feature = "services-ftp")]
101    opendal_service_ftp::register_ftp_service(registry);
102
103    #[cfg(feature = "services-gcs")]
104    opendal_service_gcs::register_gcs_service(registry);
105
106    #[cfg(feature = "services-gdrive")]
107    opendal_service_gdrive::register_gdrive_service(registry);
108
109    #[cfg(feature = "services-ghac")]
110    opendal_service_ghac::register_ghac_service(registry);
111
112    #[cfg(feature = "services-github")]
113    opendal_service_github::register_github_service(registry);
114
115    #[cfg(feature = "services-gridfs")]
116    opendal_service_gridfs::register_gridfs_service(registry);
117
118    #[cfg(feature = "services-hdfs")]
119    opendal_service_hdfs::register_hdfs_service(registry);
120
121    #[cfg(feature = "services-hdfs-native")]
122    opendal_service_hdfs_native::register_hdfs_native_service(registry);
123
124    #[cfg(feature = "services-http")]
125    opendal_service_http::register_http_service(registry);
126
127    #[cfg(feature = "services-hf")]
128    opendal_service_hf::register_hf_service(registry);
129
130    #[cfg(feature = "services-ipfs")]
131    opendal_service_ipfs::register_ipfs_service(registry);
132
133    #[cfg(feature = "services-ipmfs")]
134    opendal_service_ipmfs::register_ipmfs_service(registry);
135
136    #[cfg(feature = "services-koofr")]
137    opendal_service_koofr::register_koofr_service(registry);
138
139    #[cfg(feature = "services-lakefs")]
140    opendal_service_lakefs::register_lakefs_service(registry);
141
142    #[cfg(feature = "services-memcached")]
143    opendal_service_memcached::register_memcached_service(registry);
144
145    #[cfg(feature = "services-mini-moka")]
146    opendal_service_mini_moka::register_mini_moka_service(registry);
147
148    #[cfg(feature = "services-moka")]
149    opendal_service_moka::register_moka_service(registry);
150
151    #[cfg(feature = "services-mongodb")]
152    opendal_service_mongodb::register_mongodb_service(registry);
153
154    #[cfg(feature = "services-monoiofs")]
155    opendal_service_monoiofs::register_monoiofs_service(registry);
156
157    #[cfg(feature = "services-mysql")]
158    opendal_service_mysql::register_mysql_service(registry);
159
160    #[cfg(feature = "services-obs")]
161    opendal_service_obs::register_obs_service(registry);
162
163    #[cfg(feature = "services-onedrive")]
164    opendal_service_onedrive::register_onedrive_service(registry);
165
166    #[cfg(feature = "services-oss")]
167    opendal_service_oss::register_oss_service(registry);
168
169    #[cfg(feature = "services-pcloud")]
170    opendal_service_pcloud::register_pcloud_service(registry);
171
172    #[cfg(feature = "services-persy")]
173    opendal_service_persy::register_persy_service(registry);
174
175    #[cfg(feature = "services-postgresql")]
176    opendal_service_postgresql::register_postgresql_service(registry);
177
178    #[cfg(feature = "services-redb")]
179    opendal_service_redb::register_redb_service(registry);
180
181    #[cfg(feature = "services-rocksdb")]
182    opendal_service_rocksdb::register_rocksdb_service(registry);
183
184    #[cfg(feature = "services-s3")]
185    opendal_service_s3::register_s3_service(registry);
186
187    #[cfg(feature = "services-seafile")]
188    opendal_service_seafile::register_seafile_service(registry);
189
190    #[cfg(feature = "services-sftp")]
191    opendal_service_sftp::register_sftp_service(registry);
192
193    #[cfg(feature = "services-sled")]
194    opendal_service_sled::register_sled_service(registry);
195
196    #[cfg(feature = "services-sqlite")]
197    opendal_service_sqlite::register_sqlite_service(registry);
198
199    #[cfg(feature = "services-surrealdb")]
200    opendal_service_surrealdb::register_surrealdb_service(registry);
201
202    #[cfg(feature = "services-swift")]
203    opendal_service_swift::register_swift_service(registry);
204
205    #[cfg(feature = "services-tikv")]
206    opendal_service_tikv::register_tikv_service(registry);
207
208    #[cfg(feature = "services-upyun")]
209    opendal_service_upyun::register_upyun_service(registry);
210
211    #[cfg(feature = "services-vercel-artifacts")]
212    opendal_service_vercel_artifacts::register_vercel_artifacts_service(registry);
213
214    #[cfg(feature = "services-vercel-blob")]
215    opendal_service_vercel_blob::register_vercel_blob_service(registry);
216
217    #[cfg(feature = "services-webdav")]
218    opendal_service_webdav::register_webdav_service(registry);
219
220    #[cfg(feature = "services-webhdfs")]
221    opendal_service_webhdfs::register_webhdfs_service(registry);
222
223    #[cfg(feature = "services-yandex-disk")]
224    opendal_service_yandex_disk::register_yandex_disk_service(registry);
225
226    #[cfg(all(target_arch = "wasm32", feature = "services-opfs"))]
227    opendal_service_opfs::register_opfs_service(registry);
228
229    #[cfg(any(feature = "services-redis", feature = "services-redis-native-tls"))]
230    opendal_service_redis::register_redis_service(registry);
231}
232
233#[cfg(feature = "auto-register-services")]
234#[ctor::ctor]
235fn register_default_operator_registry() {
236    init_default_registry();
237}
238
239/// Re-export of service implementations.
240pub mod services {
241    pub use opendal_core::services::*;
242    #[cfg(feature = "services-aliyun-drive")]
243    pub use opendal_service_aliyun_drive::*;
244    #[cfg(feature = "services-alluxio")]
245    pub use opendal_service_alluxio::*;
246    #[cfg(feature = "services-azblob")]
247    pub use opendal_service_azblob::*;
248    #[cfg(feature = "services-azdls")]
249    pub use opendal_service_azdls::*;
250    #[cfg(feature = "services-azfile")]
251    pub use opendal_service_azfile::*;
252    #[cfg(feature = "services-b2")]
253    pub use opendal_service_b2::*;
254    #[cfg(feature = "services-cacache")]
255    pub use opendal_service_cacache::*;
256    #[cfg(feature = "services-cloudflare-kv")]
257    pub use opendal_service_cloudflare_kv::*;
258    #[cfg(feature = "services-compfs")]
259    pub use opendal_service_compfs::*;
260    #[cfg(feature = "services-cos")]
261    pub use opendal_service_cos::*;
262    #[cfg(feature = "services-d1")]
263    pub use opendal_service_d1::*;
264    #[cfg(feature = "services-dashmap")]
265    pub use opendal_service_dashmap::*;
266    #[cfg(feature = "services-dbfs")]
267    pub use opendal_service_dbfs::*;
268    #[cfg(feature = "services-dropbox")]
269    pub use opendal_service_dropbox::*;
270    #[cfg(feature = "services-etcd")]
271    pub use opendal_service_etcd::*;
272    #[cfg(feature = "services-foundationdb")]
273    pub use opendal_service_foundationdb::*;
274    #[cfg(feature = "services-fs")]
275    pub use opendal_service_fs::*;
276    #[cfg(feature = "services-ftp")]
277    pub use opendal_service_ftp::*;
278    #[cfg(feature = "services-gcs")]
279    pub use opendal_service_gcs::*;
280    #[cfg(feature = "services-gdrive")]
281    pub use opendal_service_gdrive::*;
282    #[cfg(feature = "services-ghac")]
283    pub use opendal_service_ghac::*;
284    #[cfg(feature = "services-github")]
285    pub use opendal_service_github::*;
286    #[cfg(feature = "services-gridfs")]
287    pub use opendal_service_gridfs::*;
288    #[cfg(feature = "services-hdfs")]
289    pub use opendal_service_hdfs::*;
290    #[cfg(feature = "services-hdfs-native")]
291    pub use opendal_service_hdfs_native::*;
292    #[cfg(feature = "services-hf")]
293    pub use opendal_service_hf::*;
294    #[cfg(feature = "services-http")]
295    pub use opendal_service_http::*;
296    #[cfg(feature = "services-ipfs")]
297    pub use opendal_service_ipfs::*;
298    #[cfg(feature = "services-ipmfs")]
299    pub use opendal_service_ipmfs::*;
300    #[cfg(feature = "services-koofr")]
301    pub use opendal_service_koofr::*;
302    #[cfg(feature = "services-lakefs")]
303    pub use opendal_service_lakefs::*;
304    #[cfg(feature = "services-memcached")]
305    pub use opendal_service_memcached::*;
306    #[cfg(feature = "services-mini-moka")]
307    pub use opendal_service_mini_moka::*;
308    #[cfg(feature = "services-moka")]
309    pub use opendal_service_moka::*;
310    #[cfg(feature = "services-mongodb")]
311    pub use opendal_service_mongodb::*;
312    #[cfg(feature = "services-monoiofs")]
313    pub use opendal_service_monoiofs::*;
314    #[cfg(feature = "services-mysql")]
315    pub use opendal_service_mysql::*;
316    #[cfg(feature = "services-obs")]
317    pub use opendal_service_obs::*;
318    #[cfg(feature = "services-onedrive")]
319    pub use opendal_service_onedrive::*;
320    #[cfg(all(target_arch = "wasm32", feature = "services-opfs"))]
321    pub use opendal_service_opfs::*;
322    #[cfg(feature = "services-oss")]
323    pub use opendal_service_oss::*;
324    #[cfg(feature = "services-pcloud")]
325    pub use opendal_service_pcloud::*;
326    #[cfg(feature = "services-persy")]
327    pub use opendal_service_persy::*;
328    #[cfg(feature = "services-postgresql")]
329    pub use opendal_service_postgresql::*;
330    #[cfg(feature = "services-redb")]
331    pub use opendal_service_redb::*;
332    #[cfg(feature = "services-redis")]
333    pub use opendal_service_redis::*;
334    #[cfg(feature = "services-rocksdb")]
335    pub use opendal_service_rocksdb::*;
336    #[cfg(feature = "services-s3")]
337    pub use opendal_service_s3::*;
338    #[cfg(feature = "services-seafile")]
339    pub use opendal_service_seafile::*;
340    #[cfg(feature = "services-sftp")]
341    pub use opendal_service_sftp::*;
342    #[cfg(feature = "services-sled")]
343    pub use opendal_service_sled::*;
344    #[cfg(feature = "services-sqlite")]
345    pub use opendal_service_sqlite::*;
346    #[cfg(feature = "services-surrealdb")]
347    pub use opendal_service_surrealdb::*;
348    #[cfg(feature = "services-swift")]
349    pub use opendal_service_swift::*;
350    #[cfg(feature = "services-tikv")]
351    pub use opendal_service_tikv::*;
352    #[cfg(feature = "services-upyun")]
353    pub use opendal_service_upyun::*;
354    #[cfg(feature = "services-vercel-artifacts")]
355    pub use opendal_service_vercel_artifacts::*;
356    #[cfg(feature = "services-vercel-blob")]
357    pub use opendal_service_vercel_blob::*;
358    #[cfg(feature = "services-webdav")]
359    pub use opendal_service_webdav::*;
360    #[cfg(feature = "services-webhdfs")]
361    pub use opendal_service_webhdfs::*;
362    #[cfg(feature = "services-yandex-disk")]
363    pub use opendal_service_yandex_disk::*;
364}
365
366/// Re-export of layers.
367pub mod layers {
368    pub use opendal_core::layers::*;
369    #[cfg(feature = "layers-async-backtrace")]
370    pub use opendal_layer_async_backtrace::*;
371    #[cfg(feature = "layers-await-tree")]
372    pub use opendal_layer_await_tree::*;
373    #[cfg(feature = "layers-capability-check")]
374    pub use opendal_layer_capability_check::*;
375    #[cfg(feature = "layers-chaos")]
376    pub use opendal_layer_chaos::*;
377    #[cfg(feature = "layers-concurrent-limit")]
378    pub use opendal_layer_concurrent_limit::*;
379    #[cfg(all(target_os = "linux", feature = "layers-dtrace"))]
380    pub use opendal_layer_dtrace::*;
381    #[cfg(feature = "layers-fastmetrics")]
382    pub use opendal_layer_fastmetrics::*;
383    #[cfg(feature = "layers-fastrace")]
384    pub use opendal_layer_fastrace::*;
385    #[cfg(feature = "layers-foyer")]
386    pub use opendal_layer_foyer::*;
387    #[cfg(feature = "layers-hotpath")]
388    pub use opendal_layer_hotpath::*;
389    #[cfg(feature = "layers-immutable-index")]
390    pub use opendal_layer_immutable_index::*;
391    #[cfg(feature = "layers-logging")]
392    pub use opendal_layer_logging::*;
393    #[cfg(feature = "layers-metrics")]
394    pub use opendal_layer_metrics::*;
395    #[cfg(feature = "layers-mime-guess")]
396    pub use opendal_layer_mime_guess::*;
397    #[cfg(feature = "layers-otel-metrics")]
398    pub use opendal_layer_otelmetrics::*;
399    #[cfg(feature = "layers-otel-trace")]
400    pub use opendal_layer_oteltrace::*;
401    #[cfg(feature = "layers-prometheus")]
402    pub use opendal_layer_prometheus::*;
403    #[cfg(feature = "layers-prometheus-client")]
404    pub use opendal_layer_prometheus_client::*;
405    #[cfg(feature = "layers-retry")]
406    pub use opendal_layer_retry::*;
407    #[cfg(feature = "layers-route")]
408    pub use opendal_layer_route::*;
409    #[cfg(feature = "layers-tail-cut")]
410    pub use opendal_layer_tail_cut::*;
411    #[cfg(feature = "layers-throttle")]
412    pub use opendal_layer_throttle::*;
413    #[cfg(feature = "layers-timeout")]
414    pub use opendal_layer_timeout::*;
415    #[cfg(feature = "layers-tracing")]
416    pub use opendal_layer_tracing::*;
417}