opendal 0.1.6.pre.rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.standard.yml +20 -0
- data/.tool-versions +1 -0
- data/.yardopts +1 -0
- data/Cargo.toml +65 -0
- data/DEPENDENCIES.md +9 -0
- data/DEPENDENCIES.rust.tsv +277 -0
- data/Gemfile +35 -0
- data/README.md +159 -0
- data/Rakefile +149 -0
- data/build.rs +22 -0
- data/core/CHANGELOG.md +4929 -0
- data/core/CONTRIBUTING.md +61 -0
- data/core/Cargo.lock +10259 -0
- data/core/Cargo.toml +437 -0
- data/core/DEPENDENCIES.md +3 -0
- data/core/DEPENDENCIES.rust.tsv +185 -0
- data/core/LICENSE +201 -0
- data/core/README.md +228 -0
- data/core/benches/README.md +18 -0
- data/core/benches/ops/README.md +26 -0
- data/core/benches/ops/main.rs +25 -0
- data/core/benches/ops/read.rs +100 -0
- data/core/benches/ops/utils.rs +59 -0
- data/core/benches/ops/write.rs +106 -0
- data/core/benches/types/README.md +9 -0
- data/core/benches/types/buffer.rs +114 -0
- data/core/benches/types/main.rs +23 -0
- data/core/benches/types/tasks.rs +64 -0
- data/core/benches/vs_fs/Cargo.toml +32 -0
- data/core/benches/vs_fs/README.md +35 -0
- data/core/benches/vs_fs/src/main.rs +83 -0
- data/core/benches/vs_s3/Cargo.toml +38 -0
- data/core/benches/vs_s3/README.md +55 -0
- data/core/benches/vs_s3/src/main.rs +123 -0
- data/core/edge/README.md +3 -0
- data/core/edge/file_write_on_full_disk/Cargo.toml +31 -0
- data/core/edge/file_write_on_full_disk/README.md +14 -0
- data/core/edge/file_write_on_full_disk/src/main.rs +43 -0
- data/core/edge/s3_aws_assume_role_with_web_identity/Cargo.toml +30 -0
- data/core/edge/s3_aws_assume_role_with_web_identity/README.md +18 -0
- data/core/edge/s3_aws_assume_role_with_web_identity/src/main.rs +34 -0
- data/core/edge/s3_read_on_wasm/.gitignore +3 -0
- data/core/edge/s3_read_on_wasm/Cargo.toml +38 -0
- data/core/edge/s3_read_on_wasm/README.md +42 -0
- data/core/edge/s3_read_on_wasm/src/lib.rs +60 -0
- data/core/edge/s3_read_on_wasm/webdriver.json +15 -0
- data/core/examples/README.md +23 -0
- data/core/examples/basic/Cargo.toml +29 -0
- data/core/examples/basic/README.md +15 -0
- data/core/examples/basic/src/main.rs +51 -0
- data/core/examples/concurrent-upload/Cargo.toml +29 -0
- data/core/examples/concurrent-upload/README.md +15 -0
- data/core/examples/concurrent-upload/src/main.rs +68 -0
- data/core/examples/multipart-upload/Cargo.toml +29 -0
- data/core/examples/multipart-upload/README.md +15 -0
- data/core/examples/multipart-upload/src/main.rs +56 -0
- data/core/fuzz/.gitignore +5 -0
- data/core/fuzz/Cargo.toml +92 -0
- data/core/fuzz/README.md +68 -0
- data/core/fuzz/fuzz_reader.rs +102 -0
- data/core/fuzz/fuzz_writer.rs +123 -0
- data/core/src/blocking/delete.rs +74 -0
- data/core/src/blocking/list.rs +71 -0
- data/core/src/blocking/mod.rs +33 -0
- data/core/src/blocking/operator.rs +729 -0
- data/core/src/blocking/read/buffer_iterator.rs +66 -0
- data/core/src/blocking/read/mod.rs +27 -0
- data/core/src/blocking/read/reader.rs +124 -0
- data/core/src/blocking/read/std_bytes_iterator.rs +69 -0
- data/core/src/blocking/read/std_reader.rs +95 -0
- data/core/src/blocking/write/mod.rs +22 -0
- data/core/src/blocking/write/std_writer.rs +82 -0
- data/core/src/blocking/write/writer.rs +109 -0
- data/core/src/docs/comparisons/mod.rs +30 -0
- data/core/src/docs/comparisons/vs_object_store.md +183 -0
- data/core/src/docs/concepts.rs +135 -0
- data/core/src/docs/internals/accessor.rs +306 -0
- data/core/src/docs/internals/layer.rs +42 -0
- data/core/src/docs/internals/mod.rs +62 -0
- data/core/src/docs/mod.rs +43 -0
- data/core/src/docs/performance/concurrent_write.md +101 -0
- data/core/src/docs/performance/http_optimization.md +124 -0
- data/core/src/docs/performance/mod.rs +32 -0
- data/core/src/docs/rfcs/0000_example.md +74 -0
- data/core/src/docs/rfcs/0000_foyer_integration.md +111 -0
- data/core/src/docs/rfcs/0041_object_native_api.md +185 -0
- data/core/src/docs/rfcs/0044_error_handle.md +198 -0
- data/core/src/docs/rfcs/0057_auto_region.md +160 -0
- data/core/src/docs/rfcs/0069_object_stream.md +145 -0
- data/core/src/docs/rfcs/0090_limited_reader.md +155 -0
- data/core/src/docs/rfcs/0112_path_normalization.md +79 -0
- data/core/src/docs/rfcs/0191_async_streaming_io.md +328 -0
- data/core/src/docs/rfcs/0203_remove_credential.md +96 -0
- data/core/src/docs/rfcs/0221_create_dir.md +89 -0
- data/core/src/docs/rfcs/0247_retryable_error.md +87 -0
- data/core/src/docs/rfcs/0293_object_id.md +67 -0
- data/core/src/docs/rfcs/0337_dir_entry.md +191 -0
- data/core/src/docs/rfcs/0409_accessor_capabilities.md +67 -0
- data/core/src/docs/rfcs/0413_presign.md +154 -0
- data/core/src/docs/rfcs/0423_command_line_interface.md +268 -0
- data/core/src/docs/rfcs/0429_init_from_iter.md +107 -0
- data/core/src/docs/rfcs/0438_multipart.md +163 -0
- data/core/src/docs/rfcs/0443_gateway.md +73 -0
- data/core/src/docs/rfcs/0501_new_builder.md +111 -0
- data/core/src/docs/rfcs/0554_write_refactor.md +96 -0
- data/core/src/docs/rfcs/0561_list_metadata_reuse.md +210 -0
- data/core/src/docs/rfcs/0599_blocking_api.md +157 -0
- data/core/src/docs/rfcs/0623_redis_service.md +300 -0
- data/core/src/docs/rfcs/0627_split_capabilities.md +89 -0
- data/core/src/docs/rfcs/0661_path_in_accessor.md +126 -0
- data/core/src/docs/rfcs/0793_generic_kv_services.md +209 -0
- data/core/src/docs/rfcs/0926_object_reader.md +93 -0
- data/core/src/docs/rfcs/0977_refactor_error.md +151 -0
- data/core/src/docs/rfcs/1085_object_handler.md +73 -0
- data/core/src/docs/rfcs/1391_object_metadataer.md +110 -0
- data/core/src/docs/rfcs/1398_query_based_metadata.md +125 -0
- data/core/src/docs/rfcs/1420_object_writer.md +147 -0
- data/core/src/docs/rfcs/1477_remove_object_concept.md +159 -0
- data/core/src/docs/rfcs/1735_operation_extension.md +117 -0
- data/core/src/docs/rfcs/2083_writer_sink_api.md +106 -0
- data/core/src/docs/rfcs/2133_append_api.md +88 -0
- data/core/src/docs/rfcs/2299_chain_based_operator_api.md +99 -0
- data/core/src/docs/rfcs/2602_object_versioning.md +138 -0
- data/core/src/docs/rfcs/2758_merge_append_into_write.md +79 -0
- data/core/src/docs/rfcs/2774_lister_api.md +66 -0
- data/core/src/docs/rfcs/2779_list_with_metakey.md +143 -0
- data/core/src/docs/rfcs/2852_native_capability.md +58 -0
- data/core/src/docs/rfcs/2884_merge_range_read_into_read.md +80 -0
- data/core/src/docs/rfcs/3017_remove_write_copy_from.md +94 -0
- data/core/src/docs/rfcs/3197_config.md +237 -0
- data/core/src/docs/rfcs/3232_align_list_api.md +69 -0
- data/core/src/docs/rfcs/3243_list_prefix.md +128 -0
- data/core/src/docs/rfcs/3356_lazy_reader.md +111 -0
- data/core/src/docs/rfcs/3526_list_recursive.md +59 -0
- data/core/src/docs/rfcs/3574_concurrent_stat_in_list.md +80 -0
- data/core/src/docs/rfcs/3734_buffered_reader.md +64 -0
- data/core/src/docs/rfcs/3898_concurrent_writer.md +66 -0
- data/core/src/docs/rfcs/3911_deleter_api.md +165 -0
- data/core/src/docs/rfcs/4382_range_based_read.md +213 -0
- data/core/src/docs/rfcs/4638_executor.md +215 -0
- data/core/src/docs/rfcs/5314_remove_metakey.md +120 -0
- data/core/src/docs/rfcs/5444_operator_from_uri.md +162 -0
- data/core/src/docs/rfcs/5479_context.md +140 -0
- data/core/src/docs/rfcs/5485_conditional_reader.md +112 -0
- data/core/src/docs/rfcs/5495_list_with_deleted.md +81 -0
- data/core/src/docs/rfcs/5556_write_returns_metadata.md +121 -0
- data/core/src/docs/rfcs/5871_read_returns_metadata.md +112 -0
- data/core/src/docs/rfcs/6189_remove_native_blocking.md +106 -0
- data/core/src/docs/rfcs/6209_glob_support.md +132 -0
- data/core/src/docs/rfcs/6213_options_api.md +142 -0
- data/core/src/docs/rfcs/README.md +62 -0
- data/core/src/docs/rfcs/mod.rs +278 -0
- data/core/src/docs/upgrade.md +1556 -0
- data/core/src/layers/async_backtrace.rs +174 -0
- data/core/src/layers/await_tree.rs +202 -0
- data/core/src/layers/capability_check.rs +239 -0
- data/core/src/layers/chaos.rs +170 -0
- data/core/src/layers/complete.rs +385 -0
- data/core/src/layers/concurrent_limit.rs +322 -0
- data/core/src/layers/correctness_check.rs +440 -0
- data/core/src/layers/dtrace.rs +294 -0
- data/core/src/layers/error_context.rs +310 -0
- data/core/src/layers/fastmetrics.rs +525 -0
- data/core/src/layers/fastrace.rs +271 -0
- data/core/src/layers/http_client.rs +206 -0
- data/core/src/layers/immutable_index.rs +408 -0
- data/core/src/layers/logging.rs +842 -0
- data/core/src/layers/metrics.rs +182 -0
- data/core/src/layers/mime_guess.rs +199 -0
- data/core/src/layers/mod.rs +130 -0
- data/core/src/layers/observe/metrics.rs +936 -0
- data/core/src/layers/observe/mod.rs +93 -0
- data/core/src/layers/otelmetrics.rs +496 -0
- data/core/src/layers/oteltrace.rs +203 -0
- data/core/src/layers/prometheus.rs +686 -0
- data/core/src/layers/prometheus_client.rs +519 -0
- data/core/src/layers/retry.rs +933 -0
- data/core/src/layers/throttle.rs +204 -0
- data/core/src/layers/timeout.rs +513 -0
- data/core/src/layers/tracing.rs +349 -0
- data/core/src/layers/type_eraser.rs +91 -0
- data/core/src/lib.rs +204 -0
- data/core/src/raw/accessor.rs +856 -0
- data/core/src/raw/adapters/kv/api.rs +164 -0
- data/core/src/raw/adapters/kv/backend.rs +253 -0
- data/core/src/raw/adapters/kv/mod.rs +31 -0
- data/core/src/raw/adapters/mod.rs +50 -0
- data/core/src/raw/adapters/typed_kv/api.rs +171 -0
- data/core/src/raw/adapters/typed_kv/backend.rs +279 -0
- data/core/src/raw/adapters/typed_kv/mod.rs +29 -0
- data/core/src/raw/atomic_util.rs +57 -0
- data/core/src/raw/azure.rs +570 -0
- data/core/src/raw/chrono_util.rs +109 -0
- data/core/src/raw/enum_utils.rs +201 -0
- data/core/src/raw/futures_util.rs +470 -0
- data/core/src/raw/http_util/body.rs +144 -0
- data/core/src/raw/http_util/bytes_content_range.rs +239 -0
- data/core/src/raw/http_util/bytes_range.rs +260 -0
- data/core/src/raw/http_util/client.rs +276 -0
- data/core/src/raw/http_util/error.rs +68 -0
- data/core/src/raw/http_util/header.rs +356 -0
- data/core/src/raw/http_util/mod.rs +78 -0
- data/core/src/raw/http_util/multipart.rs +1180 -0
- data/core/src/raw/http_util/uri.rs +190 -0
- data/core/src/raw/layer.rs +295 -0
- data/core/src/raw/mod.rs +101 -0
- data/core/src/raw/oio/buf/flex_buf.rs +118 -0
- data/core/src/raw/oio/buf/mod.rs +25 -0
- data/core/src/raw/oio/buf/pooled_buf.rs +126 -0
- data/core/src/raw/oio/buf/queue_buf.rs +117 -0
- data/core/src/raw/oio/delete/api.rs +102 -0
- data/core/src/raw/oio/delete/batch_delete.rs +127 -0
- data/core/src/raw/oio/delete/mod.rs +30 -0
- data/core/src/raw/oio/delete/one_shot_delete.rs +79 -0
- data/core/src/raw/oio/entry.rs +89 -0
- data/core/src/raw/oio/list/api.rs +69 -0
- data/core/src/raw/oio/list/flat_list.rs +137 -0
- data/core/src/raw/oio/list/hierarchy_list.rs +135 -0
- data/core/src/raw/oio/list/mod.rs +35 -0
- data/core/src/raw/oio/list/page_list.rs +105 -0
- data/core/src/raw/oio/list/prefix_list.rs +64 -0
- data/core/src/raw/oio/mod.rs +40 -0
- data/core/src/raw/oio/read/api.rs +119 -0
- data/core/src/raw/oio/read/mod.rs +21 -0
- data/core/src/raw/oio/write/api.rs +103 -0
- data/core/src/raw/oio/write/append_write.rs +111 -0
- data/core/src/raw/oio/write/block_write.rs +405 -0
- data/core/src/raw/oio/write/mod.rs +42 -0
- data/core/src/raw/oio/write/multipart_write.rs +518 -0
- data/core/src/raw/oio/write/one_shot_write.rs +77 -0
- data/core/src/raw/oio/write/position_write.rs +284 -0
- data/core/src/raw/operation.rs +88 -0
- data/core/src/raw/ops.rs +917 -0
- data/core/src/raw/path.rs +451 -0
- data/core/src/raw/path_cache.rs +244 -0
- data/core/src/raw/rps.rs +249 -0
- data/core/src/raw/serde_util.rs +423 -0
- data/core/src/raw/std_io_util.rs +65 -0
- data/core/src/raw/tests/mod.rs +30 -0
- data/core/src/raw/tests/read.rs +116 -0
- data/core/src/raw/tests/utils.rs +80 -0
- data/core/src/raw/tests/write.rs +79 -0
- data/core/src/raw/tokio_util.rs +24 -0
- data/core/src/raw/version.rs +19 -0
- data/core/src/services/aliyun_drive/backend.rs +421 -0
- data/core/src/services/aliyun_drive/config.rs +72 -0
- data/core/src/services/aliyun_drive/core.rs +651 -0
- data/core/src/services/aliyun_drive/delete.rs +51 -0
- data/core/src/services/aliyun_drive/docs.md +61 -0
- data/core/src/services/aliyun_drive/error.rs +56 -0
- data/core/src/services/aliyun_drive/lister.rs +134 -0
- data/core/src/services/aliyun_drive/mod.rs +39 -0
- data/core/src/services/aliyun_drive/writer.rs +114 -0
- data/core/src/services/alluxio/backend.rs +257 -0
- data/core/src/services/alluxio/config.rs +50 -0
- data/core/src/services/alluxio/core.rs +367 -0
- data/core/src/services/alluxio/delete.rs +38 -0
- data/core/src/services/alluxio/docs.md +45 -0
- data/core/src/services/alluxio/error.rs +99 -0
- data/core/src/services/alluxio/lister.rs +73 -0
- data/core/src/services/alluxio/mod.rs +39 -0
- data/core/src/services/alluxio/writer.rs +74 -0
- data/core/src/services/azblob/backend.rs +594 -0
- data/core/src/services/azblob/config.rs +220 -0
- data/core/src/services/azblob/core.rs +937 -0
- data/core/src/services/azblob/delete.rs +108 -0
- data/core/src/services/azblob/docs.md +77 -0
- data/core/src/services/azblob/error.rs +164 -0
- data/core/src/services/azblob/lister.rs +107 -0
- data/core/src/services/azblob/mod.rs +38 -0
- data/core/src/services/azblob/writer.rs +177 -0
- data/core/src/services/azdls/backend.rs +435 -0
- data/core/src/services/azdls/config.rs +89 -0
- data/core/src/services/azdls/core.rs +388 -0
- data/core/src/services/azdls/delete.rs +48 -0
- data/core/src/services/azdls/docs.md +73 -0
- data/core/src/services/azdls/error.rs +107 -0
- data/core/src/services/azdls/lister.rs +165 -0
- data/core/src/services/azdls/mod.rs +38 -0
- data/core/src/services/azdls/writer.rs +129 -0
- data/core/src/services/azfile/backend.rs +373 -0
- data/core/src/services/azfile/config.rs +61 -0
- data/core/src/services/azfile/core.rs +435 -0
- data/core/src/services/azfile/delete.rs +51 -0
- data/core/src/services/azfile/docs.md +65 -0
- data/core/src/services/azfile/error.rs +108 -0
- data/core/src/services/azfile/lister.rs +217 -0
- data/core/src/services/azfile/mod.rs +39 -0
- data/core/src/services/azfile/writer.rs +92 -0
- data/core/src/services/b2/backend.rs +434 -0
- data/core/src/services/b2/config.rs +64 -0
- data/core/src/services/b2/core.rs +742 -0
- data/core/src/services/b2/delete.rs +56 -0
- data/core/src/services/b2/docs.md +54 -0
- data/core/src/services/b2/error.rs +132 -0
- data/core/src/services/b2/lister.rs +110 -0
- data/core/src/services/b2/mod.rs +39 -0
- data/core/src/services/b2/writer.rs +189 -0
- data/core/src/services/cacache/backend.rs +160 -0
- data/core/src/services/cacache/config.rs +28 -0
- data/core/src/services/cacache/core.rs +96 -0
- data/core/src/services/cacache/delete.rs +39 -0
- data/core/src/services/cacache/docs.md +38 -0
- data/core/src/services/cacache/mod.rs +34 -0
- data/core/src/services/cacache/writer.rs +61 -0
- data/core/src/services/cloudflare_kv/backend.rs +513 -0
- data/core/src/services/cloudflare_kv/config.rs +55 -0
- data/core/src/services/cloudflare_kv/core.rs +168 -0
- data/core/src/services/cloudflare_kv/delete.rs +119 -0
- data/core/src/services/cloudflare_kv/docs.md +21 -0
- data/core/src/services/cloudflare_kv/error.rs +79 -0
- data/core/src/services/cloudflare_kv/lister.rs +170 -0
- data/core/src/services/cloudflare_kv/mod.rs +39 -0
- data/core/src/services/cloudflare_kv/model.rs +76 -0
- data/core/src/services/cloudflare_kv/writer.rs +68 -0
- data/core/src/services/compfs/backend.rs +290 -0
- data/core/src/services/compfs/config.rs +30 -0
- data/core/src/services/compfs/core.rs +159 -0
- data/core/src/services/compfs/delete.rs +53 -0
- data/core/src/services/compfs/lister.rs +98 -0
- data/core/src/services/compfs/mod.rs +38 -0
- data/core/src/services/compfs/reader.rs +79 -0
- data/core/src/services/compfs/writer.rs +90 -0
- data/core/src/services/cos/backend.rs +442 -0
- data/core/src/services/cos/config.rs +54 -0
- data/core/src/services/cos/core.rs +761 -0
- data/core/src/services/cos/delete.rs +48 -0
- data/core/src/services/cos/docs.md +55 -0
- data/core/src/services/cos/error.rs +105 -0
- data/core/src/services/cos/lister.rs +237 -0
- data/core/src/services/cos/mod.rs +39 -0
- data/core/src/services/cos/writer.rs +234 -0
- data/core/src/services/d1/backend.rs +330 -0
- data/core/src/services/d1/config.rs +55 -0
- data/core/src/services/d1/docs.md +48 -0
- data/core/src/services/d1/error.rs +79 -0
- data/core/src/services/d1/mod.rs +29 -0
- data/core/src/services/d1/model.rs +125 -0
- data/core/src/services/dashmap/backend.rs +203 -0
- data/core/src/services/dashmap/config.rs +37 -0
- data/core/src/services/dashmap/core.rs +61 -0
- data/core/src/services/dashmap/delete.rs +40 -0
- data/core/src/services/dashmap/docs.md +38 -0
- data/core/src/services/dashmap/lister.rs +63 -0
- data/core/src/services/dashmap/mod.rs +36 -0
- data/core/src/services/dashmap/writer.rs +87 -0
- data/core/src/services/dbfs/backend.rs +258 -0
- data/core/src/services/dbfs/config.rs +48 -0
- data/core/src/services/dbfs/core.rs +191 -0
- data/core/src/services/dbfs/delete.rs +49 -0
- data/core/src/services/dbfs/docs.md +57 -0
- data/core/src/services/dbfs/error.rs +74 -0
- data/core/src/services/dbfs/lister.rs +96 -0
- data/core/src/services/dbfs/mod.rs +38 -0
- data/core/src/services/dbfs/writer.rs +64 -0
- data/core/src/services/dropbox/backend.rs +187 -0
- data/core/src/services/dropbox/builder.rs +222 -0
- data/core/src/services/dropbox/config.rs +47 -0
- data/core/src/services/dropbox/core.rs +496 -0
- data/core/src/services/dropbox/delete.rs +54 -0
- data/core/src/services/dropbox/docs.md +64 -0
- data/core/src/services/dropbox/error.rs +85 -0
- data/core/src/services/dropbox/lister.rs +117 -0
- data/core/src/services/dropbox/mod.rs +40 -0
- data/core/src/services/dropbox/writer.rs +51 -0
- data/core/src/services/etcd/backend.rs +345 -0
- data/core/src/services/etcd/config.rs +86 -0
- data/core/src/services/etcd/core.rs +143 -0
- data/core/src/services/etcd/deleter.rs +41 -0
- data/core/src/services/etcd/docs.md +45 -0
- data/core/src/services/etcd/error.rs +26 -0
- data/core/src/services/etcd/lister.rs +79 -0
- data/core/src/services/etcd/mod.rs +36 -0
- data/core/src/services/etcd/writer.rs +61 -0
- data/core/src/services/foundationdb/backend.rs +171 -0
- data/core/src/services/foundationdb/config.rs +45 -0
- data/core/src/services/foundationdb/docs.md +42 -0
- data/core/src/services/foundationdb/mod.rs +24 -0
- data/core/src/services/fs/backend.rs +299 -0
- data/core/src/services/fs/config.rs +33 -0
- data/core/src/services/fs/core.rs +227 -0
- data/core/src/services/fs/delete.rs +53 -0
- data/core/src/services/fs/docs.md +49 -0
- data/core/src/services/fs/error.rs +31 -0
- data/core/src/services/fs/lister.rs +81 -0
- data/core/src/services/fs/mod.rs +40 -0
- data/core/src/services/fs/reader.rs +83 -0
- data/core/src/services/fs/writer.rs +212 -0
- data/core/src/services/ftp/backend.rs +388 -0
- data/core/src/services/ftp/config.rs +46 -0
- data/core/src/services/ftp/core.rs +136 -0
- data/core/src/services/ftp/delete.rs +62 -0
- data/core/src/services/ftp/docs.md +42 -0
- data/core/src/services/ftp/err.rs +47 -0
- data/core/src/services/ftp/lister.rs +72 -0
- data/core/src/services/ftp/mod.rs +41 -0
- data/core/src/services/ftp/reader.rs +84 -0
- data/core/src/services/ftp/writer.rs +122 -0
- data/core/src/services/gcs/backend.rs +499 -0
- data/core/src/services/gcs/config.rs +168 -0
- data/core/src/services/gcs/core.rs +1079 -0
- data/core/src/services/gcs/delete.rs +98 -0
- data/core/src/services/gcs/docs.md +76 -0
- data/core/src/services/gcs/error.rs +122 -0
- data/core/src/services/gcs/lister.rs +136 -0
- data/core/src/services/gcs/mod.rs +40 -0
- data/core/src/services/gcs/uri.rs +75 -0
- data/core/src/services/gcs/writer.rs +163 -0
- data/core/src/services/gdrive/backend.rs +176 -0
- data/core/src/services/gdrive/builder.rs +228 -0
- data/core/src/services/gdrive/config.rs +47 -0
- data/core/src/services/gdrive/core.rs +499 -0
- data/core/src/services/gdrive/delete.rs +57 -0
- data/core/src/services/gdrive/docs.md +65 -0
- data/core/src/services/gdrive/error.rs +80 -0
- data/core/src/services/gdrive/lister.rs +110 -0
- data/core/src/services/gdrive/mod.rs +40 -0
- data/core/src/services/gdrive/writer.rs +77 -0
- data/core/src/services/ghac/backend.rs +285 -0
- data/core/src/services/ghac/config.rs +36 -0
- data/core/src/services/ghac/core.rs +459 -0
- data/core/src/services/ghac/docs.md +84 -0
- data/core/src/services/ghac/error.rs +52 -0
- data/core/src/services/ghac/mod.rs +35 -0
- data/core/src/services/ghac/writer.rs +201 -0
- data/core/src/services/github/backend.rs +285 -0
- data/core/src/services/github/config.rs +59 -0
- data/core/src/services/github/core.rs +351 -0
- data/core/src/services/github/delete.rs +41 -0
- data/core/src/services/github/docs.md +52 -0
- data/core/src/services/github/error.rs +101 -0
- data/core/src/services/github/lister.rs +112 -0
- data/core/src/services/github/mod.rs +38 -0
- data/core/src/services/github/writer.rs +51 -0
- data/core/src/services/gridfs/backend.rs +166 -0
- data/core/src/services/gridfs/config.rs +50 -0
- data/core/src/services/gridfs/core.rs +154 -0
- data/core/src/services/gridfs/docs.md +46 -0
- data/core/src/services/gridfs/mod.rs +26 -0
- data/core/src/services/hdfs/backend.rs +413 -0
- data/core/src/services/hdfs/config.rs +59 -0
- data/core/src/services/hdfs/delete.rs +62 -0
- data/core/src/services/hdfs/docs.md +140 -0
- data/core/src/services/hdfs/lister.rs +70 -0
- data/core/src/services/hdfs/mod.rs +36 -0
- data/core/src/services/hdfs/reader.rs +79 -0
- data/core/src/services/hdfs/writer.rs +104 -0
- data/core/src/services/hdfs_native/backend.rs +340 -0
- data/core/src/services/hdfs_native/config.rs +45 -0
- data/core/src/services/hdfs_native/delete.rs +47 -0
- data/core/src/services/hdfs_native/docs.md +35 -0
- data/core/src/services/hdfs_native/error.rs +59 -0
- data/core/src/services/hdfs_native/lister.rs +85 -0
- data/core/src/services/hdfs_native/mod.rs +39 -0
- data/core/src/services/hdfs_native/reader.rs +62 -0
- data/core/src/services/hdfs_native/writer.rs +61 -0
- data/core/src/services/http/backend.rs +291 -0
- data/core/src/services/http/config.rs +49 -0
- data/core/src/services/http/core.rs +125 -0
- data/core/src/services/http/docs.md +45 -0
- data/core/src/services/http/error.rs +53 -0
- data/core/src/services/http/mod.rs +32 -0
- data/core/src/services/huggingface/backend.rs +289 -0
- data/core/src/services/huggingface/config.rs +75 -0
- data/core/src/services/huggingface/core.rs +406 -0
- data/core/src/services/huggingface/docs.md +61 -0
- data/core/src/services/huggingface/error.rs +93 -0
- data/core/src/services/huggingface/lister.rs +91 -0
- data/core/src/services/huggingface/mod.rs +34 -0
- data/core/src/services/ipfs/backend.rs +257 -0
- data/core/src/services/ipfs/config.rs +32 -0
- data/core/src/services/ipfs/core.rs +239 -0
- data/core/src/services/ipfs/docs.md +45 -0
- data/core/src/services/ipfs/error.rs +52 -0
- data/core/src/services/ipfs/ipld.rs +162 -0
- data/core/src/services/ipfs/mod.rs +34 -0
- data/core/src/services/ipmfs/backend.rs +147 -0
- data/core/src/services/ipmfs/builder.rs +166 -0
- data/core/src/services/ipmfs/config.rs +32 -0
- data/core/src/services/ipmfs/core.rs +142 -0
- data/core/src/services/ipmfs/delete.rs +48 -0
- data/core/src/services/ipmfs/docs.md +14 -0
- data/core/src/services/ipmfs/error.rs +83 -0
- data/core/src/services/ipmfs/lister.rs +135 -0
- data/core/src/services/ipmfs/mod.rs +40 -0
- data/core/src/services/ipmfs/writer.rs +49 -0
- data/core/src/services/koofr/backend.rs +361 -0
- data/core/src/services/koofr/config.rs +50 -0
- data/core/src/services/koofr/core.rs +458 -0
- data/core/src/services/koofr/delete.rs +50 -0
- data/core/src/services/koofr/docs.md +51 -0
- data/core/src/services/koofr/error.rs +72 -0
- data/core/src/services/koofr/lister.rs +88 -0
- data/core/src/services/koofr/mod.rs +38 -0
- data/core/src/services/koofr/writer.rs +53 -0
- data/core/src/services/lakefs/backend.rs +309 -0
- data/core/src/services/lakefs/config.rs +81 -0
- data/core/src/services/lakefs/core.rs +261 -0
- data/core/src/services/lakefs/delete.rs +54 -0
- data/core/src/services/lakefs/docs.md +62 -0
- data/core/src/services/lakefs/error.rs +93 -0
- data/core/src/services/lakefs/lister.rs +120 -0
- data/core/src/services/lakefs/mod.rs +38 -0
- data/core/src/services/lakefs/writer.rs +50 -0
- data/core/src/services/memcached/backend.rs +284 -0
- data/core/src/services/memcached/binary.rs +289 -0
- data/core/src/services/memcached/config.rs +43 -0
- data/core/src/services/memcached/docs.md +47 -0
- data/core/src/services/memcached/mod.rs +27 -0
- data/core/src/services/memory/backend.rs +205 -0
- data/core/src/services/memory/config.rs +30 -0
- data/core/src/services/memory/core.rs +80 -0
- data/core/src/services/memory/delete.rs +42 -0
- data/core/src/services/memory/docs.md +36 -0
- data/core/src/services/memory/lister.rs +56 -0
- data/core/src/services/memory/mod.rs +36 -0
- data/core/src/services/memory/writer.rs +85 -0
- data/core/src/services/mini_moka/backend.rs +260 -0
- data/core/src/services/mini_moka/config.rs +56 -0
- data/core/src/services/mini_moka/core.rs +52 -0
- data/core/src/services/mini_moka/delete.rs +42 -0
- data/core/src/services/mini_moka/docs.md +19 -0
- data/core/src/services/mini_moka/lister.rs +68 -0
- data/core/src/services/mini_moka/mod.rs +36 -0
- data/core/src/services/mini_moka/writer.rs +84 -0
- data/core/src/services/mod.rs +206 -0
- data/core/src/services/moka/backend.rs +326 -0
- data/core/src/services/moka/config.rs +59 -0
- data/core/src/services/moka/core.rs +62 -0
- data/core/src/services/moka/delete.rs +42 -0
- data/core/src/services/moka/docs.md +42 -0
- data/core/src/services/moka/lister.rs +65 -0
- data/core/src/services/moka/mod.rs +41 -0
- data/core/src/services/moka/writer.rs +83 -0
- data/core/src/services/mongodb/backend.rs +291 -0
- data/core/src/services/mongodb/config.rs +54 -0
- data/core/src/services/mongodb/docs.md +49 -0
- data/core/src/services/mongodb/mod.rs +24 -0
- data/core/src/services/monoiofs/backend.rs +238 -0
- data/core/src/services/monoiofs/config.rs +34 -0
- data/core/src/services/monoiofs/core.rs +313 -0
- data/core/src/services/monoiofs/delete.rs +64 -0
- data/core/src/services/monoiofs/docs.md +46 -0
- data/core/src/services/monoiofs/mod.rs +36 -0
- data/core/src/services/monoiofs/reader.rs +147 -0
- data/core/src/services/monoiofs/writer.rs +189 -0
- data/core/src/services/mysql/backend.rs +256 -0
- data/core/src/services/mysql/config.rs +66 -0
- data/core/src/services/mysql/docs.md +47 -0
- data/core/src/services/mysql/mod.rs +24 -0
- data/core/src/services/obs/backend.rs +442 -0
- data/core/src/services/obs/config.rs +53 -0
- data/core/src/services/obs/core.rs +608 -0
- data/core/src/services/obs/delete.rs +48 -0
- data/core/src/services/obs/docs.md +54 -0
- data/core/src/services/obs/error.rs +106 -0
- data/core/src/services/obs/lister.rs +101 -0
- data/core/src/services/obs/mod.rs +38 -0
- data/core/src/services/obs/writer.rs +235 -0
- data/core/src/services/onedrive/backend.rs +127 -0
- data/core/src/services/onedrive/builder.rs +236 -0
- data/core/src/services/onedrive/config.rs +49 -0
- data/core/src/services/onedrive/core.rs +691 -0
- data/core/src/services/onedrive/delete.rs +47 -0
- data/core/src/services/onedrive/docs.md +115 -0
- data/core/src/services/onedrive/error.rs +61 -0
- data/core/src/services/onedrive/graph_model.rs +425 -0
- data/core/src/services/onedrive/lister.rs +150 -0
- data/core/src/services/onedrive/mod.rs +42 -0
- data/core/src/services/onedrive/writer.rs +168 -0
- data/core/src/services/opfs/backend.rs +50 -0
- data/core/src/services/opfs/config.rs +25 -0
- data/core/src/services/opfs/core.rs +74 -0
- data/core/src/services/opfs/docs.md +18 -0
- data/core/src/services/opfs/error.rs +27 -0
- data/core/src/services/opfs/mod.rs +30 -0
- data/core/src/services/opfs/utils.rs +70 -0
- data/core/src/services/oss/backend.rs +734 -0
- data/core/src/services/oss/config.rs +113 -0
- data/core/src/services/oss/core.rs +1088 -0
- data/core/src/services/oss/delete.rs +109 -0
- data/core/src/services/oss/docs.md +74 -0
- data/core/src/services/oss/error.rs +109 -0
- data/core/src/services/oss/lister.rs +256 -0
- data/core/src/services/oss/mod.rs +38 -0
- data/core/src/services/oss/writer.rs +228 -0
- data/core/src/services/pcloud/backend.rs +358 -0
- data/core/src/services/pcloud/config.rs +51 -0
- data/core/src/services/pcloud/core.rs +461 -0
- data/core/src/services/pcloud/delete.rs +66 -0
- data/core/src/services/pcloud/docs.md +51 -0
- data/core/src/services/pcloud/error.rs +88 -0
- data/core/src/services/pcloud/lister.rs +95 -0
- data/core/src/services/pcloud/mod.rs +38 -0
- data/core/src/services/pcloud/writer.rs +66 -0
- data/core/src/services/persy/backend.rs +226 -0
- data/core/src/services/persy/config.rs +32 -0
- data/core/src/services/persy/docs.md +43 -0
- data/core/src/services/persy/mod.rs +24 -0
- data/core/src/services/postgresql/backend.rs +258 -0
- data/core/src/services/postgresql/config.rs +66 -0
- data/core/src/services/postgresql/docs.md +47 -0
- data/core/src/services/postgresql/mod.rs +24 -0
- data/core/src/services/redb/backend.rs +280 -0
- data/core/src/services/redb/config.rs +34 -0
- data/core/src/services/redb/docs.md +41 -0
- data/core/src/services/redb/mod.rs +24 -0
- data/core/src/services/redis/backend.rs +442 -0
- data/core/src/services/redis/config.rs +79 -0
- data/core/src/services/redis/core.rs +209 -0
- data/core/src/services/redis/delete.rs +40 -0
- data/core/src/services/redis/docs.md +43 -0
- data/core/src/services/redis/mod.rs +34 -0
- data/core/src/services/redis/writer.rs +57 -0
- data/core/src/services/rocksdb/backend.rs +159 -0
- data/core/src/services/rocksdb/config.rs +34 -0
- data/core/src/services/rocksdb/docs.md +54 -0
- data/core/src/services/rocksdb/mod.rs +24 -0
- data/core/src/services/s3/backend.rs +1293 -0
- data/core/src/services/s3/compatible_services.md +126 -0
- data/core/src/services/s3/config.rs +327 -0
- data/core/src/services/s3/core.rs +1741 -0
- data/core/src/services/s3/delete.rs +109 -0
- data/core/src/services/s3/docs.md +244 -0
- data/core/src/services/s3/error.rs +171 -0
- data/core/src/services/s3/lister.rs +405 -0
- data/core/src/services/s3/mod.rs +38 -0
- data/core/src/services/s3/writer.rs +262 -0
- data/core/src/services/seafile/backend.rs +297 -0
- data/core/src/services/seafile/config.rs +56 -0
- data/core/src/services/seafile/core.rs +475 -0
- data/core/src/services/seafile/delete.rs +40 -0
- data/core/src/services/seafile/docs.md +54 -0
- data/core/src/services/seafile/error.rs +86 -0
- data/core/src/services/seafile/lister.rs +83 -0
- data/core/src/services/seafile/mod.rs +38 -0
- data/core/src/services/seafile/writer.rs +55 -0
- data/core/src/services/sftp/backend.rs +397 -0
- data/core/src/services/sftp/config.rs +50 -0
- data/core/src/services/sftp/core.rs +154 -0
- data/core/src/services/sftp/delete.rs +55 -0
- data/core/src/services/sftp/docs.md +49 -0
- data/core/src/services/sftp/error.rs +57 -0
- data/core/src/services/sftp/lister.rs +88 -0
- data/core/src/services/sftp/mod.rs +42 -0
- data/core/src/services/sftp/reader.rs +78 -0
- data/core/src/services/sftp/utils.rs +51 -0
- data/core/src/services/sftp/writer.rs +67 -0
- data/core/src/services/sled/backend.rs +194 -0
- data/core/src/services/sled/config.rs +45 -0
- data/core/src/services/sled/docs.md +39 -0
- data/core/src/services/sled/mod.rs +24 -0
- data/core/src/services/sqlite/backend.rs +326 -0
- data/core/src/services/sqlite/config.rs +70 -0
- data/core/src/services/sqlite/docs.md +46 -0
- data/core/src/services/sqlite/mod.rs +24 -0
- data/core/src/services/surrealdb/backend.rs +365 -0
- data/core/src/services/surrealdb/config.rs +64 -0
- data/core/src/services/surrealdb/docs.md +54 -0
- data/core/src/services/surrealdb/mod.rs +24 -0
- data/core/src/services/swift/backend.rs +275 -0
- data/core/src/services/swift/compatible_services.md +53 -0
- data/core/src/services/swift/config.rs +53 -0
- data/core/src/services/swift/core.rs +310 -0
- data/core/src/services/swift/delete.rs +49 -0
- data/core/src/services/swift/docs.md +52 -0
- data/core/src/services/swift/error.rs +90 -0
- data/core/src/services/swift/lister.rs +119 -0
- data/core/src/services/swift/mod.rs +38 -0
- data/core/src/services/swift/writer.rs +53 -0
- data/core/src/services/tikv/backend.rs +237 -0
- data/core/src/services/tikv/config.rs +52 -0
- data/core/src/services/tikv/docs.md +43 -0
- data/core/src/services/tikv/mod.rs +24 -0
- data/core/src/services/upyun/backend.rs +317 -0
- data/core/src/services/upyun/config.rs +51 -0
- data/core/src/services/upyun/core.rs +521 -0
- data/core/src/services/upyun/delete.rs +50 -0
- data/core/src/services/upyun/docs.md +51 -0
- data/core/src/services/upyun/error.rs +97 -0
- data/core/src/services/upyun/lister.rs +101 -0
- data/core/src/services/upyun/mod.rs +38 -0
- data/core/src/services/upyun/writer.rs +127 -0
- data/core/src/services/vercel_artifacts/backend.rs +99 -0
- data/core/src/services/vercel_artifacts/builder.rs +117 -0
- data/core/src/services/vercel_artifacts/config.rs +39 -0
- data/core/src/services/vercel_artifacts/core.rs +112 -0
- data/core/src/services/vercel_artifacts/docs.md +40 -0
- data/core/src/services/vercel_artifacts/error.rs +50 -0
- data/core/src/services/vercel_artifacts/mod.rs +36 -0
- data/core/src/services/vercel_artifacts/writer.rs +58 -0
- data/core/src/services/vercel_blob/backend.rs +251 -0
- data/core/src/services/vercel_blob/config.rs +45 -0
- data/core/src/services/vercel_blob/core.rs +449 -0
- data/core/src/services/vercel_blob/delete.rs +38 -0
- data/core/src/services/vercel_blob/docs.md +45 -0
- data/core/src/services/vercel_blob/error.rs +110 -0
- data/core/src/services/vercel_blob/lister.rs +69 -0
- data/core/src/services/vercel_blob/mod.rs +38 -0
- data/core/src/services/vercel_blob/writer.rs +143 -0
- data/core/src/services/webdav/backend.rs +318 -0
- data/core/src/services/webdav/config.rs +53 -0
- data/core/src/services/webdav/core.rs +859 -0
- data/core/src/services/webdav/delete.rs +47 -0
- data/core/src/services/webdav/docs.md +49 -0
- data/core/src/services/webdav/error.rs +53 -0
- data/core/src/services/webdav/lister.rs +106 -0
- data/core/src/services/webdav/mod.rs +38 -0
- data/core/src/services/webdav/writer.rs +56 -0
- data/core/src/services/webhdfs/backend.rs +376 -0
- data/core/src/services/webhdfs/config.rs +52 -0
- data/core/src/services/webhdfs/core.rs +398 -0
- data/core/src/services/webhdfs/delete.rs +46 -0
- data/core/src/services/webhdfs/docs.md +90 -0
- data/core/src/services/webhdfs/error.rs +126 -0
- data/core/src/services/webhdfs/lister.rs +130 -0
- data/core/src/services/webhdfs/message.rs +249 -0
- data/core/src/services/webhdfs/mod.rs +41 -0
- data/core/src/services/webhdfs/writer.rs +177 -0
- data/core/src/services/yandex_disk/backend.rs +267 -0
- data/core/src/services/yandex_disk/config.rs +45 -0
- data/core/src/services/yandex_disk/core.rs +340 -0
- data/core/src/services/yandex_disk/delete.rs +54 -0
- data/core/src/services/yandex_disk/docs.md +45 -0
- data/core/src/services/yandex_disk/error.rs +104 -0
- data/core/src/services/yandex_disk/lister.rs +113 -0
- data/core/src/services/yandex_disk/mod.rs +38 -0
- data/core/src/services/yandex_disk/writer.rs +52 -0
- data/core/src/types/buffer.rs +991 -0
- data/core/src/types/builder.rs +152 -0
- data/core/src/types/capability.rs +209 -0
- data/core/src/types/context/mod.rs +22 -0
- data/core/src/types/context/read.rs +231 -0
- data/core/src/types/context/write.rs +441 -0
- data/core/src/types/delete/deleter.rs +220 -0
- data/core/src/types/delete/futures_delete_sink.rs +176 -0
- data/core/src/types/delete/input.rs +97 -0
- data/core/src/types/delete/mod.rs +26 -0
- data/core/src/types/entry.rs +69 -0
- data/core/src/types/error.rs +570 -0
- data/core/src/types/execute/api.rs +110 -0
- data/core/src/types/execute/executor.rs +96 -0
- data/core/src/types/execute/executors/mod.rs +27 -0
- data/core/src/types/execute/executors/tokio_executor.rs +60 -0
- data/core/src/types/execute/mod.rs +25 -0
- data/core/src/types/list.rs +137 -0
- data/core/src/types/metadata.rs +436 -0
- data/core/src/types/mod.rs +72 -0
- data/core/src/types/mode.rs +68 -0
- data/core/src/types/operator/builder.rs +535 -0
- data/core/src/types/operator/info.rs +63 -0
- data/core/src/types/operator/mod.rs +33 -0
- data/core/src/types/operator/operator.rs +2236 -0
- data/core/src/types/operator/operator_futures.rs +1430 -0
- data/core/src/types/operator/registry.rs +129 -0
- data/core/src/types/options.rs +548 -0
- data/core/src/types/read/buffer_stream.rs +273 -0
- data/core/src/types/read/futures_async_reader.rs +289 -0
- data/core/src/types/read/futures_bytes_stream.rs +157 -0
- data/core/src/types/read/mod.rs +29 -0
- data/core/src/types/read/reader.rs +604 -0
- data/core/src/types/scheme.rs +475 -0
- data/core/src/types/write/buffer_sink.rs +188 -0
- data/core/src/types/write/futures_async_writer.rs +136 -0
- data/core/src/types/write/futures_bytes_sink.rs +103 -0
- data/core/src/types/write/mod.rs +26 -0
- data/core/src/types/write/writer.rs +411 -0
- data/core/tests/behavior/README.md +77 -0
- data/core/tests/behavior/async_copy.rs +314 -0
- data/core/tests/behavior/async_create_dir.rs +53 -0
- data/core/tests/behavior/async_delete.rs +354 -0
- data/core/tests/behavior/async_list.rs +739 -0
- data/core/tests/behavior/async_presign.rs +175 -0
- data/core/tests/behavior/async_read.rs +871 -0
- data/core/tests/behavior/async_rename.rs +210 -0
- data/core/tests/behavior/async_stat.rs +628 -0
- data/core/tests/behavior/async_write.rs +819 -0
- data/core/tests/behavior/main.rs +78 -0
- data/core/tests/behavior/utils.rs +187 -0
- data/core/tests/data/normal_dir/.gitkeep +0 -0
- data/core/tests/data/normal_file.txt +1041 -0
- data/core/tests/data/special_dir !@#$%^&()_+-=;',/.gitkeep +0 -0
- data/core/tests/data/special_file !@#$%^&()_+-=;',.txt +1041 -0
- data/core/users.md +13 -0
- data/extconf.rb +24 -0
- data/lib/opendal.rb +25 -0
- data/lib/opendal_ruby/entry.rb +35 -0
- data/lib/opendal_ruby/io.rb +70 -0
- data/lib/opendal_ruby/metadata.rb +44 -0
- data/lib/opendal_ruby/operator.rb +29 -0
- data/lib/opendal_ruby/operator_info.rb +26 -0
- data/src/capability.rs +146 -0
- data/src/io.rs +464 -0
- data/src/lib.rs +63 -0
- data/src/lister.rs +141 -0
- data/src/metadata.rs +111 -0
- data/src/middlewares.rs +174 -0
- data/src/operator.rs +310 -0
- data/src/operator_info.rs +83 -0
- data/test/blocking_op_test.rb +112 -0
- data/test/capability_test.rb +42 -0
- data/test/io_test.rb +172 -0
- data/test/lister_test.rb +77 -0
- data/test/metadata_test.rb +78 -0
- data/test/middlewares_test.rb +46 -0
- data/test/operator_info_test.rb +35 -0
- data/test/test_helper.rb +36 -0
- metadata +857 -0
|
@@ -0,0 +1,859 @@
|
|
|
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
|
+
use std::collections::VecDeque;
|
|
19
|
+
use std::fmt;
|
|
20
|
+
use std::fmt::Debug;
|
|
21
|
+
use std::fmt::Formatter;
|
|
22
|
+
use std::sync::Arc;
|
|
23
|
+
|
|
24
|
+
use bytes::Bytes;
|
|
25
|
+
use http::header;
|
|
26
|
+
use http::Request;
|
|
27
|
+
use http::Response;
|
|
28
|
+
use http::StatusCode;
|
|
29
|
+
use serde::Deserialize;
|
|
30
|
+
|
|
31
|
+
use super::error::parse_error;
|
|
32
|
+
use crate::raw::*;
|
|
33
|
+
use crate::*;
|
|
34
|
+
|
|
35
|
+
/// The request to query all properties of a file or directory.
|
|
36
|
+
///
|
|
37
|
+
/// rfc4918 9.1: retrieve all properties define in specification
|
|
38
|
+
static PROPFIND_REQUEST: &str = r#"<?xml version="1.0" encoding="utf-8" ?><D:propfind xmlns:D="DAV:"><D:allprop/></D:propfind>"#;
|
|
39
|
+
|
|
40
|
+
/// The header to specify the depth of the query.
|
|
41
|
+
///
|
|
42
|
+
/// Valid values are `0`, `1`, `infinity`.
|
|
43
|
+
///
|
|
44
|
+
/// - `0`: only to the resource itself.
|
|
45
|
+
/// - `1`: to the resource and its internal members only.
|
|
46
|
+
/// - `infinity`: to the resource and all its members.
|
|
47
|
+
///
|
|
48
|
+
/// reference: [RFC4918: 10.2. Depth Header](https://datatracker.ietf.org/doc/html/rfc4918#section-10.2)
|
|
49
|
+
static HEADER_DEPTH: &str = "Depth";
|
|
50
|
+
/// The header to specify the destination of the query.
|
|
51
|
+
///
|
|
52
|
+
/// The Destination request header specifies the URI that identifies a
|
|
53
|
+
/// destination resource for methods such as COPY and MOVE, which take
|
|
54
|
+
/// two URIs as parameters.
|
|
55
|
+
///
|
|
56
|
+
/// reference: [RFC4918: 10.3. Destination Header](https://datatracker.ietf.org/doc/html/rfc4918#section-10.3)
|
|
57
|
+
static HEADER_DESTINATION: &str = "Destination";
|
|
58
|
+
/// The header to specify the overwrite behavior of the query
|
|
59
|
+
///
|
|
60
|
+
/// The Overwrite request header specifies whether the server should
|
|
61
|
+
/// overwrite a resource mapped to the destination URL during a COPY or
|
|
62
|
+
/// MOVE.
|
|
63
|
+
///
|
|
64
|
+
/// Valid values are `T` and `F`.
|
|
65
|
+
///
|
|
66
|
+
/// A value of "F" states that the server must not perform the COPY or MOVE operation
|
|
67
|
+
/// if the destination URL does map to a resource.
|
|
68
|
+
///
|
|
69
|
+
/// reference: [RFC4918: 10.6. Overwrite Header](https://datatracker.ietf.org/doc/html/rfc4918#section-10.6)
|
|
70
|
+
static HEADER_OVERWRITE: &str = "Overwrite";
|
|
71
|
+
|
|
72
|
+
pub struct WebdavCore {
|
|
73
|
+
pub info: Arc<AccessorInfo>,
|
|
74
|
+
pub endpoint: String,
|
|
75
|
+
pub server_path: String,
|
|
76
|
+
pub root: String,
|
|
77
|
+
pub authorization: Option<String>,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
impl Debug for WebdavCore {
|
|
81
|
+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
|
82
|
+
f.debug_struct("WebdavCore")
|
|
83
|
+
.field("endpoint", &self.endpoint)
|
|
84
|
+
.field("root", &self.root)
|
|
85
|
+
.finish_non_exhaustive()
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
impl WebdavCore {
|
|
90
|
+
pub async fn webdav_stat(&self, path: &str) -> Result<Metadata> {
|
|
91
|
+
let path = build_rooted_abs_path(&self.root, path);
|
|
92
|
+
self.webdav_stat_rooted_abs_path(&path).await
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/// Input path must be `rooted_abs_path`.
|
|
96
|
+
async fn webdav_stat_rooted_abs_path(&self, rooted_abs_path: &str) -> Result<Metadata> {
|
|
97
|
+
let url = format!("{}{}", self.endpoint, percent_encode_path(rooted_abs_path));
|
|
98
|
+
let mut req = Request::builder().method("PROPFIND").uri(url);
|
|
99
|
+
|
|
100
|
+
req = req.header(header::CONTENT_TYPE, "application/xml");
|
|
101
|
+
req = req.header(header::CONTENT_LENGTH, PROPFIND_REQUEST.len());
|
|
102
|
+
if let Some(auth) = &self.authorization {
|
|
103
|
+
req = req.header(header::AUTHORIZATION, auth);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Only stat the resource itself.
|
|
107
|
+
req = req.header(HEADER_DEPTH, "0");
|
|
108
|
+
|
|
109
|
+
let req = req
|
|
110
|
+
.extension(Operation::Stat)
|
|
111
|
+
.body(Buffer::from(Bytes::from(PROPFIND_REQUEST)))
|
|
112
|
+
.map_err(new_request_build_error)?;
|
|
113
|
+
|
|
114
|
+
let resp = self.info.http_client().send(req).await?;
|
|
115
|
+
if !resp.status().is_success() {
|
|
116
|
+
return Err(parse_error(resp));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
let bs = resp.into_body();
|
|
120
|
+
|
|
121
|
+
let result: Multistatus = deserialize_multistatus(&bs.to_bytes())?;
|
|
122
|
+
let propfind_resp = result.response.first().ok_or_else(|| {
|
|
123
|
+
Error::new(
|
|
124
|
+
ErrorKind::NotFound,
|
|
125
|
+
"propfind response is empty, the resource is not exist",
|
|
126
|
+
)
|
|
127
|
+
})?;
|
|
128
|
+
|
|
129
|
+
let metadata = parse_propstat(&propfind_resp.propstat)?;
|
|
130
|
+
Ok(metadata)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
pub async fn webdav_get(
|
|
134
|
+
&self,
|
|
135
|
+
path: &str,
|
|
136
|
+
range: BytesRange,
|
|
137
|
+
_: &OpRead,
|
|
138
|
+
) -> Result<Response<HttpBody>> {
|
|
139
|
+
let path = build_rooted_abs_path(&self.root, path);
|
|
140
|
+
let url: String = format!("{}{}", self.endpoint, percent_encode_path(&path));
|
|
141
|
+
|
|
142
|
+
let mut req = Request::get(&url);
|
|
143
|
+
|
|
144
|
+
if let Some(auth) = &self.authorization {
|
|
145
|
+
req = req.header(header::AUTHORIZATION, auth.clone())
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if !range.is_full() {
|
|
149
|
+
req = req.header(header::RANGE, range.to_header());
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
let req = req
|
|
153
|
+
.extension(Operation::Read)
|
|
154
|
+
.body(Buffer::new())
|
|
155
|
+
.map_err(new_request_build_error)?;
|
|
156
|
+
|
|
157
|
+
self.info.http_client().fetch(req).await
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
pub async fn webdav_put(
|
|
161
|
+
&self,
|
|
162
|
+
path: &str,
|
|
163
|
+
size: Option<u64>,
|
|
164
|
+
args: &OpWrite,
|
|
165
|
+
body: Buffer,
|
|
166
|
+
) -> Result<Response<Buffer>> {
|
|
167
|
+
let path = build_rooted_abs_path(&self.root, path);
|
|
168
|
+
let url = format!("{}{}", self.endpoint, percent_encode_path(&path));
|
|
169
|
+
|
|
170
|
+
let mut req = Request::put(&url);
|
|
171
|
+
|
|
172
|
+
if let Some(v) = &self.authorization {
|
|
173
|
+
req = req.header(header::AUTHORIZATION, v)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if let Some(v) = size {
|
|
177
|
+
req = req.header(header::CONTENT_LENGTH, v)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if let Some(v) = args.content_type() {
|
|
181
|
+
req = req.header(header::CONTENT_TYPE, v)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if let Some(v) = args.content_disposition() {
|
|
185
|
+
req = req.header(header::CONTENT_DISPOSITION, v)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
let req = req
|
|
189
|
+
.extension(Operation::Write)
|
|
190
|
+
.body(body)
|
|
191
|
+
.map_err(new_request_build_error)?;
|
|
192
|
+
|
|
193
|
+
self.info.http_client().send(req).await
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
pub async fn webdav_delete(&self, path: &str) -> Result<Response<Buffer>> {
|
|
197
|
+
let path = build_rooted_abs_path(&self.root, path);
|
|
198
|
+
let url = format!("{}{}", self.endpoint, percent_encode_path(&path));
|
|
199
|
+
|
|
200
|
+
let mut req = Request::delete(&url);
|
|
201
|
+
|
|
202
|
+
if let Some(auth) = &self.authorization {
|
|
203
|
+
req = req.header(header::AUTHORIZATION, auth.clone())
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
let req = req
|
|
207
|
+
.extension(Operation::Delete)
|
|
208
|
+
.body(Buffer::new())
|
|
209
|
+
.map_err(new_request_build_error)?;
|
|
210
|
+
|
|
211
|
+
self.info.http_client().send(req).await
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
pub async fn webdav_copy(&self, from: &str, to: &str) -> Result<Response<Buffer>> {
|
|
215
|
+
// Check if source file exists.
|
|
216
|
+
let _ = self.webdav_stat(from).await?;
|
|
217
|
+
// Make sure target's dir is exist.
|
|
218
|
+
self.webdav_mkcol(get_parent(to)).await?;
|
|
219
|
+
|
|
220
|
+
let source = build_rooted_abs_path(&self.root, from);
|
|
221
|
+
let source_uri = format!("{}{}", self.endpoint, percent_encode_path(&source));
|
|
222
|
+
|
|
223
|
+
let target = build_rooted_abs_path(&self.root, to);
|
|
224
|
+
let target_uri = format!("{}{}", self.endpoint, percent_encode_path(&target));
|
|
225
|
+
|
|
226
|
+
let mut req = Request::builder().method("COPY").uri(&source_uri);
|
|
227
|
+
|
|
228
|
+
if let Some(auth) = &self.authorization {
|
|
229
|
+
req = req.header(header::AUTHORIZATION, auth);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
req = req.header(HEADER_DESTINATION, target_uri);
|
|
233
|
+
req = req.header(HEADER_OVERWRITE, "T");
|
|
234
|
+
|
|
235
|
+
let req = req
|
|
236
|
+
.extension(Operation::Copy)
|
|
237
|
+
.body(Buffer::new())
|
|
238
|
+
.map_err(new_request_build_error)?;
|
|
239
|
+
|
|
240
|
+
self.info.http_client().send(req).await
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
pub async fn webdav_move(&self, from: &str, to: &str) -> Result<Response<Buffer>> {
|
|
244
|
+
// Check if source file exists.
|
|
245
|
+
let _ = self.webdav_stat(from).await?;
|
|
246
|
+
// Make sure target's dir is exist.
|
|
247
|
+
self.webdav_mkcol(get_parent(to)).await?;
|
|
248
|
+
|
|
249
|
+
let source = build_rooted_abs_path(&self.root, from);
|
|
250
|
+
let source_uri = format!("{}{}", self.endpoint, percent_encode_path(&source));
|
|
251
|
+
|
|
252
|
+
let target = build_rooted_abs_path(&self.root, to);
|
|
253
|
+
let target_uri = format!("{}{}", self.endpoint, percent_encode_path(&target));
|
|
254
|
+
|
|
255
|
+
let mut req = Request::builder().method("MOVE").uri(&source_uri);
|
|
256
|
+
|
|
257
|
+
if let Some(auth) = &self.authorization {
|
|
258
|
+
req = req.header(header::AUTHORIZATION, auth);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
req = req.header(HEADER_DESTINATION, target_uri);
|
|
262
|
+
req = req.header(HEADER_OVERWRITE, "T");
|
|
263
|
+
|
|
264
|
+
let req = req
|
|
265
|
+
.extension(Operation::Rename)
|
|
266
|
+
.body(Buffer::new())
|
|
267
|
+
.map_err(new_request_build_error)?;
|
|
268
|
+
|
|
269
|
+
self.info.http_client().send(req).await
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
pub async fn webdav_list(&self, path: &str, args: &OpList) -> Result<Response<Buffer>> {
|
|
273
|
+
let path = build_rooted_abs_path(&self.root, path);
|
|
274
|
+
let url = format!("{}{}", self.endpoint, percent_encode_path(&path));
|
|
275
|
+
|
|
276
|
+
let mut req = Request::builder().method("PROPFIND").uri(&url);
|
|
277
|
+
|
|
278
|
+
req = req.header(header::CONTENT_TYPE, "application/xml");
|
|
279
|
+
req = req.header(header::CONTENT_LENGTH, PROPFIND_REQUEST.len());
|
|
280
|
+
if let Some(auth) = &self.authorization {
|
|
281
|
+
req = req.header(header::AUTHORIZATION, auth);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if args.recursive() {
|
|
285
|
+
req = req.header(HEADER_DEPTH, "infinity");
|
|
286
|
+
} else {
|
|
287
|
+
req = req.header(HEADER_DEPTH, "1");
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
let req = req
|
|
291
|
+
.extension(Operation::List)
|
|
292
|
+
.body(Buffer::from(Bytes::from(PROPFIND_REQUEST)))
|
|
293
|
+
.map_err(new_request_build_error)?;
|
|
294
|
+
|
|
295
|
+
self.info.http_client().send(req).await
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/// Create dir recursively for given path.
|
|
299
|
+
///
|
|
300
|
+
/// # Notes
|
|
301
|
+
///
|
|
302
|
+
/// We only expose this method to the backend since there are dependencies on input path.
|
|
303
|
+
pub async fn webdav_mkcol(&self, path: &str) -> Result<()> {
|
|
304
|
+
let path = build_rooted_abs_path(&self.root, path);
|
|
305
|
+
let mut path = path.as_str();
|
|
306
|
+
|
|
307
|
+
let mut dirs = VecDeque::default();
|
|
308
|
+
|
|
309
|
+
loop {
|
|
310
|
+
match self.webdav_stat_rooted_abs_path(path).await {
|
|
311
|
+
// Dir exists, break the loop.
|
|
312
|
+
Ok(_) => {
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
// Dir not found, keep going.
|
|
316
|
+
Err(err) if err.kind() == ErrorKind::NotFound => {
|
|
317
|
+
dirs.push_front(path);
|
|
318
|
+
path = get_parent(path);
|
|
319
|
+
}
|
|
320
|
+
// Unexpected error found, return it.
|
|
321
|
+
Err(err) => return Err(err),
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if path == "/" {
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
for dir in dirs {
|
|
330
|
+
self.webdav_mkcol_rooted_abs_path(dir).await?;
|
|
331
|
+
}
|
|
332
|
+
Ok(())
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/// Create a dir
|
|
336
|
+
///
|
|
337
|
+
/// Input path must be `rooted_abs_path`
|
|
338
|
+
///
|
|
339
|
+
/// Reference: [RFC4918: 9.3.1. MKCOL Status Codes](https://datatracker.ietf.org/doc/html/rfc4918#section-9.3.1)
|
|
340
|
+
async fn webdav_mkcol_rooted_abs_path(&self, rooted_abs_path: &str) -> Result<()> {
|
|
341
|
+
let url = format!("{}{}", self.endpoint, percent_encode_path(rooted_abs_path));
|
|
342
|
+
|
|
343
|
+
let mut req = Request::builder().method("MKCOL").uri(&url);
|
|
344
|
+
|
|
345
|
+
if let Some(auth) = &self.authorization {
|
|
346
|
+
req = req.header(header::AUTHORIZATION, auth.clone())
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
let req = req
|
|
350
|
+
.extension(Operation::CreateDir)
|
|
351
|
+
.body(Buffer::new())
|
|
352
|
+
.map_err(new_request_build_error)?;
|
|
353
|
+
|
|
354
|
+
let resp = self.info.http_client().send(req).await?;
|
|
355
|
+
let status = resp.status();
|
|
356
|
+
|
|
357
|
+
match status {
|
|
358
|
+
// 201 (Created) - The collection was created.
|
|
359
|
+
StatusCode::CREATED
|
|
360
|
+
// 405 (Method Not Allowed) - MKCOL can only be executed on an unmapped URL.
|
|
361
|
+
//
|
|
362
|
+
// The MKCOL method can only be performed on a deleted or non-existent resource.
|
|
363
|
+
// This error means the directory already exists which is allowed by create_dir.
|
|
364
|
+
| StatusCode::METHOD_NOT_ALLOWED => {
|
|
365
|
+
|
|
366
|
+
Ok(())
|
|
367
|
+
}
|
|
368
|
+
_ => Err(parse_error(resp)),
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
pub fn deserialize_multistatus(bs: &[u8]) -> Result<Multistatus> {
|
|
374
|
+
let s = String::from_utf8_lossy(bs);
|
|
375
|
+
// HACKS! HACKS! HACKS!
|
|
376
|
+
//
|
|
377
|
+
// Make sure the string is escaped.
|
|
378
|
+
// Related to <https://github.com/tafia/quick-xml/issues/719>
|
|
379
|
+
//
|
|
380
|
+
// This is a temporary solution, we should find a better way to handle this.
|
|
381
|
+
let s = s.replace("&()_+-=;", "%26%28%29_%2B-%3D%3B");
|
|
382
|
+
|
|
383
|
+
quick_xml::de::from_str(&s).map_err(new_xml_deserialize_error)
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
pub fn parse_propstat(propstat: &Propstat) -> Result<Metadata> {
|
|
387
|
+
let Propstat {
|
|
388
|
+
prop:
|
|
389
|
+
Prop {
|
|
390
|
+
getlastmodified,
|
|
391
|
+
getcontentlength,
|
|
392
|
+
getcontenttype,
|
|
393
|
+
getetag,
|
|
394
|
+
resourcetype,
|
|
395
|
+
..
|
|
396
|
+
},
|
|
397
|
+
status,
|
|
398
|
+
} = propstat;
|
|
399
|
+
|
|
400
|
+
if let [_, code, text] = status.splitn(3, ' ').collect::<Vec<_>>()[..3] {
|
|
401
|
+
// As defined in https://tools.ietf.org/html/rfc2068#section-6.1
|
|
402
|
+
let code = code.parse::<u16>().unwrap();
|
|
403
|
+
if code >= 400 {
|
|
404
|
+
return Err(Error::new(
|
|
405
|
+
ErrorKind::Unexpected,
|
|
406
|
+
format!("propfind response is unexpected: {code} {text}"),
|
|
407
|
+
));
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
let mode: EntryMode = if resourcetype.value == Some(ResourceType::Collection) {
|
|
412
|
+
EntryMode::DIR
|
|
413
|
+
} else {
|
|
414
|
+
EntryMode::FILE
|
|
415
|
+
};
|
|
416
|
+
let mut m = Metadata::new(mode);
|
|
417
|
+
|
|
418
|
+
if let Some(v) = getcontentlength {
|
|
419
|
+
m.set_content_length(v.parse::<u64>().unwrap());
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if let Some(v) = getcontenttype {
|
|
423
|
+
m.set_content_type(v);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
if let Some(v) = getetag {
|
|
427
|
+
m.set_etag(v);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// https://www.rfc-editor.org/rfc/rfc4918#section-14.18
|
|
431
|
+
m.set_last_modified(parse_datetime_from_rfc2822(getlastmodified)?);
|
|
432
|
+
|
|
433
|
+
// the storage services have returned all the properties
|
|
434
|
+
Ok(m)
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
#[derive(Deserialize, Debug, PartialEq, Eq, Clone, Default)]
|
|
438
|
+
#[serde(default)]
|
|
439
|
+
pub struct Multistatus {
|
|
440
|
+
pub response: Vec<PropfindResponse>,
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
#[derive(Deserialize, Debug, PartialEq, Eq, Clone)]
|
|
444
|
+
pub struct PropfindResponse {
|
|
445
|
+
pub href: String,
|
|
446
|
+
pub propstat: Propstat,
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
#[derive(Deserialize, Debug, PartialEq, Eq, Clone)]
|
|
450
|
+
pub struct Propstat {
|
|
451
|
+
pub status: String,
|
|
452
|
+
pub prop: Prop,
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
#[derive(Deserialize, Debug, PartialEq, Eq, Clone)]
|
|
456
|
+
pub struct Prop {
|
|
457
|
+
pub getlastmodified: String,
|
|
458
|
+
pub getetag: Option<String>,
|
|
459
|
+
pub getcontentlength: Option<String>,
|
|
460
|
+
pub getcontenttype: Option<String>,
|
|
461
|
+
pub resourcetype: ResourceTypeContainer,
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
#[derive(Deserialize, Debug, PartialEq, Eq, Clone)]
|
|
465
|
+
pub struct ResourceTypeContainer {
|
|
466
|
+
#[serde(rename = "$value")]
|
|
467
|
+
pub value: Option<ResourceType>,
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
#[derive(Deserialize, Debug, PartialEq, Eq, Clone)]
|
|
471
|
+
#[serde(rename_all = "lowercase")]
|
|
472
|
+
pub enum ResourceType {
|
|
473
|
+
Collection,
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
#[cfg(test)]
|
|
477
|
+
mod tests {
|
|
478
|
+
use quick_xml::de::from_str;
|
|
479
|
+
|
|
480
|
+
use super::*;
|
|
481
|
+
|
|
482
|
+
#[test]
|
|
483
|
+
fn test_propstat() {
|
|
484
|
+
let xml = r#"<D:propstat>
|
|
485
|
+
<D:prop>
|
|
486
|
+
<D:displayname>/</D:displayname>
|
|
487
|
+
<D:getlastmodified>Tue, 01 May 2022 06:39:47 GMT</D:getlastmodified>
|
|
488
|
+
<D:resourcetype><D:collection/></D:resourcetype>
|
|
489
|
+
<D:lockdiscovery/>
|
|
490
|
+
<D:supportedlock>
|
|
491
|
+
<D:lockentry>
|
|
492
|
+
<D:lockscope><D:exclusive/></D:lockscope>
|
|
493
|
+
<D:locktype><D:write/></D:locktype>
|
|
494
|
+
</D:lockentry>
|
|
495
|
+
</D:supportedlock>
|
|
496
|
+
</D:prop>
|
|
497
|
+
<D:status>HTTP/1.1 200 OK</D:status>
|
|
498
|
+
</D:propstat>"#;
|
|
499
|
+
|
|
500
|
+
let propstat = from_str::<Propstat>(xml).unwrap();
|
|
501
|
+
assert_eq!(
|
|
502
|
+
propstat.prop.getlastmodified,
|
|
503
|
+
"Tue, 01 May 2022 06:39:47 GMT"
|
|
504
|
+
);
|
|
505
|
+
assert_eq!(
|
|
506
|
+
propstat.prop.resourcetype.value.unwrap(),
|
|
507
|
+
ResourceType::Collection
|
|
508
|
+
);
|
|
509
|
+
|
|
510
|
+
assert_eq!(propstat.status, "HTTP/1.1 200 OK");
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
#[test]
|
|
514
|
+
fn test_response_simple() {
|
|
515
|
+
let xml = r#"<D:response>
|
|
516
|
+
<D:href>/</D:href>
|
|
517
|
+
<D:propstat>
|
|
518
|
+
<D:prop>
|
|
519
|
+
<D:displayname>/</D:displayname>
|
|
520
|
+
<D:getlastmodified>Tue, 01 May 2022 06:39:47 GMT</D:getlastmodified>
|
|
521
|
+
<D:resourcetype><D:collection/></D:resourcetype>
|
|
522
|
+
<D:lockdiscovery/>
|
|
523
|
+
<D:supportedlock>
|
|
524
|
+
<D:lockentry>
|
|
525
|
+
<D:lockscope><D:exclusive/></D:lockscope>
|
|
526
|
+
<D:locktype><D:write/></D:locktype>
|
|
527
|
+
</D:lockentry>
|
|
528
|
+
</D:supportedlock>
|
|
529
|
+
</D:prop>
|
|
530
|
+
<D:status>HTTP/1.1 200 OK</D:status>
|
|
531
|
+
</D:propstat>
|
|
532
|
+
</D:response>"#;
|
|
533
|
+
|
|
534
|
+
let response = from_str::<PropfindResponse>(xml).unwrap();
|
|
535
|
+
assert_eq!(response.href, "/");
|
|
536
|
+
|
|
537
|
+
assert_eq!(
|
|
538
|
+
response.propstat.prop.getlastmodified,
|
|
539
|
+
"Tue, 01 May 2022 06:39:47 GMT"
|
|
540
|
+
);
|
|
541
|
+
assert_eq!(
|
|
542
|
+
response.propstat.prop.resourcetype.value.unwrap(),
|
|
543
|
+
ResourceType::Collection
|
|
544
|
+
);
|
|
545
|
+
assert_eq!(response.propstat.status, "HTTP/1.1 200 OK");
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
#[test]
|
|
549
|
+
fn test_response_file() {
|
|
550
|
+
let xml = r#"<D:response>
|
|
551
|
+
<D:href>/test_file</D:href>
|
|
552
|
+
<D:propstat>
|
|
553
|
+
<D:prop>
|
|
554
|
+
<D:displayname>test_file</D:displayname>
|
|
555
|
+
<D:getcontentlength>1</D:getcontentlength>
|
|
556
|
+
<D:getlastmodified>Tue, 07 May 2022 05:52:22 GMT</D:getlastmodified>
|
|
557
|
+
<D:resourcetype></D:resourcetype>
|
|
558
|
+
<D:lockdiscovery />
|
|
559
|
+
<D:supportedlock>
|
|
560
|
+
<D:lockentry>
|
|
561
|
+
<D:lockscope>
|
|
562
|
+
<D:exclusive />
|
|
563
|
+
</D:lockscope>
|
|
564
|
+
<D:locktype>
|
|
565
|
+
<D:write />
|
|
566
|
+
</D:locktype>
|
|
567
|
+
</D:lockentry>
|
|
568
|
+
</D:supportedlock>
|
|
569
|
+
</D:prop>
|
|
570
|
+
<D:status>HTTP/1.1 200 OK</D:status>
|
|
571
|
+
</D:propstat>
|
|
572
|
+
</D:response>"#;
|
|
573
|
+
|
|
574
|
+
let response = from_str::<PropfindResponse>(xml).unwrap();
|
|
575
|
+
assert_eq!(response.href, "/test_file");
|
|
576
|
+
assert_eq!(
|
|
577
|
+
response.propstat.prop.getlastmodified,
|
|
578
|
+
"Tue, 07 May 2022 05:52:22 GMT"
|
|
579
|
+
);
|
|
580
|
+
assert_eq!(response.propstat.prop.getcontentlength.unwrap(), "1");
|
|
581
|
+
assert_eq!(response.propstat.prop.resourcetype.value, None);
|
|
582
|
+
assert_eq!(response.propstat.status, "HTTP/1.1 200 OK");
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
#[test]
|
|
586
|
+
fn test_with_multiple_items_simple() {
|
|
587
|
+
let xml = r#"<D:multistatus xmlns:D="DAV:">
|
|
588
|
+
<D:response>
|
|
589
|
+
<D:href>/</D:href>
|
|
590
|
+
<D:propstat>
|
|
591
|
+
<D:prop>
|
|
592
|
+
<D:displayname>/</D:displayname>
|
|
593
|
+
<D:getlastmodified>Tue, 01 May 2022 06:39:47 GMT</D:getlastmodified>
|
|
594
|
+
<D:resourcetype><D:collection/></D:resourcetype>
|
|
595
|
+
<D:lockdiscovery/>
|
|
596
|
+
<D:supportedlock>
|
|
597
|
+
<D:lockentry>
|
|
598
|
+
<D:lockscope><D:exclusive/></D:lockscope>
|
|
599
|
+
<D:locktype><D:write/></D:locktype>
|
|
600
|
+
</D:lockentry>
|
|
601
|
+
</D:supportedlock>
|
|
602
|
+
</D:prop>
|
|
603
|
+
<D:status>HTTP/1.1 200 OK</D:status>
|
|
604
|
+
</D:propstat>
|
|
605
|
+
</D:response>
|
|
606
|
+
<D:response>
|
|
607
|
+
<D:href>/</D:href>
|
|
608
|
+
<D:propstat>
|
|
609
|
+
<D:prop>
|
|
610
|
+
<D:displayname>/</D:displayname>
|
|
611
|
+
<D:getlastmodified>Tue, 01 May 2022 06:39:47 GMT</D:getlastmodified>
|
|
612
|
+
<D:resourcetype><D:collection/></D:resourcetype>
|
|
613
|
+
<D:lockdiscovery/>
|
|
614
|
+
<D:supportedlock>
|
|
615
|
+
<D:lockentry>
|
|
616
|
+
<D:lockscope><D:exclusive/></D:lockscope>
|
|
617
|
+
<D:locktype><D:write/></D:locktype>
|
|
618
|
+
</D:lockentry>
|
|
619
|
+
</D:supportedlock>
|
|
620
|
+
</D:prop>
|
|
621
|
+
<D:status>HTTP/1.1 200 OK</D:status>
|
|
622
|
+
</D:propstat>
|
|
623
|
+
</D:response>
|
|
624
|
+
</D:multistatus>"#;
|
|
625
|
+
|
|
626
|
+
let multistatus = from_str::<Multistatus>(xml).unwrap();
|
|
627
|
+
|
|
628
|
+
let response = multistatus.response;
|
|
629
|
+
assert_eq!(response.len(), 2);
|
|
630
|
+
assert_eq!(response[0].href, "/");
|
|
631
|
+
assert_eq!(
|
|
632
|
+
response[0].propstat.prop.getlastmodified,
|
|
633
|
+
"Tue, 01 May 2022 06:39:47 GMT"
|
|
634
|
+
);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
#[test]
|
|
638
|
+
fn test_with_multiple_items_mixed() {
|
|
639
|
+
let xml = r#"<?xml version="1.0" encoding="utf-8"?>
|
|
640
|
+
<D:multistatus xmlns:D="DAV:">
|
|
641
|
+
<D:response>
|
|
642
|
+
<D:href>/</D:href>
|
|
643
|
+
<D:propstat>
|
|
644
|
+
<D:prop>
|
|
645
|
+
<D:displayname>/</D:displayname>
|
|
646
|
+
<D:getlastmodified>Tue, 07 May 2022 06:39:47 GMT</D:getlastmodified>
|
|
647
|
+
<D:resourcetype>
|
|
648
|
+
<D:collection />
|
|
649
|
+
</D:resourcetype>
|
|
650
|
+
<D:lockdiscovery />
|
|
651
|
+
<D:supportedlock>
|
|
652
|
+
<D:lockentry>
|
|
653
|
+
<D:lockscope>
|
|
654
|
+
<D:exclusive />
|
|
655
|
+
</D:lockscope>
|
|
656
|
+
<D:locktype>
|
|
657
|
+
<D:write />
|
|
658
|
+
</D:locktype>
|
|
659
|
+
</D:lockentry>
|
|
660
|
+
</D:supportedlock>
|
|
661
|
+
</D:prop>
|
|
662
|
+
<D:status>HTTP/1.1 200 OK</D:status>
|
|
663
|
+
</D:propstat>
|
|
664
|
+
</D:response>
|
|
665
|
+
<D:response>
|
|
666
|
+
<D:href>/testdir/</D:href>
|
|
667
|
+
<D:propstat>
|
|
668
|
+
<D:prop>
|
|
669
|
+
<D:displayname>testdir</D:displayname>
|
|
670
|
+
<D:getlastmodified>Tue, 07 May 2022 06:40:10 GMT</D:getlastmodified>
|
|
671
|
+
<D:resourcetype>
|
|
672
|
+
<D:collection />
|
|
673
|
+
</D:resourcetype>
|
|
674
|
+
<D:lockdiscovery />
|
|
675
|
+
<D:supportedlock>
|
|
676
|
+
<D:lockentry>
|
|
677
|
+
<D:lockscope>
|
|
678
|
+
<D:exclusive />
|
|
679
|
+
</D:lockscope>
|
|
680
|
+
<D:locktype>
|
|
681
|
+
<D:write />
|
|
682
|
+
</D:locktype>
|
|
683
|
+
</D:lockentry>
|
|
684
|
+
</D:supportedlock>
|
|
685
|
+
</D:prop>
|
|
686
|
+
<D:status>HTTP/1.1 200 OK</D:status>
|
|
687
|
+
</D:propstat>
|
|
688
|
+
</D:response>
|
|
689
|
+
<D:response>
|
|
690
|
+
<D:href>/test_file</D:href>
|
|
691
|
+
<D:propstat>
|
|
692
|
+
<D:prop>
|
|
693
|
+
<D:displayname>test_file</D:displayname>
|
|
694
|
+
<D:getcontentlength>1</D:getcontentlength>
|
|
695
|
+
<D:getlastmodified>Tue, 07 May 2022 05:52:22 GMT</D:getlastmodified>
|
|
696
|
+
<D:resourcetype></D:resourcetype>
|
|
697
|
+
<D:lockdiscovery />
|
|
698
|
+
<D:supportedlock>
|
|
699
|
+
<D:lockentry>
|
|
700
|
+
<D:lockscope>
|
|
701
|
+
<D:exclusive />
|
|
702
|
+
</D:lockscope>
|
|
703
|
+
<D:locktype>
|
|
704
|
+
<D:write />
|
|
705
|
+
</D:locktype>
|
|
706
|
+
</D:lockentry>
|
|
707
|
+
</D:supportedlock>
|
|
708
|
+
</D:prop>
|
|
709
|
+
<D:status>HTTP/1.1 200 OK</D:status>
|
|
710
|
+
</D:propstat>
|
|
711
|
+
</D:response>
|
|
712
|
+
</D:multistatus>"#;
|
|
713
|
+
|
|
714
|
+
let multistatus = from_str::<Multistatus>(xml).unwrap();
|
|
715
|
+
|
|
716
|
+
let response = multistatus.response;
|
|
717
|
+
assert_eq!(response.len(), 3);
|
|
718
|
+
let first_response = &response[0];
|
|
719
|
+
assert_eq!(first_response.href, "/");
|
|
720
|
+
assert_eq!(
|
|
721
|
+
first_response.propstat.prop.getlastmodified,
|
|
722
|
+
"Tue, 07 May 2022 06:39:47 GMT"
|
|
723
|
+
);
|
|
724
|
+
|
|
725
|
+
let second_response = &response[1];
|
|
726
|
+
assert_eq!(second_response.href, "/testdir/");
|
|
727
|
+
assert_eq!(
|
|
728
|
+
second_response.propstat.prop.getlastmodified,
|
|
729
|
+
"Tue, 07 May 2022 06:40:10 GMT"
|
|
730
|
+
);
|
|
731
|
+
|
|
732
|
+
let third_response = &response[2];
|
|
733
|
+
assert_eq!(third_response.href, "/test_file");
|
|
734
|
+
assert_eq!(
|
|
735
|
+
third_response.propstat.prop.getlastmodified,
|
|
736
|
+
"Tue, 07 May 2022 05:52:22 GMT"
|
|
737
|
+
);
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
#[test]
|
|
741
|
+
fn test_with_multiple_items_mixed_nginx() {
|
|
742
|
+
let xml = r#"<?xml version="1.0" encoding="utf-8"?>
|
|
743
|
+
<D:multistatus xmlns:D="DAV:">
|
|
744
|
+
<D:response>
|
|
745
|
+
<D:href>/</D:href>
|
|
746
|
+
<D:propstat>
|
|
747
|
+
<D:prop>
|
|
748
|
+
<D:getlastmodified>Fri, 17 Feb 2023 03:37:22 GMT</D:getlastmodified>
|
|
749
|
+
<D:resourcetype>
|
|
750
|
+
<D:collection />
|
|
751
|
+
</D:resourcetype>
|
|
752
|
+
</D:prop>
|
|
753
|
+
<D:status>HTTP/1.1 200 OK</D:status>
|
|
754
|
+
</D:propstat>
|
|
755
|
+
</D:response>
|
|
756
|
+
<D:response>
|
|
757
|
+
<D:href>/test_file_75</D:href>
|
|
758
|
+
<D:propstat>
|
|
759
|
+
<D:prop>
|
|
760
|
+
<D:getcontentlength>1</D:getcontentlength>
|
|
761
|
+
<D:getlastmodified>Fri, 17 Feb 2023 03:36:54 GMT</D:getlastmodified>
|
|
762
|
+
<D:resourcetype></D:resourcetype>
|
|
763
|
+
</D:prop>
|
|
764
|
+
<D:status>HTTP/1.1 200 OK</D:status>
|
|
765
|
+
</D:propstat>
|
|
766
|
+
</D:response>
|
|
767
|
+
<D:response>
|
|
768
|
+
<D:href>/test_file_36</D:href>
|
|
769
|
+
<D:propstat>
|
|
770
|
+
<D:prop>
|
|
771
|
+
<D:getcontentlength>1</D:getcontentlength>
|
|
772
|
+
<D:getlastmodified>Fri, 17 Feb 2023 03:36:54 GMT</D:getlastmodified>
|
|
773
|
+
<D:resourcetype></D:resourcetype>
|
|
774
|
+
</D:prop>
|
|
775
|
+
<D:status>HTTP/1.1 200 OK</D:status>
|
|
776
|
+
</D:propstat>
|
|
777
|
+
</D:response>
|
|
778
|
+
<D:response>
|
|
779
|
+
<D:href>/test_file_38</D:href>
|
|
780
|
+
<D:propstat>
|
|
781
|
+
<D:prop>
|
|
782
|
+
<D:getcontentlength>1</D:getcontentlength>
|
|
783
|
+
<D:getlastmodified>Fri, 17 Feb 2023 03:36:54 GMT</D:getlastmodified>
|
|
784
|
+
<D:resourcetype></D:resourcetype>
|
|
785
|
+
</D:prop>
|
|
786
|
+
<D:status>HTTP/1.1 200 OK</D:status>
|
|
787
|
+
</D:propstat>
|
|
788
|
+
</D:response>
|
|
789
|
+
<D:response>
|
|
790
|
+
<D:href>/test_file_59</D:href>
|
|
791
|
+
<D:propstat>
|
|
792
|
+
<D:prop>
|
|
793
|
+
<D:getcontentlength>1</D:getcontentlength>
|
|
794
|
+
<D:getlastmodified>Fri, 17 Feb 2023 03:36:54 GMT</D:getlastmodified>
|
|
795
|
+
<D:resourcetype></D:resourcetype>
|
|
796
|
+
</D:prop>
|
|
797
|
+
<D:status>HTTP/1.1 200 OK</D:status>
|
|
798
|
+
</D:propstat>
|
|
799
|
+
</D:response>
|
|
800
|
+
<D:response>
|
|
801
|
+
<D:href>/test_file_9</D:href>
|
|
802
|
+
<D:propstat>
|
|
803
|
+
<D:prop>
|
|
804
|
+
<D:getcontentlength>1</D:getcontentlength>
|
|
805
|
+
<D:getlastmodified>Fri, 17 Feb 2023 03:36:54 GMT</D:getlastmodified>
|
|
806
|
+
<D:resourcetype></D:resourcetype>
|
|
807
|
+
</D:prop>
|
|
808
|
+
<D:status>HTTP/1.1 200 OK</D:status>
|
|
809
|
+
</D:propstat>
|
|
810
|
+
</D:response>
|
|
811
|
+
<D:response>
|
|
812
|
+
<D:href>/test_file_93</D:href>
|
|
813
|
+
<D:propstat>
|
|
814
|
+
<D:prop>
|
|
815
|
+
<D:getcontentlength>1</D:getcontentlength>
|
|
816
|
+
<D:getlastmodified>Fri, 17 Feb 2023 03:36:54 GMT</D:getlastmodified>
|
|
817
|
+
<D:resourcetype></D:resourcetype>
|
|
818
|
+
</D:prop>
|
|
819
|
+
<D:status>HTTP/1.1 200 OK</D:status>
|
|
820
|
+
</D:propstat>
|
|
821
|
+
</D:response>
|
|
822
|
+
<D:response>
|
|
823
|
+
<D:href>/test_file_43</D:href>
|
|
824
|
+
<D:propstat>
|
|
825
|
+
<D:prop>
|
|
826
|
+
<D:getcontentlength>1</D:getcontentlength>
|
|
827
|
+
<D:getlastmodified>Fri, 17 Feb 2023 03:36:54 GMT</D:getlastmodified>
|
|
828
|
+
<D:resourcetype></D:resourcetype>
|
|
829
|
+
</D:prop>
|
|
830
|
+
<D:status>HTTP/1.1 200 OK</D:status>
|
|
831
|
+
</D:propstat>
|
|
832
|
+
</D:response>
|
|
833
|
+
<D:response>
|
|
834
|
+
<D:href>/test_file_95</D:href>
|
|
835
|
+
<D:propstat>
|
|
836
|
+
<D:prop>
|
|
837
|
+
<D:getcontentlength>1</D:getcontentlength>
|
|
838
|
+
<D:getlastmodified>Fri, 17 Feb 2023 03:36:54 GMT</D:getlastmodified>
|
|
839
|
+
<D:resourcetype></D:resourcetype>
|
|
840
|
+
</D:prop>
|
|
841
|
+
<D:status>HTTP/1.1 200 OK</D:status>
|
|
842
|
+
</D:propstat>
|
|
843
|
+
</D:response>
|
|
844
|
+
</D:multistatus>
|
|
845
|
+
"#;
|
|
846
|
+
|
|
847
|
+
let multistatus: Multistatus = from_str(xml).unwrap();
|
|
848
|
+
|
|
849
|
+
let response = multistatus.response;
|
|
850
|
+
assert_eq!(response.len(), 9);
|
|
851
|
+
|
|
852
|
+
let first_response = &response[0];
|
|
853
|
+
assert_eq!(first_response.href, "/");
|
|
854
|
+
assert_eq!(
|
|
855
|
+
first_response.propstat.prop.getlastmodified,
|
|
856
|
+
"Fri, 17 Feb 2023 03:37:22 GMT"
|
|
857
|
+
);
|
|
858
|
+
}
|
|
859
|
+
}
|