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