diff --git a/.github/workflows/module_async_from_push.yml b/.github/workflows/module_async_from_push.yml new file mode 100644 index 0000000000..dd4257fe08 --- /dev/null +++ b/.github/workflows/module_async_from_push.yml @@ -0,0 +1,24 @@ +name : async_from + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # async_from + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/core/async_from/Cargo.toml' + module_name : 'async_from' + commit_message : ${{ github.event.head_commit.message }} + commiter_username: ${{ github.event.head_commit.committer.username }} diff --git a/.github/workflows/module_async_tools_push.yml b/.github/workflows/module_async_tools_push.yml new file mode 100644 index 0000000000..0310131fd5 --- /dev/null +++ b/.github/workflows/module_async_tools_push.yml @@ -0,0 +1,24 @@ +name : async_tools + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # async_tools + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/core/async_tools/Cargo.toml' + module_name : 'async_tools' + commit_message : ${{ github.event.head_commit.message }} + commiter_username: ${{ github.event.head_commit.committer.username }} diff --git a/.github/workflows/module_graphtools_push.yml b/.github/workflows/module_graphtools_push.yml new file mode 100644 index 0000000000..81fcfc6c0d --- /dev/null +++ b/.github/workflows/module_graphtools_push.yml @@ -0,0 +1,24 @@ +name : graphtools + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # graphtools + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/blank/graphtools/Cargo.toml' + module_name : 'graphtools' + commit_message : ${{ github.event.head_commit.message }} + commiter_username: ${{ github.event.head_commit.committer.username }} diff --git a/.github/workflows/module_mindx_12_push.yml b/.github/workflows/module_mindx_12_push.yml new file mode 100644 index 0000000000..dc1bf11265 --- /dev/null +++ b/.github/workflows/module_mindx_12_push.yml @@ -0,0 +1,24 @@ +name : mindx12 + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # mindx12 + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/blank/mindx12/Cargo.toml' + module_name : 'mindx12' + commit_message : ${{ github.event.head_commit.message }} + commiter_username: ${{ github.event.head_commit.committer.username }} diff --git a/.github/workflows/module_mingl_push.yml b/.github/workflows/module_mingl_push.yml new file mode 100644 index 0000000000..c6ce82da26 --- /dev/null +++ b/.github/workflows/module_mingl_push.yml @@ -0,0 +1,24 @@ +name : mingl + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # mingl + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/blank/mingl/Cargo.toml' + module_name : 'mingl' + commit_message : ${{ github.event.head_commit.message }} + commiter_username: ${{ github.event.head_commit.committer.username }} diff --git a/.github/workflows/module_minmetal_push.yml b/.github/workflows/module_minmetal_push.yml new file mode 100644 index 0000000000..e76b7cf916 --- /dev/null +++ b/.github/workflows/module_minmetal_push.yml @@ -0,0 +1,24 @@ +name : minmetal + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # minmetal + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/blank/minmetal/Cargo.toml' + module_name : 'minmetal' + commit_message : ${{ github.event.head_commit.message }} + commiter_username: ${{ github.event.head_commit.committer.username }} diff --git a/.github/workflows/module_minopengl_push.yml b/.github/workflows/module_minopengl_push.yml new file mode 100644 index 0000000000..5d412de534 --- /dev/null +++ b/.github/workflows/module_minopengl_push.yml @@ -0,0 +1,24 @@ +name : minopengl + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # minopengl + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/blank/minopengl/Cargo.toml' + module_name : 'minopengl' + commit_message : ${{ github.event.head_commit.message }} + commiter_username: ${{ github.event.head_commit.committer.username }} diff --git a/.github/workflows/module_minvulkan_push.yml b/.github/workflows/module_minvulkan_push.yml new file mode 100644 index 0000000000..1350cf0693 --- /dev/null +++ b/.github/workflows/module_minvulkan_push.yml @@ -0,0 +1,24 @@ +name : minvulkan + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # minvulkan + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/blank/minvulkan/Cargo.toml' + module_name : 'minvulkan' + commit_message : ${{ github.event.head_commit.message }} + commiter_username: ${{ github.event.head_commit.committer.username }} diff --git a/.github/workflows/module_minwebgl_push.yml b/.github/workflows/module_minwebgl_push.yml new file mode 100644 index 0000000000..4d63735d10 --- /dev/null +++ b/.github/workflows/module_minwebgl_push.yml @@ -0,0 +1,24 @@ +name : minwebgl + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # minwebgl + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/blank/minwebgl/Cargo.toml' + module_name : 'minwebgl' + commit_message : ${{ github.event.head_commit.message }} + commiter_username: ${{ github.event.head_commit.committer.username }} diff --git a/.github/workflows/module_minwebgpu_push.yml b/.github/workflows/module_minwebgpu_push.yml new file mode 100644 index 0000000000..4e8992613d --- /dev/null +++ b/.github/workflows/module_minwebgpu_push.yml @@ -0,0 +1,24 @@ +name : minwebgpu + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # minwebgpu + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/blank/minwebgpu/Cargo.toml' + module_name : 'minwebgpu' + commit_message : ${{ github.event.head_commit.message }} + commiter_username: ${{ github.event.head_commit.committer.username }} diff --git a/.github/workflows/module_minwgpu_push.yml b/.github/workflows/module_minwgpu_push.yml new file mode 100644 index 0000000000..382a15d19b --- /dev/null +++ b/.github/workflows/module_minwgpu_push.yml @@ -0,0 +1,24 @@ +name : minwgpu + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # minwgpu + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/blank/minwgpu/Cargo.toml' + module_name : 'minwgpu' + commit_message : ${{ github.event.head_commit.message }} + commiter_username: ${{ github.event.head_commit.committer.username }} diff --git a/.github/workflows/module_proper_path_tools_push.yml b/.github/workflows/module_proper_path_tools_push.yml index ebfcf83964..238a9cdb3f 100644 --- a/.github/workflows/module_proper_path_tools_push.yml +++ b/.github/workflows/module_proper_path_tools_push.yml @@ -18,7 +18,7 @@ jobs : test : uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : - manifest_path : 'module/core/proper_path_tools/Cargo.toml' + manifest_path : 'module/blank/proper_path_tools/Cargo.toml' module_name : 'proper_path_tools' commit_message : ${{ github.event.head_commit.message }} commiter_username: ${{ github.event.head_commit.committer.username }} diff --git a/.github/workflows/module_pth_push.yml b/.github/workflows/module_pth_push.yml new file mode 100644 index 0000000000..ddff538916 --- /dev/null +++ b/.github/workflows/module_pth_push.yml @@ -0,0 +1,24 @@ +name : pth + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # pth + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/core/pth/Cargo.toml' + module_name : 'pth' + commit_message : ${{ github.event.head_commit.message }} + commiter_username: ${{ github.event.head_commit.committer.username }} diff --git a/.github/workflows/standard_rust_push.yml b/.github/workflows/standard_rust_push.yml index 310c7fa765..a243d1affe 100644 --- a/.github/workflows/standard_rust_push.yml +++ b/.github/workflows/standard_rust_push.yml @@ -64,21 +64,32 @@ jobs : - name: Build module run: cd ${{ steps.rootpath.outputs.path }} && cargo build && cd - - name: Audit the modules + id: audit run: make audit continue-on-error: true - name: Generate documentation for the modules + id: documentation run: make doc open=no manifest_path=${{ inputs.manifest_path }} continue-on-error: true - name: Lint the modules + id: lint run: make lint manifest_path=${{ inputs.manifest_path }} warnings=no continue-on-error: true - name: Check the modules + id: check run: make check manifest_path=${{ inputs.manifest_path }} continue-on-error: true - name: Check the modules dependencies + id: udeps run: cargo +nightly udeps --all-targets --manifest-path ${{ inputs.manifest_path }} -# This part means that all previous steps will be executed and workflow will not stop if they fail, but not this one. - continue-on-error: false + continue-on-error: true + # Added IDs for each step in the test job: This allows referencing the result of each step later. + # + # "Check for errors" step: Now checks the outcome status for each step. + # If any of them have a value of 'failure', this step will fail the job by returning exit 1. + - name: Check for errors + if: steps.audit.outcome != 'success' || steps.documentation.outcome != 'success' || steps.lint.outcome != 'success' || steps.check.outcome != 'success' || steps.udeps.outcome != 'success' + run: exit 1 # release: # if: contains( inputs.commit_message, '+test' ) || contains( inputs.commit_message, 'merge' ) @@ -127,7 +138,7 @@ jobs : will_test : # This section ensures that `job` `will_test` will only be executed after `checkmate` and if `checkmate` fails, no tests will be run. - needs: + needs : - checkmate if : contains( inputs.commit_message, '+test' ) || inputs.commiter_username == 'web-flow' || startsWith( inputs.commit_message, 'merge' ) concurrency : diff --git a/Cargo.toml b/Cargo.toml index cb2a9fabd9..a940b1b1ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,7 +80,7 @@ path = "module/alias/std_x" ## data_type [workspace.dependencies.data_type] -version = "~0.10.0" +version = "~0.12.0" path = "module/core/data_type" default-features = false @@ -98,19 +98,19 @@ default-features = false # path = "module/core/type_constructor_derive_pair_meta" [workspace.dependencies.interval_adapter] -version = "~0.24.0" +version = "~0.27.0" path = "module/core/interval_adapter" default-features = false -features = [ "enabled" ] +# features = [ "enabled" ] [workspace.dependencies.winterval] version = "~0.3.0" path = "module/alias/winterval" default-features = false -features = [ "enabled" ] +# features = [ "enabled" ] [workspace.dependencies.collection_tools] -version = "~0.12.0" +version = "~0.15.0" path = "module/core/collection_tools" default-features = false @@ -118,34 +118,34 @@ default-features = false ## derive [workspace.dependencies.derive_tools] -version = "~0.28.0" +version = "~0.32.0" path = "module/core/derive_tools" default-features = false -features = [ "enabled" ] +# features = [ "enabled" ] [workspace.dependencies.derive_tools_meta] -version = "~0.27.0" +version = "~0.31.0" path = "module/core/derive_tools_meta" default-features = false -features = [ "enabled" ] +# features = [ "enabled" ] [workspace.dependencies.reflect_tools] version = "~0.3.0" path = "module/core/reflect_tools" default-features = false -features = [ "enabled" ] +# features = [ "enabled" ] [workspace.dependencies.reflect_tools_meta] version = "~0.3.0" path = "module/core/reflect_tools_meta" default-features = false -features = [ "enabled" ] +# features = [ "enabled" ] [workspace.dependencies.format_tools] version = "~0.2.0" path = "module/core/format_tools" default-features = false -features = [ "enabled" ] +# features = [ "enabled" ] # xxx : remove features, maybe # [workspace.dependencies.type_constructor] @@ -159,33 +159,33 @@ path = "module/alias/fundamental_data_type" default-features = false [workspace.dependencies.variadic_from] -version = "~0.23.0" +version = "~0.27.0" path = "module/core/variadic_from" default-features = false -features = [ "enabled" ] +# features = [ "enabled" ] [workspace.dependencies.clone_dyn] -version = "~0.24.0" +version = "~0.29.0" path = "module/core/clone_dyn" default-features = false -features = [ "enabled" ] +# features = [ "enabled" ] [workspace.dependencies.clone_dyn_meta] -version = "~0.24.0" +version = "~0.27.0" path = "module/core/clone_dyn_meta" -features = [ "enabled" ] +# features = [ "enabled" ] [workspace.dependencies.clone_dyn_types] -version = "~0.23.0" +version = "~0.26.0" path = "module/core/clone_dyn_types" default-features = false -features = [ "enabled" ] +# features = [ "enabled" ] ## mem [workspace.dependencies.mem_tools] -version = "~0.6.0" +version = "~0.8.0" path = "module/core/mem_tools" default-features = false @@ -193,7 +193,7 @@ default-features = false ## diagnostics [workspace.dependencies.diagnostics_tools] -version = "~0.8.0" +version = "~0.10.0" path = "module/core/diagnostics_tools" default-features = false @@ -201,7 +201,7 @@ default-features = false ## iter [workspace.dependencies.iter_tools] -version = "~0.21.0" +version = "~0.24.0" path = "module/core/iter_tools" default-features = false @@ -209,17 +209,17 @@ default-features = false ## meta [workspace.dependencies.meta_tools] -version = "~0.10.0" +version = "~0.12.0" path = "module/core/meta_tools" default-features = false [workspace.dependencies.for_each] -version = "~0.8.0" +version = "~0.10.0" path = "module/core/for_each" default-features = false [workspace.dependencies.former] -version = "~2.9.0" +version = "~2.11.0" path = "module/core/former" default-features = false @@ -229,31 +229,31 @@ default-features = false # default-features = false [workspace.dependencies.former_meta] -version = "~2.9.0" +version = "~2.11.0" path = "module/core/former_meta" default-features = false [workspace.dependencies.former_types] -version = "~2.8.0" +version = "~2.12.0" path = "module/core/former_types" default-features = false [workspace.dependencies.impls_index] -version = "~0.7.0" +version = "~0.9.0" path = "module/core/impls_index" default-features = false [workspace.dependencies.impls_index_meta] -version = "~0.7.0" +version = "~0.9.0" path = "module/core/impls_index_meta" [workspace.dependencies.mod_interface] -version = "~0.24.0" +version = "~0.30.0" path = "module/core/mod_interface" default-features = false [workspace.dependencies.mod_interface_meta] -version = "~0.24.0" +version = "~0.29.0" path = "module/core/mod_interface_meta" default-features = false @@ -279,7 +279,7 @@ default-features = false ## macro tools [workspace.dependencies.macro_tools] -version = "~0.40.0" +version = "~0.44.0" path = "module/core/macro_tools" default-features = false @@ -305,12 +305,12 @@ default-features = false ## typing [workspace.dependencies.typing_tools] -version = "~0.8.0" +version = "~0.10.0" path = "module/core/typing_tools" default-features = false [workspace.dependencies.implements] -version = "~0.8.0" +version = "~0.10.0" path = "module/core/implements" default-features = false @@ -320,12 +320,12 @@ path = "module/alias/instance_of" default-features = false [workspace.dependencies.inspect_type] -version = "~0.10.0" +version = "~0.12.0" path = "module/core/inspect_type" default-features = false [workspace.dependencies.is_slice] -version = "~0.9.0" +version = "~0.11.0" path = "module/core/is_slice" default-features = false @@ -333,7 +333,7 @@ default-features = false ## error [workspace.dependencies.error_tools] -version = "~0.17.0" +version = "~0.19.0" path = "module/core/error_tools" default-features = false @@ -345,7 +345,7 @@ path = "module/alias/werror" ## string tools [workspace.dependencies.strs_tools] -version = "~0.17.0" +version = "~0.18.0" path = "module/core/strs_tools" default-features = false @@ -366,23 +366,28 @@ version = "~0.1.0" path = "module/alias/file_tools" default-features = false -[workspace.dependencies.proper_path_tools] -version = "~0.10.0" -path = "module/core/proper_path_tools" +[workspace.dependencies.pth] +version = "~0.21.0" +path = "module/core/pth" default-features = false +# [workspace.dependencies.proper_path_tools] +# version = "~0.15.0" +# path = "module/core/proper_path_tools" +# default-features = false + ## process tools [workspace.dependencies.process_tools] -version = "~0.9.0" +version = "~0.12.0" path = "module/core/process_tools" default-features = false -[workspace.dependencies.process_tools_published] -package = "process_tools" -version = "~0.8.0" -default-features = false +# [workspace.dependencies.process_tools_published] +# package = "process_tools" +# version = "~0.9.0" +# default-features = false ## test @@ -392,19 +397,34 @@ version = "~0.4.0" path = "module/alias/wtest" [workspace.dependencies.test_tools] -version = "~0.9.0" +version = "~0.11.0" path = "module/core/test_tools" +features = [ "full" ] + +[workspace.dependencies.test_tools_stable] +package = "test_tools" +version = "~0.10.0" +features = [ "full" ] [workspace.dependencies.wtest_basic] version = "~0.4.0" path = "module/alias/wtest_basic" +## async + +[workspace.dependencies.async_from] +version = "~0.2.0" +path = "module/core/async_from" + +[workspace.dependencies.async_tools] +version = "~0.1.0" +path = "module/core/async_tools" ## graphs tools [workspace.dependencies.graphs_tools] -version = "~0.2.0" +version = "~0.3.0" path = "module/move/graphs_tools" default-features = false @@ -422,7 +442,7 @@ default-features = false ## ca [workspace.dependencies.wca] -version = "~0.21.0" +version = "~0.23.0" path = "module/move/wca" @@ -436,7 +456,7 @@ path = "module/move/wcensor" ## willbe [workspace.dependencies.willbe] -version = "~0.15.0" +version = "~0.20.0" path = "module/move/willbe" @@ -476,7 +496,7 @@ version = "~0.5.0" path = "module/move/deterministic_rand" [workspace.dependencies.crates_tools] -version = "~0.13.0" +version = "~0.14.0" path = "module/move/crates_tools" @@ -507,3 +527,13 @@ default-features = true version = "~0.3.0" path = "module/test/c" default-features = true + +## External + +[workspace.dependencies.async-trait] +version = "0.1.83" + +[workspace.dependencies.tokio] +version = "1.41.0" +features = [] +default-features = false \ No newline at end of file diff --git a/Readme.md b/Readme.md index 36612d9970..1dd88d3db6 100644 --- a/Readme.md +++ b/Readme.md @@ -27,31 +27,33 @@ Collection of general purpose tools for solving problems. Fundamentally extend t | [clone_dyn](module/core/clone_dyn) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_clone_dyn_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_clone_dyn_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_clone_dyn_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_clone_dyn_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/clone_dyn) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fclone_dyn%2Fexamples%2Fclone_dyn_trivial.rs,RUN_POSTFIX=--example%20clone_dyn_trivial/https://github.com/Wandalen/wTools) | | [variadic_from](module/core/variadic_from) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_variadic_from_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_variadic_from_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_variadic_from_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_variadic_from_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/variadic_from) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fvariadic_from%2Fexamples%2Fvariadic_from_trivial.rs,RUN_POSTFIX=--example%20variadic_from_trivial/https://github.com/Wandalen/wTools) | | [derive_tools](module/core/derive_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_derive_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_derive_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_derive_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_derive_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/derive_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fderive_tools%2Fexamples%2Fderive_tools_trivial.rs,RUN_POSTFIX=--example%20derive_tools_trivial/https://github.com/Wandalen/wTools) | +| [mod_interface_meta](module/core/mod_interface_meta) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_mod_interface_meta_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_meta_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_mod_interface_meta_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_meta_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/mod_interface_meta) | | | [former_meta](module/core/former_meta) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_former_meta_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_former_meta_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_former_meta_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_former_meta_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/former_meta) | | | [impls_index_meta](module/core/impls_index_meta) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_impls_index_meta_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_impls_index_meta_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_impls_index_meta_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_impls_index_meta_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/impls_index_meta) | | -| [mod_interface_meta](module/core/mod_interface_meta) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_mod_interface_meta_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_meta_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_mod_interface_meta_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_meta_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/mod_interface_meta) | | +| [mod_interface](module/core/mod_interface) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_mod_interface_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_mod_interface_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/mod_interface) | | +| [error_tools](module/core/error_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_error_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_error_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_error_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_error_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/error_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Ferror_tools%2Fexamples%2Ferror_tools_trivial.rs,RUN_POSTFIX=--example%20error_tools_trivial/https://github.com/Wandalen/wTools) | | [for_each](module/core/for_each) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_for_each_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_for_each_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_for_each_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_for_each_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/for_each) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Ffor_each%2Fexamples%2Ffor_each_trivial.rs,RUN_POSTFIX=--example%20for_each_trivial/https://github.com/Wandalen/wTools) | | [former](module/core/former) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_former_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_former_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_former_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_former_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/former) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fformer%2Fexamples%2Fformer_trivial.rs,RUN_POSTFIX=--example%20former_trivial/https://github.com/Wandalen/wTools) | | [implements](module/core/implements) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_implements_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_implements_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_implements_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_implements_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/implements) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fimplements%2Fexamples%2Fimplements_trivial.rs,RUN_POSTFIX=--example%20implements_trivial/https://github.com/Wandalen/wTools) | | [impls_index](module/core/impls_index) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_impls_index_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_impls_index_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_impls_index_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_impls_index_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/impls_index) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fimpls_index%2Fexamples%2Fimpls_index_trivial.rs,RUN_POSTFIX=--example%20impls_index_trivial/https://github.com/Wandalen/wTools) | | [inspect_type](module/core/inspect_type) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_inspect_type_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_inspect_type_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_inspect_type_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_inspect_type_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/inspect_type) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Finspect_type%2Fexamples%2Finspect_type_trivial.rs,RUN_POSTFIX=--example%20inspect_type_trivial/https://github.com/Wandalen/wTools) | | [is_slice](module/core/is_slice) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_is_slice_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_is_slice_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_is_slice_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_is_slice_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/is_slice) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fis_slice%2Fexamples%2Fis_slice_trivial.rs,RUN_POSTFIX=--example%20is_slice_trivial/https://github.com/Wandalen/wTools) | -| [mod_interface](module/core/mod_interface) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_mod_interface_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_mod_interface_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/mod_interface) | | +| [pth](module/core/pth) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_pth_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_pth_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_pth_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_pth_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/pth) | | | [reflect_tools_meta](module/core/reflect_tools_meta) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_reflect_tools_meta_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_reflect_tools_meta_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_reflect_tools_meta_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_reflect_tools_meta_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/reflect_tools_meta) | | | [data_type](module/core/data_type) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_data_type_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_data_type_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_data_type_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_data_type_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/data_type) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fdata_type%2Fexamples%2Fdata_type_trivial.rs,RUN_POSTFIX=--example%20data_type_trivial/https://github.com/Wandalen/wTools) | | [diagnostics_tools](module/core/diagnostics_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_diagnostics_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_diagnostics_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_diagnostics_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_diagnostics_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/diagnostics_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fdiagnostics_tools%2Fexamples%2Fdiagnostics_tools_trivial.rs,RUN_POSTFIX=--example%20diagnostics_tools_trivial/https://github.com/Wandalen/wTools) | -| [error_tools](module/core/error_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_error_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_error_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_error_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_error_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/error_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Ferror_tools%2Fexamples%2Ferror_tools_trivial.rs,RUN_POSTFIX=--example%20error_tools_trivial/https://github.com/Wandalen/wTools) | | [mem_tools](module/core/mem_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_mem_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_mem_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_mem_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_mem_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/mem_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fmem_tools%2Fexamples%2Fmem_tools_trivial.rs,RUN_POSTFIX=--example%20mem_tools_trivial/https://github.com/Wandalen/wTools) | | [meta_tools](module/core/meta_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_meta_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_meta_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_meta_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_meta_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/meta_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fmeta_tools%2Fexamples%2Fmeta_tools_trivial.rs,RUN_POSTFIX=--example%20meta_tools_trivial/https://github.com/Wandalen/wTools) | -| [proper_path_tools](module/core/proper_path_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_proper_path_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_proper_path_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_proper_path_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_proper_path_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/proper_path_tools) | | +| [process_tools](module/core/process_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_process_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_process_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_process_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_process_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/process_tools) | | | [reflect_tools](module/core/reflect_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_reflect_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_reflect_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_reflect_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_reflect_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/reflect_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Freflect_tools%2Fexamples%2Freflect_tools_trivial.rs,RUN_POSTFIX=--example%20reflect_tools_trivial/https://github.com/Wandalen/wTools) | | [strs_tools](module/core/strs_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_strs_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_strs_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_strs_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_strs_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/strs_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fstrs_tools%2Fexamples%2Fstrs_tools_trivial.rs,RUN_POSTFIX=--example%20strs_tools_trivial/https://github.com/Wandalen/wTools) | | [time_tools](module/core/time_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_time_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_time_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_time_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_time_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/time_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Ftime_tools%2Fexamples%2Ftime_tools_trivial.rs,RUN_POSTFIX=--example%20time_tools_trivial/https://github.com/Wandalen/wTools) | | [typing_tools](module/core/typing_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_typing_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_typing_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_typing_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_typing_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/typing_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Ftyping_tools%2Fexamples%2Ftyping_tools_trivial.rs,RUN_POSTFIX=--example%20typing_tools_trivial/https://github.com/Wandalen/wTools) | +| [async_from](module/core/async_from) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_async_from_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_async_from_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_async_from_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_async_from_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/async_from) | | +| [async_tools](module/core/async_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_async_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_async_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_async_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_async_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/async_tools) | | | [format_tools](module/core/format_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_format_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_format_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_format_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_format_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/format_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fformat_tools%2Fexamples%2Fformat_tools_trivial.rs,RUN_POSTFIX=--example%20format_tools_trivial/https://github.com/Wandalen/wTools) | | [fs_tools](module/core/fs_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_fs_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_fs_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_fs_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_fs_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/fs_tools) | | | [include_md](module/core/include_md) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_include_md_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_include_md_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_include_md_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_include_md_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/include_md) | | -| [process_tools](module/core/process_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_process_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_process_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_process_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_process_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/process_tools) | | | [program_tools](module/core/program_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_program_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_program_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_program_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_program_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/program_tools) | | | [test_tools](module/core/test_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_test_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_test_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_test_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_test_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/test_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Ftest_tools%2Fexamples%2Ftest_tools_trivial.rs,RUN_POSTFIX=--example%20test_tools_trivial/https://github.com/Wandalen/wTools) | | [wtools](module/core/wtools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_wtools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_wtools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_wtools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_wtools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/wtools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fwtools%2Fexamples%2Fwtools_trivial.rs,RUN_POSTFIX=--example%20wtools_trivial/https://github.com/Wandalen/wTools) | diff --git a/cgtools b/cgtools new file mode 160000 index 0000000000..f42bdc878f --- /dev/null +++ b/cgtools @@ -0,0 +1 @@ +Subproject commit f42bdc878f9414f7fd46b212454f615ab6ebcf61 diff --git a/module/alias/cargo_will/License b/module/alias/cargo_will/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/alias/cargo_will/License +++ b/module/alias/cargo_will/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/alias/cargo_will/src/bin/willbe.rs b/module/alias/cargo_will/src/bin/willbe.rs index 39d2429139..c2850a237c 100644 --- a/module/alias/cargo_will/src/bin/willbe.rs +++ b/module/alias/cargo_will/src/bin/willbe.rs @@ -6,7 +6,7 @@ #[ allow( unused_imports ) ] use::willbe::*; -fn main() -> Result< (), wtools::error::untyped::Error > +fn main() -> Result< (), error::untyped::Error > { Ok( willbe::run( std::env::args().collect() )? ) } diff --git a/module/alias/file_tools/License b/module/alias/file_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/alias/file_tools/License +++ b/module/alias/file_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/alias/fundamental_data_type/License b/module/alias/fundamental_data_type/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/alias/fundamental_data_type/License +++ b/module/alias/fundamental_data_type/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/alias/instance_of/License b/module/alias/instance_of/License index e3e9e057cf..c32986cee3 100644 --- a/module/alias/instance_of/License +++ b/module/alias/instance_of/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/alias/multilayer/License b/module/alias/multilayer/License index e3e9e057cf..c32986cee3 100644 --- a/module/alias/multilayer/License +++ b/module/alias/multilayer/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/alias/proc_macro_tools/License b/module/alias/proc_macro_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/alias/proc_macro_tools/License +++ b/module/alias/proc_macro_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/alias/proper_tools/License b/module/alias/proper_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/alias/proper_tools/License +++ b/module/alias/proper_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/alias/werror/License b/module/alias/werror/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/alias/werror/License +++ b/module/alias/werror/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/alias/willbe2/License b/module/alias/willbe2/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/alias/willbe2/License +++ b/module/alias/willbe2/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/alias/winterval/License b/module/alias/winterval/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/alias/winterval/License +++ b/module/alias/winterval/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/alias/wproc_macro/License b/module/alias/wproc_macro/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/alias/wproc_macro/License +++ b/module/alias/wproc_macro/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/alias/wstring_tools/License b/module/alias/wstring_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/alias/wstring_tools/License +++ b/module/alias/wstring_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/alias/wtest/License b/module/alias/wtest/License index e3e9e057cf..c32986cee3 100644 --- a/module/alias/wtest/License +++ b/module/alias/wtest/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/alias/wtest_basic/Cargo.toml b/module/alias/wtest_basic/Cargo.toml index 3d5e3d1218..6e6ceb65fd 100644 --- a/module/alias/wtest_basic/Cargo.toml +++ b/module/alias/wtest_basic/Cargo.toml @@ -58,7 +58,7 @@ enabled = [ "test_tools/enabled" ] [dependencies] -test_tools = { workspace = true, features = [ "full" ] } +test_tools = { workspace = true, default-features = true } # ## external # @@ -76,5 +76,5 @@ test_tools = { workspace = true, features = [ "full" ] } # data_type = { workspace = true, features = [ "full" ] } # diagnostics_tools = { workspace = true, features = [ "full" ] } -# [dev-dependencies] -# test_tools = { workspace = true } +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/alias/wtest_basic/License b/module/alias/wtest_basic/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/alias/wtest_basic/License +++ b/module/alias/wtest_basic/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/blank/brain_tools/License b/module/blank/brain_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/blank/brain_tools/License +++ b/module/blank/brain_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/blank/draw_lang/License b/module/blank/draw_lang/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/blank/draw_lang/License +++ b/module/blank/draw_lang/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/blank/drawboard/License b/module/blank/drawboard/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/blank/drawboard/License +++ b/module/blank/drawboard/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/blank/drawql/License b/module/blank/drawql/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/blank/drawql/License +++ b/module/blank/drawql/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/blank/exe_tools/License b/module/blank/exe_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/blank/exe_tools/License +++ b/module/blank/exe_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/blank/graphtools/Cargo.toml b/module/blank/graphtools/Cargo.toml new file mode 100644 index 0000000000..67a3c06564 --- /dev/null +++ b/module/blank/graphtools/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "graphtools" +version = "0.1.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/graphtools" +repository = "https://github.com/Wandalen/wTools/tree/master/module/blank/graphtools" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/blank/graphtools" +description = """ +Tools to manipulate graphs. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + +[lints] +workspace = true + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + +[features] +default = [ "enabled" ] +full = [ "enabled" ] +enabled = [] + +[dependencies] + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/core/proper_path_tools/License b/module/blank/graphtools/License similarity index 93% rename from module/core/proper_path_tools/License rename to module/blank/graphtools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/proper_path_tools/License +++ b/module/blank/graphtools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/blank/graphtools/Readme.md b/module/blank/graphtools/Readme.md new file mode 100644 index 0000000000..175776ccd1 --- /dev/null +++ b/module/blank/graphtools/Readme.md @@ -0,0 +1,33 @@ + + +# Module :: graphtools +[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/Modulebrain_toolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/Modulebrain_toolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/graphtools?color=e3e8f0&logo=docs.rs)](https://docs.rs/graphtools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + +Tools to manipulate graphs. + + diff --git a/module/blank/graphtools/src/lib.rs b/module/blank/graphtools/src/lib.rs new file mode 100644 index 0000000000..4168554e8f --- /dev/null +++ b/module/blank/graphtools/src/lib.rs @@ -0,0 +1,11 @@ + +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc( html_root_url = "https://docs.rs/brain_tools/latest/brain_tools/" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Function description. +#[ cfg( feature = "enabled" ) ] +pub fn f1() +{ +} diff --git a/module/blank/graphtools/tests/inc/basic_test.rs b/module/blank/graphtools/tests/inc/basic_test.rs new file mode 100644 index 0000000000..60c9a81cfb --- /dev/null +++ b/module/blank/graphtools/tests/inc/basic_test.rs @@ -0,0 +1,7 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ +} diff --git a/module/blank/graphtools/tests/inc/mod.rs b/module/blank/graphtools/tests/inc/mod.rs new file mode 100644 index 0000000000..dde9de6f94 --- /dev/null +++ b/module/blank/graphtools/tests/inc/mod.rs @@ -0,0 +1,4 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod basic_test; diff --git a/module/blank/graphtools/tests/smoke_test.rs b/module/blank/graphtools/tests/smoke_test.rs new file mode 100644 index 0000000000..663dd6fb9f --- /dev/null +++ b/module/blank/graphtools/tests/smoke_test.rs @@ -0,0 +1,12 @@ + +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/blank/graphtools/tests/tests.rs b/module/blank/graphtools/tests/tests.rs new file mode 100644 index 0000000000..574f34b114 --- /dev/null +++ b/module/blank/graphtools/tests/tests.rs @@ -0,0 +1,10 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use brain_tools as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/blank/image_tools/License b/module/blank/image_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/blank/image_tools/License +++ b/module/blank/image_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/blank/math_tools/License b/module/blank/math_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/blank/math_tools/License +++ b/module/blank/math_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/blank/mindx12/Cargo.toml b/module/blank/mindx12/Cargo.toml new file mode 100644 index 0000000000..a26d724817 --- /dev/null +++ b/module/blank/mindx12/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "mindx12" +version = "0.1.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/mindx12" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/mindx12" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/mindx12" +description = """ +Draw language. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + +[lints] +workspace = true + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + +[features] +default = [ "enabled" ] +full = [ "enabled" ] +enabled = [] + +[dependencies] + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/blank/mindx12/License b/module/blank/mindx12/License new file mode 100644 index 0000000000..0804aed8e3 --- /dev/null +++ b/module/blank/mindx12/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/blank/mindx12/Readme.md b/module/blank/mindx12/Readme.md new file mode 100644 index 0000000000..adc110369e --- /dev/null +++ b/module/blank/mindx12/Readme.md @@ -0,0 +1,33 @@ + + +# Module :: mindx12 +[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/Modulemindx12Push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/Modulemindx12Push.yml) [![docs.rs](https://img.shields.io/docsrs/mindx12?color=e3e8f0&logo=docs.rs)](https://docs.rs/mindx12) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + +Draw language. + + diff --git a/module/blank/mindx12/src/lib.rs b/module/blank/mindx12/src/lib.rs new file mode 100644 index 0000000000..8736456366 --- /dev/null +++ b/module/blank/mindx12/src/lib.rs @@ -0,0 +1,10 @@ + +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Function description. +#[ cfg( feature = "enabled" ) ] +pub fn f1() +{ +} diff --git a/module/blank/mindx12/tests/inc/basic_test.rs b/module/blank/mindx12/tests/inc/basic_test.rs new file mode 100644 index 0000000000..60c9a81cfb --- /dev/null +++ b/module/blank/mindx12/tests/inc/basic_test.rs @@ -0,0 +1,7 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ +} diff --git a/module/blank/mindx12/tests/inc/mod.rs b/module/blank/mindx12/tests/inc/mod.rs new file mode 100644 index 0000000000..dde9de6f94 --- /dev/null +++ b/module/blank/mindx12/tests/inc/mod.rs @@ -0,0 +1,4 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod basic_test; diff --git a/module/core/proper_path_tools/tests/smoke_test.rs b/module/blank/mindx12/tests/smoke_test.rs similarity index 100% rename from module/core/proper_path_tools/tests/smoke_test.rs rename to module/blank/mindx12/tests/smoke_test.rs diff --git a/module/blank/mindx12/tests/tests.rs b/module/blank/mindx12/tests/tests.rs new file mode 100644 index 0000000000..5a33e742f0 --- /dev/null +++ b/module/blank/mindx12/tests/tests.rs @@ -0,0 +1,10 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use mindx12 as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/blank/mingl/Cargo.toml b/module/blank/mingl/Cargo.toml new file mode 100644 index 0000000000..dbd89af97e --- /dev/null +++ b/module/blank/mingl/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "mingl" +version = "0.1.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/mingl" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/mingl" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/mingl" +description = """ +Draw language. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + +[lints] +workspace = true + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + +[features] +default = [ "enabled" ] +full = [ "enabled" ] +enabled = [] + +[dependencies] + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/blank/mingl/License b/module/blank/mingl/License new file mode 100644 index 0000000000..0804aed8e3 --- /dev/null +++ b/module/blank/mingl/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/blank/mingl/Readme.md b/module/blank/mingl/Readme.md new file mode 100644 index 0000000000..3a3390cd6c --- /dev/null +++ b/module/blank/mingl/Readme.md @@ -0,0 +1,33 @@ + + +# Module :: draw_lang +[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/Moduledraw_langPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/Moduledraw_langPush.yml) [![docs.rs](https://img.shields.io/docsrs/draw_lang?color=e3e8f0&logo=docs.rs)](https://docs.rs/draw_lang) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + +Draw language. + + diff --git a/module/blank/mingl/src/lib.rs b/module/blank/mingl/src/lib.rs new file mode 100644 index 0000000000..8736456366 --- /dev/null +++ b/module/blank/mingl/src/lib.rs @@ -0,0 +1,10 @@ + +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Function description. +#[ cfg( feature = "enabled" ) ] +pub fn f1() +{ +} diff --git a/module/blank/mingl/tests/inc/basic_test.rs b/module/blank/mingl/tests/inc/basic_test.rs new file mode 100644 index 0000000000..60c9a81cfb --- /dev/null +++ b/module/blank/mingl/tests/inc/basic_test.rs @@ -0,0 +1,7 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ +} diff --git a/module/blank/mingl/tests/inc/mod.rs b/module/blank/mingl/tests/inc/mod.rs new file mode 100644 index 0000000000..dde9de6f94 --- /dev/null +++ b/module/blank/mingl/tests/inc/mod.rs @@ -0,0 +1,4 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod basic_test; diff --git a/module/blank/mingl/tests/smoke_test.rs b/module/blank/mingl/tests/smoke_test.rs new file mode 100644 index 0000000000..828e9b016b --- /dev/null +++ b/module/blank/mingl/tests/smoke_test.rs @@ -0,0 +1,14 @@ + + +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + + +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/blank/mingl/tests/tests.rs b/module/blank/mingl/tests/tests.rs new file mode 100644 index 0000000000..3e3cefe2bd --- /dev/null +++ b/module/blank/mingl/tests/tests.rs @@ -0,0 +1,10 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use mingl as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/blank/minmetal/Cargo.toml b/module/blank/minmetal/Cargo.toml new file mode 100644 index 0000000000..72527fb754 --- /dev/null +++ b/module/blank/minmetal/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "minmetal" +version = "0.1.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/minmetal" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/minmetal" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/minmetal" +description = """ +Draw language. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + +[lints] +workspace = true + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + +[features] +default = [ "enabled" ] +full = [ "enabled" ] +enabled = [] + +[dependencies] + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/blank/minmetal/License b/module/blank/minmetal/License new file mode 100644 index 0000000000..0804aed8e3 --- /dev/null +++ b/module/blank/minmetal/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/blank/minmetal/Readme.md b/module/blank/minmetal/Readme.md new file mode 100644 index 0000000000..f701fbedf7 --- /dev/null +++ b/module/blank/minmetal/Readme.md @@ -0,0 +1,33 @@ + + +# Module :: minmetal +[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleminmetalPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleminmetalPush.yml) [![docs.rs](https://img.shields.io/docsrs/minmetal?color=e3e8f0&logo=docs.rs)](https://docs.rs/minmetal) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + +Draw language. + + diff --git a/module/blank/minmetal/src/lib.rs b/module/blank/minmetal/src/lib.rs new file mode 100644 index 0000000000..8736456366 --- /dev/null +++ b/module/blank/minmetal/src/lib.rs @@ -0,0 +1,10 @@ + +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Function description. +#[ cfg( feature = "enabled" ) ] +pub fn f1() +{ +} diff --git a/module/blank/minmetal/tests/inc/basic_test.rs b/module/blank/minmetal/tests/inc/basic_test.rs new file mode 100644 index 0000000000..60c9a81cfb --- /dev/null +++ b/module/blank/minmetal/tests/inc/basic_test.rs @@ -0,0 +1,7 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ +} diff --git a/module/blank/minmetal/tests/inc/mod.rs b/module/blank/minmetal/tests/inc/mod.rs new file mode 100644 index 0000000000..dde9de6f94 --- /dev/null +++ b/module/blank/minmetal/tests/inc/mod.rs @@ -0,0 +1,4 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod basic_test; diff --git a/module/blank/minmetal/tests/smoke_test.rs b/module/blank/minmetal/tests/smoke_test.rs new file mode 100644 index 0000000000..828e9b016b --- /dev/null +++ b/module/blank/minmetal/tests/smoke_test.rs @@ -0,0 +1,14 @@ + + +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + + +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/blank/minmetal/tests/tests.rs b/module/blank/minmetal/tests/tests.rs new file mode 100644 index 0000000000..f2f68bee4f --- /dev/null +++ b/module/blank/minmetal/tests/tests.rs @@ -0,0 +1,10 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use minmetal as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/blank/minopengl/Cargo.toml b/module/blank/minopengl/Cargo.toml new file mode 100644 index 0000000000..8be8629874 --- /dev/null +++ b/module/blank/minopengl/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "minopengl" +version = "0.1.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/minopengl" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/minopengl" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/minopengl" +description = """ +Draw language. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + +[lints] +workspace = true + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + +[features] +default = [ "enabled" ] +full = [ "enabled" ] +enabled = [] + +[dependencies] + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/blank/minopengl/License b/module/blank/minopengl/License new file mode 100644 index 0000000000..0804aed8e3 --- /dev/null +++ b/module/blank/minopengl/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/blank/minopengl/Readme.md b/module/blank/minopengl/Readme.md new file mode 100644 index 0000000000..7d19f733ea --- /dev/null +++ b/module/blank/minopengl/Readme.md @@ -0,0 +1,33 @@ + + +# Module :: minopengl +[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleminopenglPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleminopenglPush.yml) [![docs.rs](https://img.shields.io/docsrs/minopengl?color=e3e8f0&logo=docs.rs)](https://docs.rs/minopengl) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + +Draw language. + + diff --git a/module/blank/minopengl/src/lib.rs b/module/blank/minopengl/src/lib.rs new file mode 100644 index 0000000000..8736456366 --- /dev/null +++ b/module/blank/minopengl/src/lib.rs @@ -0,0 +1,10 @@ + +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Function description. +#[ cfg( feature = "enabled" ) ] +pub fn f1() +{ +} diff --git a/module/blank/minopengl/tests/inc/basic_test.rs b/module/blank/minopengl/tests/inc/basic_test.rs new file mode 100644 index 0000000000..60c9a81cfb --- /dev/null +++ b/module/blank/minopengl/tests/inc/basic_test.rs @@ -0,0 +1,7 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ +} diff --git a/module/blank/minopengl/tests/inc/mod.rs b/module/blank/minopengl/tests/inc/mod.rs new file mode 100644 index 0000000000..dde9de6f94 --- /dev/null +++ b/module/blank/minopengl/tests/inc/mod.rs @@ -0,0 +1,4 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod basic_test; diff --git a/module/blank/minopengl/tests/smoke_test.rs b/module/blank/minopengl/tests/smoke_test.rs new file mode 100644 index 0000000000..828e9b016b --- /dev/null +++ b/module/blank/minopengl/tests/smoke_test.rs @@ -0,0 +1,14 @@ + + +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + + +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/blank/minopengl/tests/tests.rs b/module/blank/minopengl/tests/tests.rs new file mode 100644 index 0000000000..8a64879a19 --- /dev/null +++ b/module/blank/minopengl/tests/tests.rs @@ -0,0 +1,10 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use minopengl as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/blank/minvulkan/Cargo.toml b/module/blank/minvulkan/Cargo.toml new file mode 100644 index 0000000000..69ce9bda5d --- /dev/null +++ b/module/blank/minvulkan/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "minvulkan" +version = "0.1.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/minvulkan" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/minvulkan" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/minvulkan" +description = """ +Draw language. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + +[lints] +workspace = true + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + +[features] +default = [ "enabled" ] +full = [ "enabled" ] +enabled = [] + +[dependencies] + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/blank/minvulkan/License b/module/blank/minvulkan/License new file mode 100644 index 0000000000..0804aed8e3 --- /dev/null +++ b/module/blank/minvulkan/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/blank/minvulkan/Readme.md b/module/blank/minvulkan/Readme.md new file mode 100644 index 0000000000..69b19ad55c --- /dev/null +++ b/module/blank/minvulkan/Readme.md @@ -0,0 +1,33 @@ + + +# Module :: minvulkan +[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleminvulkanPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleminvulkanPush.yml) [![docs.rs](https://img.shields.io/docsrs/minvulkan?color=e3e8f0&logo=docs.rs)](https://docs.rs/minvulkan) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + +Draw language. + + diff --git a/module/blank/minvulkan/src/lib.rs b/module/blank/minvulkan/src/lib.rs new file mode 100644 index 0000000000..8736456366 --- /dev/null +++ b/module/blank/minvulkan/src/lib.rs @@ -0,0 +1,10 @@ + +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Function description. +#[ cfg( feature = "enabled" ) ] +pub fn f1() +{ +} diff --git a/module/blank/minvulkan/tests/inc/basic_test.rs b/module/blank/minvulkan/tests/inc/basic_test.rs new file mode 100644 index 0000000000..60c9a81cfb --- /dev/null +++ b/module/blank/minvulkan/tests/inc/basic_test.rs @@ -0,0 +1,7 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ +} diff --git a/module/blank/minvulkan/tests/inc/mod.rs b/module/blank/minvulkan/tests/inc/mod.rs new file mode 100644 index 0000000000..dde9de6f94 --- /dev/null +++ b/module/blank/minvulkan/tests/inc/mod.rs @@ -0,0 +1,4 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod basic_test; diff --git a/module/blank/minvulkan/tests/smoke_test.rs b/module/blank/minvulkan/tests/smoke_test.rs new file mode 100644 index 0000000000..828e9b016b --- /dev/null +++ b/module/blank/minvulkan/tests/smoke_test.rs @@ -0,0 +1,14 @@ + + +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + + +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/blank/minvulkan/tests/tests.rs b/module/blank/minvulkan/tests/tests.rs new file mode 100644 index 0000000000..d2d5f19233 --- /dev/null +++ b/module/blank/minvulkan/tests/tests.rs @@ -0,0 +1,10 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use minvulkan as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/blank/minwebgl/Cargo.toml b/module/blank/minwebgl/Cargo.toml new file mode 100644 index 0000000000..06d52581fb --- /dev/null +++ b/module/blank/minwebgl/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "minwebgl" +version = "0.1.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/minwebgl" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/minwebgl" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/minwebgl" +description = """ +Draw language. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + +[lints] +workspace = true + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + +[features] +default = [ "enabled" ] +full = [ "enabled" ] +enabled = [] + +[dependencies] + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/blank/minwebgl/License b/module/blank/minwebgl/License new file mode 100644 index 0000000000..0804aed8e3 --- /dev/null +++ b/module/blank/minwebgl/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/blank/minwebgl/Readme.md b/module/blank/minwebgl/Readme.md new file mode 100644 index 0000000000..5b92138916 --- /dev/null +++ b/module/blank/minwebgl/Readme.md @@ -0,0 +1,33 @@ + + +# Module :: minwebgl +[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleminwebglPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleminwebglPush.yml) [![docs.rs](https://img.shields.io/docsrs/minwebgl?color=e3e8f0&logo=docs.rs)](https://docs.rs/minwebgl) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + +Draw language. + + diff --git a/module/blank/minwebgl/src/lib.rs b/module/blank/minwebgl/src/lib.rs new file mode 100644 index 0000000000..8736456366 --- /dev/null +++ b/module/blank/minwebgl/src/lib.rs @@ -0,0 +1,10 @@ + +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Function description. +#[ cfg( feature = "enabled" ) ] +pub fn f1() +{ +} diff --git a/module/blank/minwebgl/tests/inc/basic_test.rs b/module/blank/minwebgl/tests/inc/basic_test.rs new file mode 100644 index 0000000000..60c9a81cfb --- /dev/null +++ b/module/blank/minwebgl/tests/inc/basic_test.rs @@ -0,0 +1,7 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ +} diff --git a/module/blank/minwebgl/tests/inc/mod.rs b/module/blank/minwebgl/tests/inc/mod.rs new file mode 100644 index 0000000000..dde9de6f94 --- /dev/null +++ b/module/blank/minwebgl/tests/inc/mod.rs @@ -0,0 +1,4 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod basic_test; diff --git a/module/blank/minwebgl/tests/smoke_test.rs b/module/blank/minwebgl/tests/smoke_test.rs new file mode 100644 index 0000000000..828e9b016b --- /dev/null +++ b/module/blank/minwebgl/tests/smoke_test.rs @@ -0,0 +1,14 @@ + + +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + + +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/blank/minwebgl/tests/tests.rs b/module/blank/minwebgl/tests/tests.rs new file mode 100644 index 0000000000..f830fcaa61 --- /dev/null +++ b/module/blank/minwebgl/tests/tests.rs @@ -0,0 +1,10 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use minwebgl as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/blank/minwebgpu/Cargo.toml b/module/blank/minwebgpu/Cargo.toml new file mode 100644 index 0000000000..c543c5be36 --- /dev/null +++ b/module/blank/minwebgpu/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "minwebgpu" +version = "0.1.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/minwebgpu" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/minwebgpu" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/minwebgpu" +description = """ +Draw language. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + +[lints] +workspace = true + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + +[features] +default = [ "enabled" ] +full = [ "enabled" ] +enabled = [] + +[dependencies] + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/blank/minwebgpu/License b/module/blank/minwebgpu/License new file mode 100644 index 0000000000..0804aed8e3 --- /dev/null +++ b/module/blank/minwebgpu/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/blank/minwebgpu/Readme.md b/module/blank/minwebgpu/Readme.md new file mode 100644 index 0000000000..259dee0ab2 --- /dev/null +++ b/module/blank/minwebgpu/Readme.md @@ -0,0 +1,33 @@ + + +# Module :: minwebgpu +[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleminwebgpuPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleminwebgpuPush.yml) [![docs.rs](https://img.shields.io/docsrs/minwebgpu?color=e3e8f0&logo=docs.rs)](https://docs.rs/minwebgpu) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + +Draw language. + + diff --git a/module/blank/minwebgpu/src/lib.rs b/module/blank/minwebgpu/src/lib.rs new file mode 100644 index 0000000000..8736456366 --- /dev/null +++ b/module/blank/minwebgpu/src/lib.rs @@ -0,0 +1,10 @@ + +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Function description. +#[ cfg( feature = "enabled" ) ] +pub fn f1() +{ +} diff --git a/module/blank/minwebgpu/tests/inc/basic_test.rs b/module/blank/minwebgpu/tests/inc/basic_test.rs new file mode 100644 index 0000000000..60c9a81cfb --- /dev/null +++ b/module/blank/minwebgpu/tests/inc/basic_test.rs @@ -0,0 +1,7 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ +} diff --git a/module/blank/minwebgpu/tests/inc/mod.rs b/module/blank/minwebgpu/tests/inc/mod.rs new file mode 100644 index 0000000000..dde9de6f94 --- /dev/null +++ b/module/blank/minwebgpu/tests/inc/mod.rs @@ -0,0 +1,4 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod basic_test; diff --git a/module/blank/minwebgpu/tests/smoke_test.rs b/module/blank/minwebgpu/tests/smoke_test.rs new file mode 100644 index 0000000000..828e9b016b --- /dev/null +++ b/module/blank/minwebgpu/tests/smoke_test.rs @@ -0,0 +1,14 @@ + + +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + + +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/blank/minwebgpu/tests/tests.rs b/module/blank/minwebgpu/tests/tests.rs new file mode 100644 index 0000000000..849473f639 --- /dev/null +++ b/module/blank/minwebgpu/tests/tests.rs @@ -0,0 +1,10 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use minwebgpu as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/blank/minwgpu/Cargo.toml b/module/blank/minwgpu/Cargo.toml new file mode 100644 index 0000000000..25841190ba --- /dev/null +++ b/module/blank/minwgpu/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "minwgpu" +version = "0.1.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/minwgpu" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/minwgpu" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/minwgpu" +description = """ +Draw language. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + +[lints] +workspace = true + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + +[features] +default = [ "enabled" ] +full = [ "enabled" ] +enabled = [] + +[dependencies] + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/blank/minwgpu/License b/module/blank/minwgpu/License new file mode 100644 index 0000000000..0804aed8e3 --- /dev/null +++ b/module/blank/minwgpu/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/blank/minwgpu/Readme.md b/module/blank/minwgpu/Readme.md new file mode 100644 index 0000000000..1c8ca98d8a --- /dev/null +++ b/module/blank/minwgpu/Readme.md @@ -0,0 +1,33 @@ + + +# Module :: minwgpu +[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleminwgpuPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleminwgpuPush.yml) [![docs.rs](https://img.shields.io/docsrs/minwgpu?color=e3e8f0&logo=docs.rs)](https://docs.rs/minwgpu) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + +Draw language. + + diff --git a/module/blank/minwgpu/src/lib.rs b/module/blank/minwgpu/src/lib.rs new file mode 100644 index 0000000000..8736456366 --- /dev/null +++ b/module/blank/minwgpu/src/lib.rs @@ -0,0 +1,10 @@ + +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Function description. +#[ cfg( feature = "enabled" ) ] +pub fn f1() +{ +} diff --git a/module/blank/minwgpu/tests/inc/basic_test.rs b/module/blank/minwgpu/tests/inc/basic_test.rs new file mode 100644 index 0000000000..60c9a81cfb --- /dev/null +++ b/module/blank/minwgpu/tests/inc/basic_test.rs @@ -0,0 +1,7 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ +} diff --git a/module/blank/minwgpu/tests/inc/mod.rs b/module/blank/minwgpu/tests/inc/mod.rs new file mode 100644 index 0000000000..dde9de6f94 --- /dev/null +++ b/module/blank/minwgpu/tests/inc/mod.rs @@ -0,0 +1,4 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod basic_test; diff --git a/module/blank/minwgpu/tests/smoke_test.rs b/module/blank/minwgpu/tests/smoke_test.rs new file mode 100644 index 0000000000..828e9b016b --- /dev/null +++ b/module/blank/minwgpu/tests/smoke_test.rs @@ -0,0 +1,14 @@ + + +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + + +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/blank/minwgpu/tests/tests.rs b/module/blank/minwgpu/tests/tests.rs new file mode 100644 index 0000000000..9bcb27960e --- /dev/null +++ b/module/blank/minwgpu/tests/tests.rs @@ -0,0 +1,10 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use minwgpu as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/blank/paths_tools/License b/module/blank/paths_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/blank/paths_tools/License +++ b/module/blank/paths_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/blank/proper_path_tools/Cargo.toml b/module/blank/proper_path_tools/Cargo.toml new file mode 100644 index 0000000000..4fe862c57e --- /dev/null +++ b/module/blank/proper_path_tools/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "proper_path_tools" +version = "0.1.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/proper_path_tools" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/proper_path_tools" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/proper_path_tools" +description = """ +Tools for second brain. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + +[lints] +workspace = true + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + +[features] +default = [ "enabled" ] +full = [ "enabled" ] +enabled = [] + +[dependencies] + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/blank/proper_path_tools/License b/module/blank/proper_path_tools/License new file mode 100644 index 0000000000..0804aed8e3 --- /dev/null +++ b/module/blank/proper_path_tools/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/blank/proper_path_tools/Readme.md b/module/blank/proper_path_tools/Readme.md new file mode 100644 index 0000000000..7fd9f99168 --- /dev/null +++ b/module/blank/proper_path_tools/Readme.md @@ -0,0 +1,33 @@ + + +# Module :: proper_path_tools +[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/Moduleproper_path_toolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/Moduleproper_path_toolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/proper_path_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/proper_path_tools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + +Tools for second brain. + + diff --git a/module/blank/proper_path_tools/src/lib.rs b/module/blank/proper_path_tools/src/lib.rs new file mode 100644 index 0000000000..b96a03ed21 --- /dev/null +++ b/module/blank/proper_path_tools/src/lib.rs @@ -0,0 +1,11 @@ + +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc( html_root_url = "https://docs.rs/proper_path_tools/latest/proper_path_tools/" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Function description. +#[ cfg( feature = "enabled" ) ] +pub fn f1() +{ +} diff --git a/module/blank/proper_path_tools/tests/inc/basic_test.rs b/module/blank/proper_path_tools/tests/inc/basic_test.rs new file mode 100644 index 0000000000..60c9a81cfb --- /dev/null +++ b/module/blank/proper_path_tools/tests/inc/basic_test.rs @@ -0,0 +1,7 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ +} diff --git a/module/blank/proper_path_tools/tests/inc/mod.rs b/module/blank/proper_path_tools/tests/inc/mod.rs new file mode 100644 index 0000000000..dde9de6f94 --- /dev/null +++ b/module/blank/proper_path_tools/tests/inc/mod.rs @@ -0,0 +1,4 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod basic_test; diff --git a/module/blank/proper_path_tools/tests/smoke_test.rs b/module/blank/proper_path_tools/tests/smoke_test.rs new file mode 100644 index 0000000000..663dd6fb9f --- /dev/null +++ b/module/blank/proper_path_tools/tests/smoke_test.rs @@ -0,0 +1,12 @@ + +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/core/proper_path_tools/tests/tests.rs b/module/blank/proper_path_tools/tests/tests.rs similarity index 100% rename from module/core/proper_path_tools/tests/tests.rs rename to module/blank/proper_path_tools/tests/tests.rs diff --git a/module/blank/rustql/License b/module/blank/rustql/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/blank/rustql/License +++ b/module/blank/rustql/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/blank/second_brain/License b/module/blank/second_brain/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/blank/second_brain/License +++ b/module/blank/second_brain/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/blank/w4d/License b/module/blank/w4d/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/blank/w4d/License +++ b/module/blank/w4d/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/blank/wlang/License b/module/blank/wlang/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/blank/wlang/License +++ b/module/blank/wlang/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/async_from/Cargo.toml b/module/core/async_from/Cargo.toml new file mode 100644 index 0000000000..b6be30c5c7 --- /dev/null +++ b/module/core/async_from/Cargo.toml @@ -0,0 +1,38 @@ +[package] +name = "async_from" +version = "0.2.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/async_from" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/async_from" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/async_from" +description = """ +Async version of From, Into, TryFrom, TryInto. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + +[lints] +workspace = true + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + +[features] +default = [ "enabled", "async_from", "async_try_from" ] +full = [ "default" ] +enabled = [] +async_from = [] +async_try_from = [] + +[dependencies] +async-trait = { workspace = true } + +[dev-dependencies] +# test_tools = { workspace = true } +tokio = { workspace = true, features = [ "rt-multi-thread", "time", "macros" ] } diff --git a/module/core/async_from/License b/module/core/async_from/License new file mode 100644 index 0000000000..0804aed8e3 --- /dev/null +++ b/module/core/async_from/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/core/async_from/Readme.md b/module/core/async_from/Readme.md new file mode 100644 index 0000000000..374fd4595c --- /dev/null +++ b/module/core/async_from/Readme.md @@ -0,0 +1,91 @@ + + +# Module :: async_from +[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/Moduleasync_fromPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/Moduleasync_fromPush.yml) [![docs.rs](https://img.shields.io/docsrs/async_from?color=e3e8f0&logo=docs.rs)](https://docs.rs/async_from) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + +Async version of From, Into, TryFrom, TryInto. + +The `async_from` crate provides asynchronous versions of the well-known `From`, `Into`, `TryFrom`, and `TryInto` traits. These traits are essential for handling conversions in Rust, and their asynchronous counterparts, allowing for conversions that involve asynchronous operations. + +## Why Asynchronous Conversion Traits? + +In Rust, the `From`, `Into`, `TryFrom`, and `TryInto` traits provide a standardized way to handle type conversions. The `async_from` module extends this functionality to asynchronous contexts with `AsyncFrom`, `AsyncInto`, `AsyncTryFrom`, and `AsyncTryInto` traits, offering several key benefits: + +- **Simplicity**: Allow straightforward conversions without boilerplate, even in asynchronous contexts. +- **Consistency**: Provide a uniform interface for conversions across different types, aiding in writing predictable and maintainable code. +- **Error Handling**: Enable safe and explicit handling of conversion failures, essential for robust error management in commercial applications. +- **Asynchronous Contexts**: Facilitate conversions involving asynchronous operations, such as network requests or database queries, which are common in modern applications. + +The `async_from` provides developers with the tools needed to handle complex conversions in an async context efficiently, which is particularly important for commercial applications requiring reliable and efficient handling of asynchronous operations. + +### `AsyncFrom` and `AsyncInto` + +Trait for asynchronous conversions from a type T. + +These traits are designed for infallible asynchronous conversions. They allow you to convert types asynchronously, returning the result directly. + +```rust +use async_from::{ async_trait, AsyncFrom, AsyncInto }; + +struct MyNumber( u32 ); + +#[ async_trait ] +impl AsyncFrom< String > for MyNumber +{ + async fn async_from( value : String ) -> Self + { + let num = value.parse::< u32 >().unwrap_or( 0 ); + MyNumber( num ) + } +} + +#[ tokio::main ] +async fn main() +{ + let num = MyNumber::async_from( "42".to_string() ).await; + println!( "Converted: {}", num.0 ); + let num : MyNumber = "42".to_string().async_into().await; + println!( "Converted: {}", num.0 ); +} +``` + +### `AsyncTryFrom` and `AsyncTryInto` + +Trait for asynchronous fallible conversions from a type T. + +These traits are for fallible asynchronous conversions, where the conversion might fail. They return a `Result` wrapped in a `Future`, allowing you to handle errors gracefully. + +```rust +use async_from::{ async_trait, AsyncTryFrom, AsyncTryInto }; +use std::num::ParseIntError; + +struct MyNumber( u32 ); + +#[ async_trait ] +impl AsyncTryFrom< String > for MyNumber +{ + type Error = ParseIntError; + + async fn async_try_from( value : String ) -> Result< Self, Self::Error > + { + let num = value.parse::< u32 >()?; + Ok( MyNumber( num ) ) + } +} + +#[ tokio::main ] +async fn main() +{ + match MyNumber::async_try_from( "42".to_string() ).await + { + Ok( my_num ) => println!( "Converted successfully: {}", my_num.0 ), + Err( e ) => println!( "Conversion failed: {:?}", e ), + } + let result : Result< MyNumber, _ > = "42".to_string().async_try_into().await; + match result + { + Ok( my_num ) => println!( "Converted successfully using AsyncTryInto: {}", my_num.0 ), + Err( e ) => println!( "Conversion failed using AsyncTryInto: {:?}", e ), + } +} +``` diff --git a/module/core/async_from/src/lib.rs b/module/core/async_from/src/lib.rs new file mode 100644 index 0000000000..b2419ae521 --- /dev/null +++ b/module/core/async_from/src/lib.rs @@ -0,0 +1,316 @@ + +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc( html_root_url = "https://docs.rs/async_from/latest/async_from/" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Namespace with dependencies. +#[ cfg( feature = "enabled" ) ] +pub mod dependency +{ + pub use ::async_trait; +} + +/// Internal namespace. +#[ cfg( feature = "enabled" ) ] +mod private +{ + + pub use async_trait::async_trait; + use std::fmt::Debug; + + /// Trait for asynchronous conversions from a type `T`. + /// + /// This trait allows for conversions that occur asynchronously, returning a `Future`. + /// + /// # Example + /// + /// ```rust + /// use async_from::{ async_trait, AsyncFrom }; + /// + /// struct MyNumber( u32 ); + /// + /// #[ async_trait ] + /// impl AsyncFrom< String > for MyNumber + /// { + /// async fn async_from( value : String ) -> Self + /// { + /// let num = value.parse::< u32 >().unwrap_or( 0 ); + /// MyNumber( num ) + /// } + /// } + /// + /// #[ tokio::main ] + /// async fn main() + /// { + /// let num = MyNumber::async_from( "42".to_string() ).await; + /// println!( "Converted: {}", num.0 ); + /// } + /// ``` + #[ cfg( feature = "async_from" ) ] + #[ async_trait ] + pub trait AsyncFrom< T > : Sized + { + /// Asynchronously converts a value of type `T` into `Self`. + /// + /// # Arguments + /// + /// * `value` - The value to be converted. + /// + /// # Returns + /// + /// * `Self` - The converted value. + async fn async_from( value : T ) -> Self; + } + + /// Trait for asynchronous conversions into a type `T`. + /// + /// This trait provides a method to convert `Self` into `T` asynchronously. + /// + /// # Example + /// + /// ```rust + /// use async_from::{ async_trait, AsyncFrom, AsyncInto }; + /// + /// struct MyNumber( u32 ); + /// + /// #[ async_trait ] + /// impl AsyncFrom< String > for MyNumber + /// { + /// async fn async_from( value : String ) -> Self + /// { + /// let num = value.parse::< u32 >().unwrap_or( 0 ); + /// MyNumber( num ) + /// } + /// } + /// + /// #[ tokio::main ] + /// async fn main() + /// { + /// let num : MyNumber = "42".to_string().async_into().await; + /// println!( "Converted: {}", num.0 ); + /// } + /// ``` + #[ async_trait ] + #[ cfg( feature = "async_from" ) ] + pub trait AsyncInto< T > : Sized + { + /// Asynchronously converts `Self` into a value of type `T`. + /// + /// # Returns + /// + /// * `T` - The converted value. + async fn async_into( self ) -> T; + } + + /// Blanket implementation of `AsyncInto` for any type that implements `AsyncFrom`. + /// + /// This implementation allows any type `T` that implements `AsyncFrom` to also implement `AsyncInto`. + #[ async_trait ] + #[ cfg( feature = "async_from" ) ] + impl< T, U > AsyncInto< U > for T + where + U : AsyncFrom< T > + Send, + T : Send, + { + /// Asynchronously converts `Self` into a value of type `U` using `AsyncFrom`. + /// + /// # Returns + /// + /// * `U` - The converted value. + async fn async_into( self ) -> U + { + U::async_from( self ).await + } + } + + /// Trait for asynchronous fallible conversions from a type `T`. + /// + /// This trait allows for conversions that may fail, returning a `Result` wrapped in a `Future`. + /// + /// # Example + /// + /// ```rust + /// use async_from::{ async_trait, AsyncTryFrom }; + /// use std::num::ParseIntError; + /// + /// struct MyNumber( u32 ); + /// + /// #[ async_trait ] + /// impl AsyncTryFrom< String > for MyNumber + /// { + /// type Error = ParseIntError; + /// + /// async fn async_try_from( value : String ) -> Result< Self, Self::Error > + /// { + /// let num = value.parse::< u32 >()?; + /// Ok( MyNumber( num ) ) + /// } + /// } + /// + /// #[ tokio::main ] + /// async fn main() + /// { + /// match MyNumber::async_try_from( "42".to_string() ).await + /// { + /// Ok( my_num ) => println!( "Converted successfully: {}", my_num.0 ), + /// Err( e ) => println!( "Conversion failed: {:?}", e ), + /// } + /// } + /// ``` + #[ async_trait ] + #[ cfg( feature = "async_try_from" ) ] + pub trait AsyncTryFrom< T > : Sized + { + /// The error type returned if the conversion fails. + type Error : Debug; + + /// Asynchronously attempts to convert a value of type `T` into `Self`. + /// + /// # Arguments + /// + /// * `value` - The value to be converted. + /// + /// # Returns + /// + /// * `Result` - On success, returns the converted value. On failure, returns an error. + async fn async_try_from( value : T ) -> Result< Self, Self::Error >; + } + + /// Trait for asynchronous fallible conversions into a type `T`. + /// + /// This trait provides a method to convert `Self` into `T`, potentially returning an error. + /// + /// # Example + /// + /// ```rust + /// use async_from::{ async_trait, AsyncTryFrom, AsyncTryInto }; + /// use std::num::ParseIntError; + /// + /// struct MyNumber( u32 ); + /// + /// #[ async_trait ] + /// impl AsyncTryFrom< String > for MyNumber + /// { + /// type Error = ParseIntError; + /// + /// async fn async_try_from( value : String ) -> Result< Self, Self::Error > + /// { + /// let num = value.parse::< u32 >()?; + /// Ok( MyNumber( num ) ) + /// } + /// } + /// + /// #[ tokio::main ] + /// async fn main() + /// { + /// let result : Result< MyNumber, _ > = "42".to_string().async_try_into().await; + /// match result + /// { + /// Ok( my_num ) => println!( "Converted successfully using AsyncTryInto: {}", my_num.0 ), + /// Err( e ) => println!( "Conversion failed using AsyncTryInto: {:?}", e ), + /// } + /// } + /// ``` + #[ async_trait ] + #[ cfg( feature = "async_try_from" ) ] + pub trait AsyncTryInto< T > : Sized + { + /// The error type returned if the conversion fails. + type Error : Debug; + + /// Asynchronously attempts to convert `Self` into a value of type `T`. + /// + /// # Returns + /// + /// * `Result` - On success, returns the converted value. On failure, returns an error. + async fn async_try_into( self ) -> Result< T, Self::Error >; + } + + /// Blanket implementation of `AsyncTryInto` for any type that implements `AsyncTryFrom`. + /// + /// This implementation allows any type `T` that implements `AsyncTryFrom` to also implement `AsyncTryInto`. + #[ async_trait ] + #[ cfg( feature = "async_try_from" ) ] + impl< T, U > AsyncTryInto< U > for T + where + U : AsyncTryFrom< T > + Send, + T : Send, + { + type Error = U::Error; + + /// Asynchronously converts `Self` into a value of type `U` using `AsyncTryFrom`. + /// + /// # Returns + /// + /// * `Result` - On success, returns the converted value. On failure, returns an error. + async fn async_try_into( self ) -> Result< U, Self::Error > + { + U::async_try_from( self ).await + } + } + +} + +#[ cfg( feature = "enabled" ) ] +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +pub use own::*; + +/// Own namespace of the module. +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod own +{ + use super::*; + #[ doc( inline ) ] + pub use orphan::*; +} + +/// Orphan namespace of the module. +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod orphan +{ + use super::*; + #[ doc( inline ) ] + pub use exposed::*; + +} + +/// Exposed namespace of the module. +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod exposed +{ + use super::*; + + #[ doc( inline ) ] + pub use prelude::*; + + #[ doc( inline ) ] + pub use ::async_trait::async_trait; + + #[ cfg( feature = "async_from" ) ] + pub use private:: + { + AsyncFrom, + AsyncInto, + }; + + #[ cfg( feature = "async_try_from" ) ] + pub use private:: + { + AsyncTryFrom, + AsyncTryInto, + }; + +} + +/// Prelude to use essentials: `use my_module::prelude::*`. +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod prelude +{ + use super::*; +} diff --git a/module/core/async_from/tests/inc/basic_test.rs b/module/core/async_from/tests/inc/basic_test.rs new file mode 100644 index 0000000000..dce63a4c1e --- /dev/null +++ b/module/core/async_from/tests/inc/basic_test.rs @@ -0,0 +1,84 @@ +use super::*; + +#[ tokio::test ] +async fn async_try_from_test() +{ + + // Example implementation of AsyncTryFrom for a custom type + struct MyNumber( u32 ); + + // xxx : qqq : broken + // #[ the_module::async_trait ] + // impl< 'a > the_module::AsyncTryFrom< &'a str > for MyNumber + // { + // type Error = std::num::ParseIntError; + // + // async fn async_try_from( value : &'a str ) -> Result< Self, Self::Error > + // { + // // Simulate asynchronous work + // tokio::time::sleep( tokio::time::Duration::from_millis( 1 ) ).await; + // let num = value.parse::< u32 >()?; + // Ok( MyNumber( num ) ) + // } + // } + + #[ the_module::async_trait ] + impl the_module::AsyncTryFrom< String > for MyNumber + { + type Error = std::num::ParseIntError; + + async fn async_try_from( value : String ) -> Result< Self, Self::Error > + { + // Simulate asynchronous work + tokio::time::sleep( tokio::time::Duration::from_millis( 10 ) ).await; + let num = value.parse::< u32 >()?; + Ok( MyNumber( num ) ) + } + } + + use the_module::{ AsyncTryFrom, AsyncTryInto }; + + // Using AsyncTryFrom directly + match MyNumber::async_try_from( "42".to_string() ).await + { + Ok( my_num ) => println!( "Converted successfully: {}", my_num.0 ), + Err( e ) => println!( "Conversion failed: {:?}", e ), + } + + // Using AsyncTryInto, which is automatically implemented + let result : Result< MyNumber, _ > = "42".to_string().async_try_into().await; + match result + { + Ok( my_num ) => println!( "Converted successfully using AsyncTryInto: {}", my_num.0 ), + Err( e ) => println!( "Conversion failed using AsyncTryInto: {:?}", e ), + } +} + +#[ tokio::test ] +async fn async_from_test() +{ + // Example implementation of AsyncFrom for a custom type + struct MyNumber( u32 ); + + #[ the_module::async_trait ] + impl the_module::AsyncFrom< String > for MyNumber + { + async fn async_from( value : String ) -> Self + { + // Simulate asynchronous work + tokio::time::sleep( tokio::time::Duration::from_millis( 10 ) ).await; + let num = value.parse::< u32 >().unwrap_or( 0 ); + MyNumber( num ) + } + } + + use the_module::{ AsyncFrom, AsyncInto }; + + // Using AsyncFrom directly + let my_num : MyNumber = MyNumber::async_from( "42".to_string() ).await; + println!( "Converted successfully using AsyncFrom: {}", my_num.0 ); + + // Using AsyncInto, which is automatically implemented + let my_num : MyNumber = "42".to_string().async_into().await; + println!( "Converted successfully using AsyncInto: {}", my_num.0 ); +} diff --git a/module/core/async_from/tests/inc/mod.rs b/module/core/async_from/tests/inc/mod.rs new file mode 100644 index 0000000000..329271ad56 --- /dev/null +++ b/module/core/async_from/tests/inc/mod.rs @@ -0,0 +1,3 @@ +use super::*; + +mod basic_test; diff --git a/module/core/async_from/tests/tests.rs b/module/core/async_from/tests/tests.rs new file mode 100644 index 0000000000..299521de4e --- /dev/null +++ b/module/core/async_from/tests/tests.rs @@ -0,0 +1,9 @@ +#![ allow( unused_imports ) ] + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +use async_from as the_module; +// use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/core/async_tools/Cargo.toml b/module/core/async_tools/Cargo.toml new file mode 100644 index 0000000000..0f6c4f835b --- /dev/null +++ b/module/core/async_tools/Cargo.toml @@ -0,0 +1,39 @@ +[package] +name = "async_tools" +version = "0.1.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/async_tools" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/async_tools" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/async_tools" +description = """ +Toolkit for asynchronous programming. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + +[lints] +workspace = true + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + +[features] +default = [ "enabled", "async_from", "async_try_from" ] +full = [ "default" ] +enabled = [] +async_from = [ "async_from/async_from" ] +async_try_from = [ "async_from/async_try_from" ] + +[dependencies] +async-trait = { workspace = true } +async_from = { workspace = true } + +[dev-dependencies] +# test_tools = { workspace = true } +tokio = { workspace = true, default-features = false, features = [ "rt-multi-thread", "time", "macros" ] } diff --git a/module/core/async_tools/License b/module/core/async_tools/License new file mode 100644 index 0000000000..0804aed8e3 --- /dev/null +++ b/module/core/async_tools/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/core/async_tools/Readme.md b/module/core/async_tools/Readme.md new file mode 100644 index 0000000000..0b469a2688 --- /dev/null +++ b/module/core/async_tools/Readme.md @@ -0,0 +1,6 @@ + + +# Module :: async_tools +[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/Moduleasync_fromPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/Moduleasync_fromPush.yml) [![docs.rs](https://img.shields.io/docsrs/async_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/async_tools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + +Toolkit for asynchronous programming. diff --git a/module/core/async_tools/src/lib.rs b/module/core/async_tools/src/lib.rs new file mode 100644 index 0000000000..ab0bcbf7e8 --- /dev/null +++ b/module/core/async_tools/src/lib.rs @@ -0,0 +1,79 @@ + +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc( html_root_url = "https://docs.rs/async_tools/latest/async_tools/" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Namespace with dependencies. +#[ cfg( feature = "enabled" ) ] +pub mod dependency +{ + pub use ::async_trait; + pub use ::async_from; +} + +/// Internal namespace. +#[ cfg( feature = "enabled" ) ] +mod private +{ +} + +#[ cfg( feature = "enabled" ) ] +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +pub use own::*; + +/// Own namespace of the module. +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod own +{ + use super::*; + #[ doc( inline ) ] + pub use orphan::*; + + #[ doc( inline ) ] + pub use ::async_from::orphan::*; + +} + +/// Orphan namespace of the module. +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod orphan +{ + use super::*; + #[ doc( inline ) ] + pub use exposed::*; + +} + +/// Exposed namespace of the module. +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod exposed +{ + use super::*; + + #[ doc( inline ) ] + pub use prelude::*; + + #[ doc( inline ) ] + pub use ::async_trait::async_trait; + + #[ doc( inline ) ] + pub use ::async_from::exposed::*; + +} + +/// Prelude to use essentials: `use my_module::prelude::*`. +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod prelude +{ + use super::*; + + #[ doc( inline ) ] + pub use ::async_from::prelude::*; + +} diff --git a/module/core/async_tools/tests/inc/basic_test.rs b/module/core/async_tools/tests/inc/basic_test.rs new file mode 100644 index 0000000000..c652899926 --- /dev/null +++ b/module/core/async_tools/tests/inc/basic_test.rs @@ -0,0 +1,84 @@ +use super::*; + +#[ tokio::test ] +async fn async_try_from_test() +{ + + // Example implementation of AsyncTryFrom for a custom type + struct MyNumber( u32 ); + + // xxx : qqq : broken + // #[ the_module::async_trait ] + // impl< 'a > the_module::AsyncTryFrom< &'a str > for MyNumber + // { + // type Error = std::num::ParseIntError; + // + // async fn async_try_from( value : &'a str ) -> Result< Self, Self::Error > + // { + // // Simulate asynchronous work + // tokio::time::sleep( tokio::time::Duration::from_millis( 1 ) ).await; + // let num = value.parse::< u32 >()?; + // Ok( MyNumber( num ) ) + // } + // } + + #[ the_module::async_trait ] + impl the_module::AsyncTryFrom< String > for MyNumber + { + type Error = std::num::ParseIntError; + + async fn async_try_from( value : String ) -> Result< Self, Self::Error > + { + // Simulate asynchronous work + tokio::time::sleep( tokio::time::Duration::from_millis( 10 ) ).await; + let num = value.parse::< u32 >()?; + Ok( MyNumber( num ) ) + } + } + + use the_module::{ AsyncTryFrom, AsyncTryInto }; + + // Using AsyncTryFrom directly + match MyNumber::async_try_from( "42".to_string() ).await + { + Ok( my_num ) => println!( "Converted successfully: {}", my_num.0 ), + Err( e ) => println!( "Conversion failed: {:?}", e ), + } + + // Using AsyncTryInto, which is automatically implemented + let result : Result< MyNumber, _ > = "42".to_string().async_try_into().await; + match result + { + Ok( my_num ) => println!( "Converted successfully using AsyncTryInto: {}", my_num.0 ), + Err( e ) => println!( "Conversion failed using AsyncTryInto: {:?}", e ), + } +} + +#[ tokio::test ] +async fn async_from_test() +{ + // Example implementation of AsyncFrom for a custom type + struct MyNumber( u32 ); + + #[ the_module::async_trait ] + impl the_module::AsyncFrom< String > for MyNumber + { + async fn async_tools( value : String ) -> Self + { + // Simulate asynchronous work + tokio::time::sleep( tokio::time::Duration::from_millis( 10 ) ).await; + let num = value.parse::< u32 >().unwrap_or( 0 ); + MyNumber( num ) + } + } + + use the_module::{ AsyncFrom, AsyncInto }; + + // Using AsyncFrom directly + let my_num : MyNumber = MyNumber::async_tools( "42".to_string() ).await; + println!( "Converted successfully using AsyncFrom: {}", my_num.0 ); + + // Using AsyncInto, which is automatically implemented + let my_num : MyNumber = "42".to_string().async_into().await; + println!( "Converted successfully using AsyncInto: {}", my_num.0 ); +} diff --git a/module/core/async_tools/tests/inc/mod.rs b/module/core/async_tools/tests/inc/mod.rs new file mode 100644 index 0000000000..329271ad56 --- /dev/null +++ b/module/core/async_tools/tests/inc/mod.rs @@ -0,0 +1,3 @@ +use super::*; + +mod basic_test; diff --git a/module/core/async_tools/tests/tests.rs b/module/core/async_tools/tests/tests.rs new file mode 100644 index 0000000000..42f32553db --- /dev/null +++ b/module/core/async_tools/tests/tests.rs @@ -0,0 +1,10 @@ +#![ allow( unused_imports ) ] + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +use async_tools as the_module; +// use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +#[ path = "../../../../module/core/async_from/tests/inc/mod.rs" ] +mod inc; diff --git a/module/core/clone_dyn/Cargo.toml b/module/core/clone_dyn/Cargo.toml index df7631e07c..400ba0e1fb 100644 --- a/module/core/clone_dyn/Cargo.toml +++ b/module/core/clone_dyn/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clone_dyn" -version = "0.24.0" +version = "0.29.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -26,16 +26,17 @@ all-features = false [features] -default = [ "enabled", "clone_dyn_types", "clone_dyn_meta" ] -full = [ "enabled", "clone_dyn_types", "clone_dyn_meta" ] +default = [ "enabled", "clone_dyn_types", "derive_clone_dyn" ] +full = [ "enabled", "clone_dyn_types", "derive_clone_dyn" ] enabled = [] clone_dyn_types = [ "dep:clone_dyn_types", "clone_dyn_types/enabled" ] -clone_dyn_meta = [ "dep:clone_dyn_meta", "clone_dyn_meta/enabled", "clone_dyn_types" ] +derive_clone_dyn = [ "dep:clone_dyn_meta", "clone_dyn_meta/enabled", "clone_dyn_types" ] [dependencies] clone_dyn_meta = { workspace = true, optional = true } clone_dyn_types = { workspace = true, optional = true } +# clone_dyn_types = { version = "0.27.0", optional = true } [dev-dependencies] test_tools = { workspace = true } diff --git a/module/core/clone_dyn/License b/module/core/clone_dyn/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/clone_dyn/License +++ b/module/core/clone_dyn/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/clone_dyn/Readme.md b/module/core/clone_dyn/Readme.md index f23c03a8c9..43e159b62c 100644 --- a/module/core/clone_dyn/Readme.md +++ b/module/core/clone_dyn/Readme.md @@ -70,9 +70,9 @@ The main function demonstrates the overall usage by creating a vector, obtaining ```rust -# #[ cfg( not( all( feature = "enabled", feature = "clone_dyn_meta" ) ) ) ] +# #[ cfg( not( all( feature = "enabled", feature = "derive_clone_dyn" ) ) ) ] # fn main() {} -# #[ cfg( all( feature = "enabled", feature = "clone_dyn_meta" ) ) ] +# #[ cfg( all( feature = "enabled", feature = "derive_clone_dyn" ) ) ] # fn main() # { diff --git a/module/core/clone_dyn/examples/clone_dyn_trivial.rs b/module/core/clone_dyn/examples/clone_dyn_trivial.rs index cd67d1cbea..aecf14563d 100644 --- a/module/core/clone_dyn/examples/clone_dyn_trivial.rs +++ b/module/core/clone_dyn/examples/clone_dyn_trivial.rs @@ -56,9 +56,9 @@ //! The main function demonstrates the overall usage by creating a vector, obtaining an iterator, and using the iterator to print elements. //! -#[ cfg( not( all( feature = "enabled", feature = "clone_dyn_meta" ) ) ) ] +#[ cfg( not( all( feature = "enabled", feature = "derive_clone_dyn" ) ) ) ] fn main() {} -#[ cfg( all( feature = "enabled", feature = "clone_dyn_meta" ) ) ] +#[ cfg( all( feature = "enabled", feature = "derive_clone_dyn" ) ) ] fn main() { use clone_dyn::{ clone_dyn, CloneDyn }; diff --git a/module/core/clone_dyn/src/lib.rs b/module/core/clone_dyn/src/lib.rs index 2f2ba25890..18e0150163 100644 --- a/module/core/clone_dyn/src/lib.rs +++ b/module/core/clone_dyn/src/lib.rs @@ -5,11 +5,10 @@ #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] /// Namespace with dependencies. - #[ cfg( feature = "enabled" ) ] pub mod dependency { - #[ cfg( feature = "clone_dyn_meta" ) ] + #[ cfg( feature = "derive_clone_dyn" ) ] pub use ::clone_dyn_meta; #[ cfg( feature = "clone_dyn_types" ) ] pub use ::clone_dyn_types; @@ -72,7 +71,7 @@ pub mod prelude #[ doc( inline ) ] #[ allow( unused_imports ) ] - #[ cfg( feature = "clone_dyn_meta" ) ] + #[ cfg( feature = "derive_clone_dyn" ) ] pub use ::clone_dyn_meta::clone_dyn; #[ doc( inline ) ] diff --git a/module/core/clone_dyn/tests/inc/mod.rs b/module/core/clone_dyn/tests/inc/mod.rs index fc05ba6236..6e0cb7295a 100644 --- a/module/core/clone_dyn/tests/inc/mod.rs +++ b/module/core/clone_dyn/tests/inc/mod.rs @@ -2,9 +2,9 @@ #[ allow( unused_imports ) ] use super::*; -#[ cfg( feature = "clone_dyn_meta" ) ] +#[ cfg( feature = "derive_clone_dyn" ) ] pub mod basic_manual; -#[ cfg( feature = "clone_dyn_meta" ) ] +#[ cfg( feature = "derive_clone_dyn" ) ] pub mod basic; -#[ cfg( feature = "clone_dyn_meta" ) ] +#[ cfg( feature = "derive_clone_dyn" ) ] pub mod parametrized; diff --git a/module/core/clone_dyn_meta/Cargo.toml b/module/core/clone_dyn_meta/Cargo.toml index 2359fb19c7..d77ad96088 100644 --- a/module/core/clone_dyn_meta/Cargo.toml +++ b/module/core/clone_dyn_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clone_dyn_meta" -version = "0.24.0" +version = "0.27.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/clone_dyn_meta/License b/module/core/clone_dyn_meta/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/clone_dyn_meta/License +++ b/module/core/clone_dyn_meta/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/clone_dyn_types/Cargo.toml b/module/core/clone_dyn_types/Cargo.toml index b9c3e6ee14..4a145d0c13 100644 --- a/module/core/clone_dyn_types/Cargo.toml +++ b/module/core/clone_dyn_types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clone_dyn_types" -version = "0.23.0" +version = "0.26.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/clone_dyn_types/License b/module/core/clone_dyn_types/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/clone_dyn_types/License +++ b/module/core/clone_dyn_types/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/collection_tools/Cargo.toml b/module/core/collection_tools/Cargo.toml index 58c96881f9..86dcfa51b3 100644 --- a/module/core/collection_tools/Cargo.toml +++ b/module/core/collection_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "collection_tools" -version = "0.12.0" +version = "0.15.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -28,7 +28,7 @@ all-features = false [features] no_std = [ - "test_tools/no_std", + # "test_tools/no_std", ] use_alloc = [ diff --git a/module/core/collection_tools/License b/module/core/collection_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/collection_tools/License +++ b/module/core/collection_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/data_type/Cargo.toml b/module/core/data_type/Cargo.toml index f42fae69bd..c5f7155d97 100644 --- a/module/core/data_type/Cargo.toml +++ b/module/core/data_type/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "data_type" -version = "0.10.0" +version = "0.12.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -32,7 +32,6 @@ default = [ # "use_std", "enabled", "dt_either", - "dt_prelude", "dt_interval", "dt_collection", # "dt_make", @@ -43,7 +42,6 @@ full = [ # "use_std", "enabled", "dt_either", - "dt_prelude", "dt_interval", "dt_collection", # "dt_make", @@ -54,43 +52,18 @@ no_std = [] use_alloc = [ "no_std" ] enabled = [] -# dt_prelude = [ "collection_tools/reexports" ] -dt_prelude = [] # rid of maybe? dt_interval = [ "interval_adapter/enabled" ] dt_collection = [ "collection_tools/enabled" ] dt_either = [ "either" ] # qqq : for Anton : integrate all features of collection_tools into data_type and reuse tests -# dt_type_constructor = [ "type_constructor/enabled" ] -# dt_make = [ "type_constructor/make" ] -# dt_vectorized_from = [ "type_constructor/vectorized_from" ] - -# = entries - -# [lib] -# name = "data_type" -# path = "src/dt/data_type_lib.rs" - -# [[test]] -# name = "data_type_test" -# path = "tests/dt/data_type_tests.rs" -# -# [[test]] -# name = "data_type_smoke_test" -# path = "tests/_integration_test/smoke_test.rs" -# -# [[example]] -# name = "data_type_trivial" -# path = "examples/data_type_trivial/src/main.rs" - [dependencies] ## external either = { version = "~1.6", optional = true } ## internal -# type_constructor = { workspace = true } interval_adapter = { workspace = true } collection_tools = { workspace = true } diff --git a/module/core/data_type/License b/module/core/data_type/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/data_type/License +++ b/module/core/data_type/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/data_type/src/lib.rs b/module/core/data_type/src/lib.rs index 5f16a02ecb..7cdff4fae2 100644 --- a/module/core/data_type/src/lib.rs +++ b/module/core/data_type/src/lib.rs @@ -123,13 +123,13 @@ pub mod prelude pub use crate::dependency::collection_tools::prelude::*; // #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] - #[ cfg( feature = "dt_prelude" ) ] - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use core:: - { - fmt, - }; + // #[ cfg( feature = "dt_prelude" ) ] + // #[ doc( inline ) ] + // #[ allow( unused_imports ) ] + // pub use core:: + // { + // fmt, + // }; } diff --git a/module/core/derive_tools/Cargo.toml b/module/core/derive_tools/Cargo.toml index d41086762e..a2d1e31fb4 100644 --- a/module/core/derive_tools/Cargo.toml +++ b/module/core/derive_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "derive_tools" -version = "0.28.0" +version = "0.32.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -203,7 +203,7 @@ parse-display = { version = "~0.8.2", optional = true, default-features = false ## internal derive_tools_meta = { workspace = true, optional = true, features = [] } variadic_from = { workspace = true, optional = true, features = [] } -clone_dyn = { workspace = true, optional = true, features = [ "clone_dyn_types", "clone_dyn_meta" ] } +clone_dyn = { workspace = true, optional = true, features = [ "clone_dyn_types", "derive_clone_dyn" ] } [dev-dependencies] diff --git a/module/core/derive_tools/License b/module/core/derive_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/derive_tools/License +++ b/module/core/derive_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/derive_tools/src/lib.rs b/module/core/derive_tools/src/lib.rs index 7c3ddfdecf..62468ed1dc 100644 --- a/module/core/derive_tools/src/lib.rs +++ b/module/core/derive_tools/src/lib.rs @@ -144,6 +144,7 @@ pub mod exposed #[ cfg( feature = "derive_strum" ) ] #[ doc( inline ) ] pub use ::strum::*; + // qqq : xxx : name all #[ cfg( any( feature = "derive_variadic_from", feature = "type_variadic_from" ) ) ] #[ doc( inline ) ] @@ -201,3 +202,44 @@ pub mod prelude pub use ::variadic_from::prelude::*; } + +// xxx : minimize dependendencies +// Adding aho-corasick v1.1.3 +// Adding cfg_aliases v0.1.1 (latest: v0.2.1) +// Adding clone_dyn v0.24.0 +// Adding clone_dyn_meta v0.24.0 +// Adding clone_dyn_types v0.23.0 +// Adding collection_tools v0.12.0 +// Adding const_format v0.2.33 +// Adding const_format_proc_macros v0.2.33 +// Adding convert_case v0.6.0 +// Adding derive_more v1.0.0 +// Adding derive_more-impl v1.0.0 +// Adding derive_tools v0.28.0 +// Adding derive_tools_meta v0.27.0 +// Adding either v1.13.0 +// Adding former_types v2.8.0 +// Adding heck v0.4.1 (latest: v0.5.0) +// Adding interval_adapter v0.24.0 +// Adding iter_tools v0.21.0 +// Adding itertools v0.11.0 (latest: v0.13.0) +// Adding macro_tools v0.40.0 +// Adding parse-display v0.8.2 (latest: v0.10.0) +// Adding parse-display-derive v0.8.2 (latest: v0.10.0) +// Adding phf v0.10.1 (latest: v0.11.2) +// Adding phf_generator v0.10.0 (latest: v0.11.2) +// Adding phf_macros v0.10.0 (latest: v0.11.2) +// Adding phf_shared v0.10.0 (latest: v0.11.2) +// Adding proc-macro-hack v0.5.20+deprecated +// Adding regex v1.10.6 +// Adding regex-automata v0.4.7 +// Adding regex-syntax v0.7.5 (latest: v0.8.4) +// Adding regex-syntax v0.8.4 +// Adding rustversion v1.0.17 +// Adding structmeta v0.2.0 (latest: v0.3.0) +// Adding structmeta-derive v0.2.0 (latest: v0.3.0) +// Adding strum v0.25.0 (latest: v0.26.3) +// Adding strum_macros v0.25.3 (latest: v0.26.4) +// Adding unicode-segmentation v1.11.0 +// Adding unicode-xid v0.2.5 +// Adding variadic_from v0.23.0 \ No newline at end of file diff --git a/module/core/derive_tools/tests/inc/new/basic_manual_test.rs b/module/core/derive_tools/tests/inc/new/basic_manual_test.rs index 993956eefa..c7f40395c6 100644 --- a/module/core/derive_tools/tests/inc/new/basic_manual_test.rs +++ b/module/core/derive_tools/tests/inc/new/basic_manual_test.rs @@ -1,15 +1,20 @@ use super::*; -#[ derive( Debug, Clone, Copy, PartialEq ) ] -pub struct IsTransparent( bool ); - -impl IsTransparent +mod mod1 { - #[ inline( always ) ] - fn new( src : bool ) -> Self + + #[ derive( Debug, Clone, Copy, PartialEq ) ] + pub struct Struct1( pub bool ); + + impl Struct1 { - Self( src ) + #[ inline( always ) ] + pub fn new( src : bool ) -> Self + { + Self( src ) + } } + } include!( "./only_test/basic.rs" ); diff --git a/module/core/derive_tools/tests/inc/new/basic_test.rs b/module/core/derive_tools/tests/inc/new/basic_test.rs index 6cea8c5a49..c96850d3de 100644 --- a/module/core/derive_tools/tests/inc/new/basic_test.rs +++ b/module/core/derive_tools/tests/inc/new/basic_test.rs @@ -1,6 +1,10 @@ use super::*; -#[ derive( Debug, Clone, Copy, PartialEq, the_module::New ) ] -pub struct IsTransparent( bool ); +mod mod1 +{ + use super::*; + #[ derive( Debug, Clone, Copy, PartialEq, the_module::New ) ] + pub struct Struct1( pub bool ); +} include!( "./only_test/basic.rs" ); diff --git a/module/core/derive_tools/tests/inc/new/multiple_named_manual_test.rs b/module/core/derive_tools/tests/inc/new/multiple_named_manual_test.rs index 839456b1a0..45a7007502 100644 --- a/module/core/derive_tools/tests/inc/new/multiple_named_manual_test.rs +++ b/module/core/derive_tools/tests/inc/new/multiple_named_manual_test.rs @@ -1,19 +1,24 @@ use super::*; -#[ derive( Debug, PartialEq, Eq ) ] -struct StructNamedFields +mod mod1 { - a : i32, - b : bool, -} -impl StructNamedFields -{ - #[ inline( always ) ] - fn new( a : i32, b : bool ) -> Self + #[ derive( Debug, PartialEq, Eq ) ] + pub struct Struct1 + { + pub a : i32, + pub b : bool, + } + + impl Struct1 { - Self{ a, b } + #[ inline( always ) ] + pub fn new( a : i32, b : bool ) -> Self + { + Self{ a, b } + } } + } include!( "./only_test/multiple_named.rs" ); diff --git a/module/core/derive_tools/tests/inc/new/multiple_named_test.rs b/module/core/derive_tools/tests/inc/new/multiple_named_test.rs index c3988146df..3e148771eb 100644 --- a/module/core/derive_tools/tests/inc/new/multiple_named_test.rs +++ b/module/core/derive_tools/tests/inc/new/multiple_named_test.rs @@ -1,11 +1,17 @@ use super::*; -#[ derive( Debug, PartialEq, Eq, the_module::New ) ] -// #[ debug ] -struct StructNamedFields +mod mod1 { - a : i32, - b : bool, + use super::*; + + #[ derive( Debug, PartialEq, Eq, the_module::New ) ] + // #[ debug ] + pub struct Struct1 + { + pub a : i32, + pub b : bool, + } + } include!( "./only_test/multiple_named.rs" ); diff --git a/module/core/derive_tools/tests/inc/new/multiple_unnamed_manual_test.rs b/module/core/derive_tools/tests/inc/new/multiple_unnamed_manual_test.rs index 08ee277851..bed9e79851 100644 --- a/module/core/derive_tools/tests/inc/new/multiple_unnamed_manual_test.rs +++ b/module/core/derive_tools/tests/inc/new/multiple_unnamed_manual_test.rs @@ -1,15 +1,20 @@ use super::*; -#[ derive( Debug, PartialEq, Eq ) ] -struct StructWithManyFields( i32, bool ); - -impl StructWithManyFields +mod mod1 { - #[ inline( always ) ] - fn new( src1 : i32, src2 : bool ) -> Self + + #[ derive( Debug, PartialEq, Eq ) ] + pub struct Struct1( pub i32, pub bool ); + + impl Struct1 { - Self( src1, src2 ) + #[ inline( always ) ] + pub fn new( src1 : i32, src2 : bool ) -> Self + { + Self( src1, src2 ) + } } + } include!( "./only_test/multiple_unnamed.rs" ); diff --git a/module/core/derive_tools/tests/inc/new/multiple_unnamed_test.rs b/module/core/derive_tools/tests/inc/new/multiple_unnamed_test.rs index 6a8f882287..8df3f37489 100644 --- a/module/core/derive_tools/tests/inc/new/multiple_unnamed_test.rs +++ b/module/core/derive_tools/tests/inc/new/multiple_unnamed_test.rs @@ -1,6 +1,12 @@ use super::*; -#[ derive( Debug, PartialEq, Eq, the_module::New ) ] -struct StructWithManyFields( i32, bool ); +mod mod1 +{ + use super::*; + + #[ derive( Debug, PartialEq, Eq, the_module::New ) ] + pub struct Struct1( pub i32, pub bool ); + +} include!( "./only_test/multiple_unnamed.rs" ); diff --git a/module/core/derive_tools/tests/inc/new/named_manual_test.rs b/module/core/derive_tools/tests/inc/new/named_manual_test.rs index 679afeec66..56f656a1c9 100644 --- a/module/core/derive_tools/tests/inc/new/named_manual_test.rs +++ b/module/core/derive_tools/tests/inc/new/named_manual_test.rs @@ -1,18 +1,23 @@ use super::*; -#[ derive( Debug, PartialEq, Eq ) ] -struct MyStruct +mod mod1 { - a : i32, -} -impl MyStruct -{ - #[ inline( always ) ] - fn new( src : i32 ) -> Self + #[ derive( Debug, PartialEq, Eq ) ] + pub struct Struct1 + { + pub a : i32, + } + + impl Struct1 { - Self{ a : src } + #[ inline( always ) ] + pub fn new( src : i32 ) -> Self + { + Self{ a : src } + } } + } include!( "./only_test/named.rs" ); diff --git a/module/core/derive_tools/tests/inc/new/named_test.rs b/module/core/derive_tools/tests/inc/new/named_test.rs index 1df964f76f..66d8fd8ac0 100644 --- a/module/core/derive_tools/tests/inc/new/named_test.rs +++ b/module/core/derive_tools/tests/inc/new/named_test.rs @@ -1,9 +1,15 @@ use super::*; -#[ derive( Debug, PartialEq, Eq, the_module::New ) ] -struct MyStruct +mod mod1 { - a : i32, + use super::*; + + #[ derive( Debug, PartialEq, Eq, the_module::New ) ] + pub struct Struct1 + { + pub a : i32, + } + } include!( "./only_test/named.rs" ); diff --git a/module/core/derive_tools/tests/inc/new/only_test/basic.rs b/module/core/derive_tools/tests/inc/new/only_test/basic.rs index 7dadc915f2..cfaf3127df 100644 --- a/module/core/derive_tools/tests/inc/new/only_test/basic.rs +++ b/module/core/derive_tools/tests/inc/new/only_test/basic.rs @@ -2,12 +2,13 @@ #[ test ] fn from_test() { + use mod1::Struct1; - let got = IsTransparent::new( true ); - let exp = IsTransparent( true ); + let got = Struct1::new( true ); + let exp = Struct1( true ); a_id!( got, exp ); - let got = IsTransparent::new( false ); - let exp = IsTransparent( false ); + let got = Struct1::new( false ); + let exp = Struct1( false ); a_id!( got, exp ); } diff --git a/module/core/derive_tools/tests/inc/new/only_test/multiple_named.rs b/module/core/derive_tools/tests/inc/new/only_test/multiple_named.rs index eebdbba992..adf93b4c93 100644 --- a/module/core/derive_tools/tests/inc/new/only_test/multiple_named.rs +++ b/module/core/derive_tools/tests/inc/new/only_test/multiple_named.rs @@ -1,7 +1,9 @@ #[ test ] fn from_named() { - let got : StructNamedFields = StructNamedFields::new( 10, true ); - let exp = StructNamedFields{ a : 10 , b : true }; + use mod1::Struct1; + + let got : Struct1 = Struct1::new( 10, true ); + let exp = Struct1{ a : 10 , b : true }; a_id!( got, exp ); } diff --git a/module/core/derive_tools/tests/inc/new/only_test/multiple_unnamed.rs b/module/core/derive_tools/tests/inc/new/only_test/multiple_unnamed.rs index 94abf3c133..f8d960c898 100644 --- a/module/core/derive_tools/tests/inc/new/only_test/multiple_unnamed.rs +++ b/module/core/derive_tools/tests/inc/new/only_test/multiple_unnamed.rs @@ -1,7 +1,9 @@ #[ test ] fn from_named() { - let got : StructWithManyFields = StructWithManyFields::new( 10, true ); - let exp = StructWithManyFields( 10 , true ); + use mod1::Struct1; + + let got : Struct1 = Struct1::new( 10, true ); + let exp = Struct1( 10 , true ); a_id!( got, exp ); } diff --git a/module/core/derive_tools/tests/inc/new/only_test/named.rs b/module/core/derive_tools/tests/inc/new/only_test/named.rs index b654961735..71804413ce 100644 --- a/module/core/derive_tools/tests/inc/new/only_test/named.rs +++ b/module/core/derive_tools/tests/inc/new/only_test/named.rs @@ -1,7 +1,9 @@ #[ test ] fn from_named() { - let got : MyStruct = MyStruct::new( 13 ); - let exp = MyStruct { a : 13 }; + use mod1::Struct1; + + let got : Struct1 = Struct1::new( 13 ); + let exp = Struct1 { a : 13 }; a_id!( got, exp ); } diff --git a/module/core/derive_tools/tests/inc/new/only_test/unit.rs b/module/core/derive_tools/tests/inc/new/only_test/unit.rs index 279908a05d..9366152172 100644 --- a/module/core/derive_tools/tests/inc/new/only_test/unit.rs +++ b/module/core/derive_tools/tests/inc/new/only_test/unit.rs @@ -1,7 +1,9 @@ #[ test ] fn from_named() { - let got : UnitStruct = UnitStruct::new(); - let exp = UnitStruct; + use mod1::Struct1; + + let got : Struct1 = Struct1::new(); + let exp = Struct1; a_id!( got, exp ); } diff --git a/module/core/derive_tools/tests/inc/new/unit_manual_test.rs b/module/core/derive_tools/tests/inc/new/unit_manual_test.rs index d5fc60e6c5..2d04912112 100644 --- a/module/core/derive_tools/tests/inc/new/unit_manual_test.rs +++ b/module/core/derive_tools/tests/inc/new/unit_manual_test.rs @@ -1,15 +1,20 @@ use super::*; -#[ derive( Debug, Clone, Copy, PartialEq ) ] -struct UnitStruct; - -impl UnitStruct +mod mod1 { - #[ inline( always ) ] - fn new() -> Self + + #[ derive( Debug, Clone, Copy, PartialEq ) ] + pub struct Struct1; + + impl Struct1 { - Self + #[ inline( always ) ] + pub fn new() -> Self + { + Self + } } + } include!( "./only_test/unit.rs" ); diff --git a/module/core/derive_tools/tests/inc/new/unit_test.rs b/module/core/derive_tools/tests/inc/new/unit_test.rs index 606df185d8..4e40c31a0e 100644 --- a/module/core/derive_tools/tests/inc/new/unit_test.rs +++ b/module/core/derive_tools/tests/inc/new/unit_test.rs @@ -1,6 +1,12 @@ use super::*; -#[ derive( Debug, Clone, Copy, PartialEq, the_module::New ) ] -struct UnitStruct; +mod mod1 +{ + use super::*; + + #[ derive( Debug, Clone, Copy, PartialEq, the_module::New ) ] + pub struct Struct1; + +} include!( "./only_test/unit.rs" ); diff --git a/module/core/derive_tools_meta/Cargo.toml b/module/core/derive_tools_meta/Cargo.toml index b931c9806a..ce3e0ce395 100644 --- a/module/core/derive_tools_meta/Cargo.toml +++ b/module/core/derive_tools_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "derive_tools_meta" -version = "0.27.0" +version = "0.31.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/derive_tools_meta/License b/module/core/derive_tools_meta/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/derive_tools_meta/License +++ b/module/core/derive_tools_meta/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/derive_tools_meta/src/derive/new.rs b/module/core/derive_tools_meta/src/derive/new.rs index 2f0341c159..5e274c3eb1 100644 --- a/module/core/derive_tools_meta/src/derive/new.rs +++ b/module/core/derive_tools_meta/src/derive/new.rs @@ -145,7 +145,7 @@ fn generate_unit #generics_where { #[ inline( always ) ] - fn new() -> Self + pub fn new() -> Self { Self } @@ -175,8 +175,8 @@ fn generate_single_field_named #generics_where { #[ inline( always ) ] - // fn new( src : i32 ) -> Self - fn new( src : #field_type ) -> Self + // pub fn new( src : i32 ) -> Self + pub fn new( src : #field_type ) -> Self { // Self { a : src } Self { #field_name: src } @@ -207,8 +207,8 @@ fn generate_single_field #generics_where { #[ inline( always ) ] - // fn new( src : bool ) -> Self - fn new( src : #field_type ) -> Self + // pub fn new( src : bool ) -> Self + pub fn new( src : #field_type ) -> Self { // Self( src ) Self( src ) @@ -248,8 +248,8 @@ fn generate_multiple_fields_named< 'a > #generics_where { #[ inline( always ) ] - // fn new( src : ( i32, bool ) ) -> Self - fn new( #( #val_type ),* ) -> Self + // pub fn new( src : ( i32, bool ) ) -> Self + pub fn new( #( #val_type ),* ) -> Self { // StructNamedFields{ a : src.0, b : src.1 } #item_name { #( #field_names ),* } @@ -287,8 +287,8 @@ fn generate_multiple_fields< 'a > #generics_where { #[ inline( always ) ] - // fn new( src : (i32, bool) ) -> Self - fn new( src : ( #( #field_types ),* ) ) -> Self + // pub fn new( src : (i32, bool) ) -> Self + pub fn new( src : ( #( #field_types ),* ) ) -> Self { // StructWithManyFields( src.0, src.1 ) #item_name( #( #params ),* ) @@ -359,7 +359,7 @@ where {2} {{ #[ inline ] - fn new( src : {args} ) -> Self + pub fn new( src : {args} ) -> Self {{ Self::{variant_name}( {use_src} ) }} @@ -388,7 +388,7 @@ field : {variant_name}"#, #generics_where { #[ inline ] - fn new( src : #args ) -> Self + pub fn new( src : #args ) -> Self { Self::#variant_name( #use_src ) } diff --git a/module/core/diagnostics_tools/Cargo.toml b/module/core/diagnostics_tools/Cargo.toml index c2b7d7e994..6b48adc190 100644 --- a/module/core/diagnostics_tools/Cargo.toml +++ b/module/core/diagnostics_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "diagnostics_tools" -version = "0.8.0" +version = "0.10.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/diagnostics_tools/License b/module/core/diagnostics_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/diagnostics_tools/License +++ b/module/core/diagnostics_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/error_tools/Cargo.toml b/module/core/error_tools/Cargo.toml index 62f8ec7e88..de02c81004 100644 --- a/module/core/error_tools/Cargo.toml +++ b/module/core/error_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "error_tools" -version = "0.17.0" +version = "0.19.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/error_tools/License b/module/core/error_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/error_tools/License +++ b/module/core/error_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/for_each/Cargo.toml b/module/core/for_each/Cargo.toml index 877ccbe184..2e43d14153 100644 --- a/module/core/for_each/Cargo.toml +++ b/module/core/for_each/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "for_each" -version = "0.8.0" +version = "0.10.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/for_each/License b/module/core/for_each/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/for_each/License +++ b/module/core/for_each/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/format_tools/License b/module/core/format_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/format_tools/License +++ b/module/core/format_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/format_tools/src/format.rs b/module/core/format_tools/src/format.rs index 4e55517dcc..2abf7f18a4 100644 --- a/module/core/format_tools/src/format.rs +++ b/module/core/format_tools/src/format.rs @@ -17,8 +17,8 @@ mod private macro_rules! _field_with_key { ( + $path : expr, $key : ident, - $src : expr, $how : ty, $fallback1 : ty, $fallback2 : ty @@ -28,9 +28,10 @@ mod private {{ ( ::core::stringify!( $key ), - $crate::OptionalCow::< '_, str, $how >::from + // $crate::OptionalCow::< '_, str, $how >::from + Option::Some ( - $crate::to_string_with_fallback!( $how, $fallback1, $fallback2, $src ) + $crate::to_string_with_fallback!( $how, $fallback1, $fallback2, $path ) ), ) }}; @@ -47,32 +48,39 @@ mod private macro_rules! _field { - ( & $path:ident.$( $key:ident )+, $how : ty, $fallback1 : ty, $fallback2 : ty $(,)? ) => + // dst.push( field!( &self.id ) ); + ( ( & $pre:ident.$( $key:tt )+ ), $how : ty, $fallback1 : ty, $fallback2 : ty $(,)? ) => {{ - $crate::_field!( # ( & $path . ) ( $( $key )+ ) ( $how, $fallback1, $fallback2 ) ) + $crate::_field!( # ( & $pre . ) ( $( $key )+ ) ( $how, $fallback1, $fallback2 ) ) }}; - ( $path:ident.$( $key:ident )+, $how : ty, $fallback1 : ty, $fallback2 : ty $(,)? ) => + // dst.push( field!( self.id ) ); + ( ( $pre:ident.$( $key:tt )+ ), $how : ty, $fallback1 : ty, $fallback2 : ty $(,)? ) => {{ - $crate::_field!( # ( $path . ) ( $( $key )+ ) ( $how, $fallback1, $fallback2 ) ) + $crate::_field!( # ( $pre . ) ( $( $key )+ ) ( $how, $fallback1, $fallback2 ) ) }}; - ( & $key:ident, $how : ty, $fallback1 : ty, $fallback2 : ty $(,)? ) => + // dst.push( field!( &tools ) ); + ( ( & $key:ident ), $how : ty, $fallback1 : ty, $fallback2 : ty $(,)? ) => {{ - $crate::_field!( # () ( $key ) ( $how, $fallback1, $fallback2 ) ) + $crate::_field!( # () ( & $key ) ( $how, $fallback1, $fallback2 ) ) }}; - ( $key:ident, $how : ty, $fallback1 : ty, $fallback2 : ty $(,)? ) => + // dst.push( field!( tools ) ); + ( ( $key:ident ), $how : ty, $fallback1 : ty, $fallback2 : ty $(,)? ) => {{ $crate::_field!( # () ( $key ) ( $how, $fallback1, $fallback2 ) ) }}; // private + // ( a.b. ) + // ( c.d ) + // ( $crate::WithRef, $crate::WithDebug, $crate::WithDebug ) ( # ( $( $prefix:tt )* ) - ( $prekey:ident.$( $field:ident )+ ) + ( $prekey:ident.$( $field:tt )+ ) ( $how : ty, $fallback1 : ty, $fallback2 : ty ) ) => @@ -80,6 +88,23 @@ mod private $crate::_field!( # ( $( $prefix )* $prekey . ) ( $( $field )+ ) ( $how, $fallback1, $fallback2 ) ) }}; + // ( a.b. ) + // ( 0.d ) + // ( $crate::WithRef, $crate::WithDebug, $crate::WithDebug ) + ( + # + ( $( $prefix:tt )* ) + ( $prekey:tt.$( $field:tt )+ ) + ( $how : ty, $fallback1 : ty, $fallback2 : ty ) + ) + => + {{ + $crate::_field!( # ( $( $prefix )* $prekey . ) ( $( $field )+ ) ( $how, $fallback1, $fallback2 ) ) + }}; + + // ( a.b.c. ) + // ( d ) + // ( $crate::WithRef, $crate::WithDebug, $crate::WithDebug ) ( # ( $( $prefix:tt )* ) @@ -91,6 +116,9 @@ mod private $crate::_field!( # # ( $( $prefix )* ) ( $key ) ( $how, $fallback1, $fallback2 ) ) }}; + // ( a.b.c ) + // ( d ) + // ( $crate::WithRef, $crate::WithDebug, $crate::WithDebug ) ( # # ( $( $prefix:tt )* ) @@ -99,7 +127,8 @@ mod private ) => {{ - $crate::_field_with_key!( $key, $( $prefix )* $key, $how, $fallback1, $fallback2 ) + // _field_with_key!( id, &self. id, $crate::WithRef, $crate::WithDisplay, $crate::WithDebugMultiline ) + $crate::_field_with_key!( $( $prefix )* $key, $key, $how, $fallback1, $fallback2 ) }}; } @@ -129,7 +158,7 @@ mod private ) => {{ - $crate::_field_with_key!( $key, $src, $crate::WithRef, $crate::WithDisplay, $crate::WithDebugMultiline ) + $crate::_field_with_key!( $src, $key, $crate::WithRef, $crate::WithDisplay, $crate::WithDebugMultiline ) }}; } @@ -144,7 +173,7 @@ mod private ( $( $t:tt )+ ) => {{ - $crate::_field!( $( $t )+, $crate::WithRef, $crate::WithDisplay, $crate::WithDebugMultiline ) + $crate::_field!( ( $( $t )+ ), $crate::WithRef, $crate::WithDisplay, $crate::WithDebugMultiline ) }} } @@ -178,7 +207,7 @@ mod private ) => {{ - $crate::_field_with_key!( $key, $src, $crate::WithRef, $crate::WithDisplay, $crate::WithDebug ) + $crate::_field_with_key!( $src, $key, $crate::WithRef, $crate::WithDisplay, $crate::WithDebug ) }}; } @@ -193,7 +222,7 @@ mod private ( $( $t:tt )+ ) => {{ - $crate::_field!( $( $t )+, $crate::WithRef, $crate::WithDisplay, $crate::WithDebug ) + $crate::_field!( ( $( $t )+ ), $crate::WithRef, $crate::WithDisplay, $crate::WithDebug ) }} } @@ -226,7 +255,7 @@ mod private ) => {{ - $crate::_field_with_key!( $key, $src, $crate::WithRef, $crate::WithDebug, $crate::WithDebug ) + $crate::_field_with_key!( $src, $key, $crate::WithRef, $crate::WithDebug, $crate::WithDebug ) }}; } @@ -240,7 +269,7 @@ mod private ( $( $t:tt )+ ) => {{ - $crate::_field!( $( $t )+, $crate::WithRef, $crate::WithDebug, $crate::WithDebug ) + $crate::_field!( ( $( $t )+ ), $crate::WithRef, $crate::WithDebug, $crate::WithDebug ) }} } @@ -261,6 +290,11 @@ pub mod table; pub mod to_string; pub mod to_string_with_fallback; +/// A strucutre for diagnostic and demonstration purpose. +#[ doc( hidden ) ] +#[ cfg( debug_assertions ) ] +pub mod test_object_without_impl; + #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use own::*; @@ -304,6 +338,14 @@ pub mod orphan ref_or_debug, }; + #[ doc( hidden ) ] + #[ cfg( debug_assertions ) ] + pub use test_object_without_impl:: + { + TestObjectWithoutImpl, + test_objects_gen, + }; + } /// Exposed namespace of the module. diff --git a/module/core/format_tools/src/format/as_table.rs b/module/core/format_tools/src/format/as_table.rs index 4e70ba233d..b1c48c159f 100644 --- a/module/core/format_tools/src/format/as_table.rs +++ b/module/core/format_tools/src/format/as_table.rs @@ -21,29 +21,29 @@ mod private /// #[ repr( transparent ) ] #[ derive( Clone, Copy ) ] - pub struct AsTable< 'table, Table, RowKey, Row, CellKey, CellRepr > + pub struct AsTable< 'table, Table, RowKey, Row, CellKey> ( &'table Table, ::core::marker::PhantomData <( &'table (), - fn() -> ( &'table RowKey, Row, &'table CellKey, CellRepr ), + fn() -> ( &'table RowKey, Row, &'table CellKey ), )>, ) where RowKey : table::RowKey, - Row : Cells< CellKey, CellRepr >, + Row : Cells< CellKey>, CellKey : table::CellKey + ?Sized, - CellRepr : table::CellRepr + // CellRepr : table::CellRepr ; - impl< 'table, Table, RowKey, Row, CellKey, CellRepr > - AsTable< 'table, Table, RowKey, Row, CellKey, CellRepr > + impl< 'table, Table, RowKey, Row, CellKey> + AsTable< 'table, Table, RowKey, Row, CellKey> where RowKey : table::RowKey, - Row : Cells< CellKey, CellRepr >, + Row : Cells< CellKey>, CellKey : table::CellKey + ?Sized, - CellRepr : table::CellRepr, + // CellRepr : table::CellRepr, { /// Just a constructor. pub fn new( src : &'table Table ) -> Self @@ -52,13 +52,13 @@ mod private } } - impl< 'table, Table, RowKey, Row, CellKey, CellRepr > AsRef< Table > - for AsTable< 'table, Table, RowKey, Row, CellKey, CellRepr > + impl< 'table, Table, RowKey, Row, CellKey> AsRef< Table > + for AsTable< 'table, Table, RowKey, Row, CellKey> where RowKey : table::RowKey, - Row : Cells< CellKey, CellRepr >, + Row : Cells< CellKey>, CellKey : table::CellKey + ?Sized, - CellRepr : table::CellRepr, + // CellRepr : table::CellRepr, { fn as_ref( &self ) -> &Table { @@ -66,13 +66,13 @@ mod private } } - impl< 'table, Table, RowKey, Row, CellKey, CellRepr > Deref - for AsTable< 'table, Table, RowKey, Row, CellKey, CellRepr > + impl< 'table, Table, RowKey, Row, CellKey> Deref + for AsTable< 'table, Table, RowKey, Row, CellKey> where RowKey : table::RowKey, - Row : Cells< CellKey, CellRepr >, + Row : Cells< CellKey>, CellKey : table::CellKey + ?Sized, - CellRepr : table::CellRepr, + // CellRepr : table::CellRepr, { type Target = Table; @@ -82,13 +82,13 @@ mod private } } - impl< 'table, Table, RowKey, Row, CellKey, CellRepr > From< &'table Table > - for AsTable< 'table, Table, RowKey, Row, CellKey, CellRepr > + impl< 'table, Table, RowKey, Row, CellKey> From< &'table Table > + for AsTable< 'table, Table, RowKey, Row, CellKey> where RowKey : table::RowKey, - Row : Cells< CellKey, CellRepr >, + Row : Cells< CellKey>, CellKey : table::CellKey + ?Sized, - CellRepr : table::CellRepr, + // CellRepr : table::CellRepr, { fn from( table : &'table Table ) -> Self { @@ -96,14 +96,14 @@ mod private } } - impl< 'table, Table, RowKey, Row, CellKey, CellRepr > fmt::Debug - for AsTable< 'table, Table, RowKey, Row, CellKey, CellRepr > + impl< 'table, Table, RowKey, Row, CellKey> fmt::Debug + for AsTable< 'table, Table, RowKey, Row, CellKey> where Table : fmt::Debug, RowKey : table::RowKey, - Row : Cells< CellKey, CellRepr >, + Row : Cells< CellKey>, CellKey : table::CellKey + ?Sized, - CellRepr : table::CellRepr, + // CellRepr : table::CellRepr, { fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result { @@ -130,25 +130,25 @@ mod private type RowKey : table::RowKey; /// The type representing a row, must implement `Cells`. - type Row : Cells< Self::CellKey, Self::CellRepr >; + type Row : Cells< Self::CellKey >; /// The type used to identify cells within a row, must implement `Key` and can be unsized. type CellKey : table::CellKey + ?Sized; - /// The type representing the content of a cell, must implement `CellRepr`. - type CellRepr : table::CellRepr; + // /// The type representing the content of a cell, must implement `CellRepr`. + // type // CellRepr : table::CellRepr; /// Converts the data reference into an `AsTable` reference. - fn as_table( &self ) -> AsTable< '_, Self::Table, Self::RowKey, Self::Row, Self::CellKey, Self::CellRepr >; + fn as_table( &self ) -> AsTable< '_, Self::Table, Self::RowKey, Self::Row, Self::CellKey >; } - impl< 'table, Table, RowKey, Row, CellKey, CellRepr > IntoAsTable - for AsTable< 'table, Table, RowKey, Row, CellKey, CellRepr > + impl< 'table, Table, RowKey, Row, CellKey> IntoAsTable + for AsTable< 'table, Table, RowKey, Row, CellKey> where RowKey : table::RowKey, - Row : Cells< CellKey, CellRepr >, + Row : Cells< CellKey>, CellKey : table::CellKey + ?Sized, - CellRepr : table::CellRepr, + // CellRepr : table::CellRepr, Self : Copy, { @@ -156,9 +156,9 @@ mod private type RowKey = RowKey; type Row = Row; type CellKey = CellKey; - type CellRepr = CellRepr; + // type CellRepr = CellRepr; - fn as_table( &self ) -> AsTable< '_, Self::Table, Self::RowKey, Self::Row, Self::CellKey, Self::CellRepr > + fn as_table( &self ) -> AsTable< '_, Self::Table, Self::RowKey, Self::Row, Self::CellKey > { *self } @@ -168,9 +168,9 @@ mod private // impl< Row > IntoAsTable // for Vec< Row > // where -// Row : Cells< Self::CellKey, Self::CellRepr >, +// Row : Cells< Self::CellKey >, // // CellKey : table::CellKey + ?Sized, -// // CellRepr : table::CellRepr, +// // // CellRepr : table::CellRepr, // { // // type Table = Self; @@ -179,14 +179,14 @@ mod private // type CellKey = str; // type CellRepr = WithRef; // -// fn as_table( &self ) -> AsTable< '_, Self::Table, Self::RowKey, Self::Row, Self::CellKey, Self::CellRepr > +// fn as_table( &self ) -> AsTable< '_, Self::Table, Self::RowKey, Self::Row, Self::CellKey > // { // AsTable::from( self ) // } // // } - // pub struct AsTable< 'table, Table, RowKey, Row, CellKey, CellRepr > + // pub struct AsTable< 'table, Table, RowKey, Row, CellKey> } diff --git a/module/core/format_tools/src/format/md_math.rs b/module/core/format_tools/src/format/md_math.rs index d4de6ae6af..196b0ee811 100644 --- a/module/core/format_tools/src/format/md_math.rs +++ b/module/core/format_tools/src/format/md_math.rs @@ -3,6 +3,8 @@ //! Provides functionality for converting multidimensional indices into flat offsets, //! useful for operations involving multidimensional arrays or grids. +// xxx : use crate mdmath + /// Internal namespace. mod private { diff --git a/module/core/format_tools/src/format/output_format.rs b/module/core/format_tools/src/format/output_format.rs index 511d12db79..69acca8515 100644 --- a/module/core/format_tools/src/format/output_format.rs +++ b/module/core/format_tools/src/format/output_format.rs @@ -1,6 +1,6 @@ //! Customizable format of printing table. //! -//! # Example of ordinary format +//! # Example of table format //! //! ```text //! sid | sname | gap @@ -74,14 +74,15 @@ mod private #[ inline( always ) ] fn default() -> Self { - super::ordinary::Ordinary::instance() + super::table::Table::instance() } } } -mod ordinary; +mod table; mod records; +mod keys; #[ allow( unused_imports ) ] pub use own::*; @@ -97,8 +98,9 @@ pub mod own #[ doc( inline ) ] pub use { - ordinary::Ordinary, + table::Table, records::Records, + keys::Keys, }; #[ doc( inline ) ] diff --git a/module/core/format_tools/src/format/output_format/keys.rs b/module/core/format_tools/src/format/output_format/keys.rs new file mode 100644 index 0000000000..55ee27b023 --- /dev/null +++ b/module/core/format_tools/src/format/output_format/keys.rs @@ -0,0 +1,107 @@ +//! Implement keys list output format. +//! +//! # Example +//! +//! ```text +//! ``` +//! + +use crate::*; +use print:: +{ + InputExtract, + Context, +}; +use core:: +{ + fmt, +}; +use std::sync::OnceLock; + +/// A struct representing the list of keys output format. +#[derive( Debug )] +pub struct Keys +{ + // /// Prefix added to each row. + // pub table_prefix : String, + // /// Postfix added to each row. + // pub table_postfix : String, + // /// Separator used between rows. + // pub table_separator : String, + // /// Prefix added to each row. + // pub row_prefix : String, + // /// Postfix added to each row. + // pub row_postfix : String, + // /// Separator used between rows. + // pub row_separator : String, + // /// Prefix added to each cell. + // pub cell_prefix : String, + // /// Postfix added to each cell. + // pub cell_postfix : String, + // /// Separator used between table columns. + // pub cell_separator : String, +} + +impl Keys +{ + /// Returns a reference to a static instance of `Keys`. + pub fn instance() -> &'static dyn TableOutputFormat + { + static INSTANCE : OnceLock< Keys > = OnceLock::new(); + INSTANCE.get_or_init( || Keys::default() ) + } +} + +impl Default for Keys +{ + fn default() -> Self + { + + // let cell_prefix = "".to_string(); + // let cell_postfix = "".to_string(); + // let cell_separator = " β”‚ ".to_string(); + // let row_prefix = "β”‚ ".to_string(); + // let row_postfix = " β”‚".to_string(); + // let row_separator = "\n".to_string(); + // let table_prefix = "".to_string(); + // let table_postfix = "".to_string(); + // let table_separator = "\n".to_string(); + + Self + { + // table_prefix, + // table_postfix, + // table_separator, + // row_prefix, + // row_postfix, + // row_separator, + // cell_prefix, + // cell_postfix, + // cell_separator, + } + } +} + +impl TableOutputFormat for Keys +{ + + fn extract_write< 'buf, 'data >( + &self, + x : &InputExtract< 'data >, + c : &mut Context< 'buf >, + ) -> fmt::Result + { + + // dbg!( &x ); + + for col in &x.col_descriptors + { + write!( c.buf, " - {}\n", col.label )?; + } + + write!( c.buf, " {} fields\n", x.col_descriptors.len() )?; + + Ok(()) + } + +} diff --git a/module/core/format_tools/src/format/output_format/ordinary.rs b/module/core/format_tools/src/format/output_format/table.rs similarity index 93% rename from module/core/format_tools/src/format/output_format/ordinary.rs rename to module/core/format_tools/src/format/output_format/table.rs index 23606111f3..579ba6c783 100644 --- a/module/core/format_tools/src/format/output_format/ordinary.rs +++ b/module/core/format_tools/src/format/output_format/table.rs @@ -24,7 +24,7 @@ use std::sync::OnceLock; /// A struct representing the classic table output format. /// -/// `Ordinary` provides a standard implementation for table formatting, +/// `Table` provides a standard implementation for table formatting, /// supporting a classic style with default settings. /// /// # Example @@ -37,7 +37,7 @@ use std::sync::OnceLock; /// 10 | Boris | 5 /// ``` #[ derive( Debug ) ] -pub struct Ordinary +pub struct Table { /// Delimitting header with grid line or not. pub delimitting_header : bool, @@ -77,7 +77,7 @@ pub struct Ordinary pub corner_rb : char, } -impl Default for Ordinary +impl Default for Table { fn default() -> Self { @@ -127,30 +127,30 @@ impl Default for Ordinary } } -impl Default for &'static Ordinary +impl Default for &'static Table { fn default() -> Self { // qqq : find a better solution - static STYLES : OnceLock< Ordinary > = OnceLock::new(); + static STYLES : OnceLock< Table > = OnceLock::new(); STYLES.get_or_init( || { - Ordinary::default() + Table::default() }) } } -impl Ordinary +impl Table { - /// Returns a reference to a static instance of `Ordinary`. + /// Returns a reference to a static instance of `Table`. /// - /// This method provides access to a single shared instance of `Ordinary`, + /// This method provides access to a single shared instance of `Table`, /// ensuring efficient reuse of the classic table output format. pub fn instance() -> & 'static dyn TableOutputFormat { - static INSTANCE : OnceLock< Ordinary > = OnceLock::new(); + static INSTANCE : OnceLock< Table > = OnceLock::new(); INSTANCE.get_or_init( || { Self::default() @@ -159,7 +159,7 @@ impl Ordinary } } -impl TableOutputFormat for Ordinary +impl TableOutputFormat for Table { fn extract_write< 'buf, 'data >( &self, x : &InputExtract< 'data >, c : &mut Context< 'buf > ) -> fmt::Result { diff --git a/module/core/format_tools/src/format/print.rs b/module/core/format_tools/src/format/print.rs index 123dc47a31..42ce219c19 100644 --- a/module/core/format_tools/src/format/print.rs +++ b/module/core/format_tools/src/format/print.rs @@ -166,7 +166,7 @@ mod private /// A `String` containing the formatted table. fn table_to_string( &'data self ) -> String { - self.table_to_string_with_format( &output_format::Ordinary::default() ) + self.table_to_string_with_format( &output_format::Table::default() ) } /// Converts the table to a string representation specifying printer. @@ -197,15 +197,15 @@ mod private } /// A trait for formatting tables. - impl< 'data, T, RowKey, Row, CellKey, CellRepr > TableFormatter< 'data > - for AsTable< 'data, T, RowKey, Row, CellKey, CellRepr > + impl< 'data, T, RowKey, Row, CellKey> TableFormatter< 'data > + for AsTable< 'data, T, RowKey, Row, CellKey> where - Self : TableRows< CellKey = CellKey, CellRepr = CellRepr, RowKey = RowKey, Row = Row >, + Self : TableRows< CellKey = CellKey, RowKey = RowKey, Row = Row >, Self : TableHeader< CellKey = CellKey >, RowKey : table::RowKey, - Row : Cells< CellKey, CellRepr >, + Row : Cells< CellKey>, CellKey : table::CellKey + ?Sized, - CellRepr : table::CellRepr, + // CellRepr : table::CellRepr, { fn fmt< 'a >( &'data self, c : &mut Context< 'a > ) -> fmt::Result @@ -365,7 +365,7 @@ mod private } } /// Extract input data from and collect it in a format consumable by output formatter. - pub fn extract< 't, 'context, Table, RowKey, Row, CellKey, CellRepr > + pub fn extract< 't, 'context, Table, RowKey, Row, CellKey> ( table : &'t Table, filter_col : &'context ( dyn FilterCol + 'context ), @@ -376,12 +376,12 @@ mod private where 'data : 't, // 't : 'data, - Table : TableRows< RowKey = RowKey, Row = Row, CellKey = CellKey, CellRepr = CellRepr >, + Table : TableRows< RowKey = RowKey, Row = Row, CellKey = CellKey >, Table : TableHeader< CellKey = CellKey >, RowKey : table::RowKey, - Row : Cells< CellKey, CellRepr > + 'data, + Row : Cells< CellKey> + 'data, CellKey : table::CellKey + ?Sized + 'data, - CellRepr : table::CellRepr, + // CellRepr : table::CellRepr, { use md_math::MdOffset; @@ -508,7 +508,7 @@ mod private | ( key, val ) | { - let val = match val.0 + let val = match val { Some( val ) => { @@ -583,7 +583,10 @@ mod private slices[ x.slices_dim.md_offset( md_index ) ] = s; }) ; - x.col_descriptors[ icol ].label = cell.0.as_ref(); + if irow == 0 + { + x.col_descriptors[ icol ].label = cell.0.as_ref(); + } } } diff --git a/module/core/format_tools/src/format/table.rs b/module/core/format_tools/src/format/table.rs index 9ea6b1aecd..d3dc8bd71c 100644 --- a/module/core/format_tools/src/format/table.rs +++ b/module/core/format_tools/src/format/table.rs @@ -12,7 +12,7 @@ mod private // fmt, borrow::Borrow, }; - // use std::borrow::Cow; + use std::borrow::Cow; use reflect_tools:: { IteratorTrait, @@ -78,20 +78,21 @@ mod private // = /// A trait for iterating over all cells of a row. - pub trait Cells< CellKey, CellRepr > + pub trait Cells< CellKey > where - CellRepr : table::CellRepr, + // CellRepr : table::CellRepr, CellKey : table::CellKey + ?Sized, { /// Returns an iterator over all cells of the row. - fn cells< 'a, 'b >( &'a self ) -> impl IteratorTrait< Item = ( &'b CellKey, OptionalCow< 'b, str, CellRepr > ) > + // fn cells< 'a, 'b >( &'a self ) -> impl IteratorTrait< Item = ( &'b CellKey, OptionalCow< 'b, str > ) > + fn cells< 'a, 'b >( &'a self ) -> impl IteratorTrait< Item = ( &'b CellKey, Option< Cow< 'b, str > > ) > where 'a : 'b, CellKey : 'b, ; } - impl< Row, CellKey, CellRepr > Cells< CellKey, CellRepr > + impl< Row, CellKey > Cells< CellKey > for Row where CellKey : table::CellKey + ?Sized, @@ -99,14 +100,17 @@ mod private Row : TableWithFields + Fields < &'ckv CellKey, - OptionalCow< 'ckv, str, CellRepr >, + // OptionalCow< 'ckv, str >, + Option< Cow< 'ckv, str > >, Key< 'ckv > = &'ckv CellKey, - Val< 'ckv > = OptionalCow< 'ckv, str, CellRepr >, + // Val< 'ckv > = OptionalCow< 'ckv, str >, + Val< 'ckv > = Option< Cow< 'ckv, str > >, > + 'ckv, // xxx - CellRepr : table::CellRepr, + // CellRepr : table::CellRepr, { - fn cells< 'a, 'b >( &'a self ) -> impl IteratorTrait< Item = ( &'b CellKey, OptionalCow< 'b, str, CellRepr > ) > + // fn cells< 'a, 'b >( &'a self ) -> impl IteratorTrait< Item = ( &'b CellKey, OptionalCow< 'b, str > ) > + fn cells< 'a, 'b >( &'a self ) -> impl IteratorTrait< Item = ( &'b CellKey, Option< Cow< 'b, str > > ) > where 'a : 'b, CellKey : 'b, @@ -154,15 +158,15 @@ mod private /// /// The type representing a row, which must implement `Cells` /// for the specified `CellKey` and `CellRepr`. - type Row : Cells< Self::CellKey, Self::CellRepr >; + type Row : Cells< Self::CellKey >; /// /// The type used to identify cells within a row, requiring /// implementation of the `Key` trait. type CellKey : table::CellKey + ?Sized; /// - /// The type representing the content of a cell, requiring - /// implementation of the `CellRepr` trait. - type CellRepr : table::CellRepr; + // /// The type representing the content of a cell, requiring + // /// implementation of the `CellRepr` trait. + // type // CellRepr : table::CellRepr; /// Returns an iterator over all rows of the table. fn rows( &self ) -> impl IteratorTrait< Item = &Self::Row >; @@ -171,9 +175,8 @@ mod private // Self::Row : 'a; } - impl< T, RowKey, Row, CellKey, CellRepr > - TableRows<> - for AsTable< '_, T, RowKey, Row, CellKey, CellRepr > + impl< T, RowKey, Row, CellKey > TableRows<> + for AsTable< '_, T, RowKey, Row, CellKey > where for< 'k, 'v > T : Fields @@ -185,14 +188,14 @@ mod private > + 'k + 'v, RowKey : table::RowKey, - Row : TableWithFields + Cells< CellKey, CellRepr >, + Row : TableWithFields + Cells< CellKey >, CellKey : table::CellKey + ?Sized, - CellRepr : table::CellRepr, + // CellRepr : table::CellRepr, { type RowKey = RowKey; type Row = Row; type CellKey = CellKey; - type CellRepr = CellRepr; + // type CellRepr = CellRepr; fn rows( &self ) -> impl IteratorTrait< Item = &Self::Row > // fn rows< 'a >( &'a self ) -> impl IteratorTrait< Item = &'a Self::Row > @@ -217,14 +220,14 @@ mod private // fn mcells( &self ) -> [ usize ; 2 ]; // } // -// impl< T, RowKey, Row, CellKey, CellRepr > TableSize -// for AsTable< '_, T, RowKey, Row, CellKey, CellRepr > +// impl< T, RowKey, Row, CellKey > TableSize +// for AsTable< '_, T, RowKey, Row, CellKey > // where -// Self : TableRows< RowKey = RowKey, Row = Row, CellKey = CellKey, CellRepr = CellRepr >, +// Self : TableRows< RowKey = RowKey, Row = Row, CellKey = CellKey >, // RowKey : table::RowKey, -// Row : Cells< CellKey, CellRepr >, +// Row : Cells< CellKey >, // CellKey : table::CellKey + ?Sized, -// CellRepr : table::CellRepr, +// // CellRepr : table::CellRepr, // { // fn mcells( &self ) -> [ usize ; 2 ] // { @@ -256,14 +259,14 @@ mod private fn header( &self ) -> Option< impl IteratorTrait< Item = ( &Self::CellKey, &'_ str ) > >; } - impl< T, RowKey, Row, CellKey, CellRepr > TableHeader - for AsTable< '_, T, RowKey, Row, CellKey, CellRepr > + impl< T, RowKey, Row, CellKey > TableHeader + for AsTable< '_, T, RowKey, Row, CellKey > where - Self : TableRows< RowKey = RowKey, Row = Row, CellKey = CellKey, CellRepr = CellRepr >, + Self : TableRows< RowKey = RowKey, Row = Row, CellKey = CellKey >, RowKey : table::RowKey, - Row : TableWithFields + Cells< CellKey, CellRepr >, + Row : TableWithFields + Cells< CellKey >, CellKey : table::CellKey + ?Sized, - CellRepr : table::CellRepr, + // CellRepr : table::CellRepr, { type CellKey = CellKey; diff --git a/module/core/format_tools/src/format/test_object_without_impl.rs b/module/core/format_tools/src/format/test_object_without_impl.rs new file mode 100644 index 0000000000..f61b3fe588 --- /dev/null +++ b/module/core/format_tools/src/format/test_object_without_impl.rs @@ -0,0 +1,155 @@ +//! A strucutre for diagnostic and demonstration purpose. + +// use super::*; + +// use crate:: +// { +// Fields, +// IteratorTrait, +// TableWithFields, +// WithRef, +// OptionalCow, +// }; + +use std:: +{ + collections::HashMap, + hash::Hasher, + hash::Hash, + cmp::Ordering, + // borrow::Cow, +}; + +/// Struct representing a test object with various fields. +#[ derive( Clone, Debug, PartialEq, Eq ) ] +pub struct TestObjectWithoutImpl +{ + pub id : String, + pub created_at : i64, + pub file_ids : Vec< String >, + pub tools : Option< Vec< HashMap< String, String > > >, +} + +// TableWithFields is not implemented for TestObjectWithoutImpl intentionally + +// impl TableWithFields for TestObjectWithoutImpl {} +// +// impl Fields< &'_ str, Option< Cow< '_, str > > > +// for TestObjectWithoutImpl +// { +// type Key< 'k > = &'k str; +// type Val< 'v > = Option< Cow< 'v, str > >; +// +// fn fields( &self ) -> impl IteratorTrait< Item = ( &'_ str, Option< Cow< '_, str > > ) > +// { +// use format_tools::ref_or_display_or_debug_multiline::field; +// // use format_tools::ref_or_display_or_debug::field; +// let mut dst : Vec< ( &'_ str, Option< Cow< '_, str > > ) > = Vec::new(); +// +// dst.push( field!( &self.id ) ); +// dst.push( field!( &self.created_at ) ); +// dst.push( field!( &self.file_ids ) ); +// +// if let Some( tools ) = &self.tools +// { +// dst.push( field!( tools ) ); +// } +// else +// { +// dst.push( ( "tools", Option::None ) ); +// } +// +// dst.into_iter() +// } +// +// } + +impl Hash for TestObjectWithoutImpl +{ + + fn hash< H: Hasher >( &self, state: &mut H ) + { + self.id.hash( state ); + self.created_at.hash( state ); + self.file_ids.hash( state ); + + if let Some( tools ) = &self.tools + { + for tool in tools + { + for ( key, value ) in tool + { + key.hash( state ); + value.hash( state ); + } + } + } + else + { + state.write_u8( 0 ); + } + } + +} + +impl PartialOrd for TestObjectWithoutImpl +{ + + fn partial_cmp( &self, other: &Self ) -> Option< Ordering > + { + Some( self.cmp( other ) ) + } + +} + +impl Ord for TestObjectWithoutImpl +{ + + fn cmp( &self, other: &Self ) -> Ordering + { + self.id + .cmp( &other.id ) + .then_with( | | self.created_at.cmp( &other.created_at ) ) + .then_with( | | self.file_ids.cmp( &other.file_ids ) ) + } + +} + +/// Generate a dynamic array of test objects. +pub fn test_objects_gen() -> Vec< TestObjectWithoutImpl > +{ + + vec! + [ + TestObjectWithoutImpl + { + id : "1".to_string(), + created_at : 1627845583, + file_ids : vec![ "file1".to_string(), "file2".to_string() ], + tools : None + }, + TestObjectWithoutImpl + { + id : "2".to_string(), + created_at : 13, + file_ids : vec![ "file3".to_string(), "file4\nmore details".to_string() ], + tools : Some + ( + vec! + [ + { + let mut map = HashMap::new(); + map.insert( "tool1".to_string(), "value1".to_string() ); + map + }, + { + let mut map = HashMap::new(); + map.insert( "tool2".to_string(), "value2".to_string() ); + map + } + ] + ), + }, + ] + +} diff --git a/module/core/format_tools/tests/inc/collection_test.rs b/module/core/format_tools/tests/inc/collection_test.rs index 7e1607820e..6b17ce0975 100644 --- a/module/core/format_tools/tests/inc/collection_test.rs +++ b/module/core/format_tools/tests/inc/collection_test.rs @@ -6,7 +6,7 @@ use the_module:: AsTable, TableRows, WithRef, - print, + // the_module::print, }; use std:: @@ -56,14 +56,14 @@ fn dlist_basic() }; use the_module::TableFormatter; - let _as_table : AsTable< '_, Vec< TestObject >, &str, TestObject, str, WithRef > = AsTable::new( &data ); + let _as_table : AsTable< '_, Vec< TestObject >, &str, TestObject, str> = AsTable::new( &data ); let as_table = AsTable::new( &data ); let rows = TableRows::rows( &as_table ); assert_eq!( rows.len(), 2 ); let mut output = String::new(); - let mut context = print::Context::new( &mut output, Default::default() ); + let mut context = the_module::print::Context::new( &mut output, Default::default() ); let _got = the_module::TableFormatter::fmt( &as_table, &mut context ); let got = as_table.table_to_string(); assert!( got.contains( "β”‚ id β”‚ created_at β”‚ file_ids β”‚ tools β”‚" ) ); @@ -112,14 +112,14 @@ fn hmap_basic() }; use the_module::TableFormatter; - let _as_table : AsTable< '_, HashMap< &str, TestObject >, &str, TestObject, str, WithRef > = AsTable::new( &data ); + let _as_table : AsTable< '_, HashMap< &str, TestObject >, &str, TestObject, str> = AsTable::new( &data ); let as_table = AsTable::new( &data ); let rows = TableRows::rows( &as_table ); assert_eq!( rows.len(), 2 ); let mut output = String::new(); - let mut context = print::Context::new( &mut output, Default::default() ); + let mut context = the_module::print::Context::new( &mut output, Default::default() ); let _got = the_module::TableFormatter::fmt( &as_table, &mut context ); let got = as_table.table_to_string(); assert!( got.contains( "β”‚ id β”‚ created_at β”‚ file_ids β”‚ tools β”‚" ) ); @@ -168,14 +168,14 @@ fn bmap_basic() }; use the_module::TableFormatter; - let _as_table : AsTable< '_, Bmap< &str, TestObject >, &str, TestObject, str, WithRef > = AsTable::new( &data ); + let _as_table : AsTable< '_, Bmap< &str, TestObject >, &str, TestObject, str> = AsTable::new( &data ); let as_table = AsTable::new( &data ); let rows = TableRows::rows( &as_table ); assert_eq!( rows.len(), 2 ); let mut output = String::new(); - let mut context = print::Context::new( &mut output, Default::default() ); + let mut context = the_module::print::Context::new( &mut output, Default::default() ); let _got = the_module::TableFormatter::fmt( &as_table, &mut context ); let got = as_table.table_to_string(); assert!( got.contains( "β”‚ id β”‚ created_at β”‚ file_ids β”‚ tools β”‚" ) ); @@ -222,14 +222,14 @@ fn bset_basic() }; use the_module::TableFormatter; - let _as_table : AsTable< '_, BTreeSet< TestObject >, &str, TestObject, str, WithRef > = AsTable::new( &data ); + let _as_table : AsTable< '_, BTreeSet< TestObject >, &str, TestObject, str> = AsTable::new( &data ); let as_table = AsTable::new( &data ); let rows = TableRows::rows( &as_table ); assert_eq!( rows.len(), 2 ); let mut output = String::new(); - let mut context = print::Context::new( &mut output, Default::default() ); + let mut context = the_module::print::Context::new( &mut output, Default::default() ); let _got = the_module::TableFormatter::fmt( &as_table, &mut context ); let got = as_table.table_to_string(); assert!( got.contains( "β”‚ id β”‚ created_at β”‚ file_ids β”‚ tools β”‚" ) ); @@ -276,14 +276,14 @@ fn deque_basic() }; use the_module::TableFormatter; - let _as_table : AsTable< '_, VecDeque< TestObject >, &str, TestObject, str, WithRef > = AsTable::new( &data ); + let _as_table : AsTable< '_, VecDeque< TestObject >, &str, TestObject, str> = AsTable::new( &data ); let as_table = AsTable::new( &data ); let rows = TableRows::rows( &as_table ); assert_eq!( rows.len(), 2 ); let mut output = String::new(); - let mut context = print::Context::new( &mut output, Default::default() ); + let mut context = the_module::print::Context::new( &mut output, Default::default() ); let _got = the_module::TableFormatter::fmt( &as_table, &mut context ); let got = as_table.table_to_string(); assert!( got.contains( "β”‚ id β”‚ created_at β”‚ file_ids β”‚ tools β”‚" ) ); @@ -328,16 +328,16 @@ fn hset_basic() ), }, }; - + use the_module::TableFormatter; - let _as_table : AsTable< '_, HashSet< TestObject >, &str, TestObject, str, WithRef > = AsTable::new( &data ); + let _as_table : AsTable< '_, HashSet< TestObject >, &str, TestObject, str> = AsTable::new( &data ); let as_table = AsTable::new( &data ); let rows = TableRows::rows( &as_table ); assert_eq!( rows.len(), 2 ); let mut output = String::new(); - let mut context = print::Context::new( &mut output, Default::default() ); + let mut context = the_module::print::Context::new( &mut output, Default::default() ); let _got = the_module::TableFormatter::fmt( &as_table, &mut context ); let got = as_table.table_to_string(); assert!( got.contains( "β”‚ id β”‚ created_at β”‚ file_ids β”‚ tools β”‚" ) ); @@ -384,14 +384,14 @@ fn llist_basic() }; use the_module::TableFormatter; - let _as_table : AsTable< '_, LinkedList< TestObject >, &str, TestObject, str, WithRef > = AsTable::new( &data ); + let _as_table : AsTable< '_, LinkedList< TestObject >, &str, TestObject, str> = AsTable::new( &data ); let as_table = AsTable::new( &data ); let rows = TableRows::rows( &as_table ); assert_eq!( rows.len(), 2 ); let mut output = String::new(); - let mut context = print::Context::new( &mut output, Default::default() ); + let mut context = the_module::print::Context::new( &mut output, Default::default() ); let _got = the_module::TableFormatter::fmt( &as_table, &mut context ); let got = as_table.table_to_string(); assert!( got.contains( "β”‚ id β”‚ created_at β”‚ file_ids β”‚ tools β”‚" ) ); diff --git a/module/core/format_tools/tests/inc/fields_test.rs b/module/core/format_tools/tests/inc/fields_test.rs index 48ba295e20..32d921bed0 100644 --- a/module/core/format_tools/tests/inc/fields_test.rs +++ b/module/core/format_tools/tests/inc/fields_test.rs @@ -26,16 +26,16 @@ pub struct TestObject pub tools : Option< Vec< HashMap< String, String > > >, } -impl Fields< &'static str, OptionalCow< '_, str, WithRef > > +impl Fields< &'_ str, Option< Cow< '_, str > > > for TestObject { - type Key< 'k > = &'static str; - type Val< 'v > = OptionalCow< 'v, str, WithRef >; + type Key< 'k > = &'k str; + type Val< 'v > = Option< Cow< 'v, str > >; - fn fields( &self ) -> impl IteratorTrait< Item = ( &'static str, OptionalCow< '_, str, WithRef > ) > + fn fields( &self ) -> impl IteratorTrait< Item = ( &'_ str, Option< Cow< '_, str > > ) > { use format_tools::ref_or_display_or_debug::field; - let mut dst : Vec< ( &'static str, OptionalCow< '_, str, WithRef > ) > = Vec::new(); + let mut dst : Vec< ( &'_ str, Option< Cow< '_, str > > ) > = Vec::new(); dst.push( field!( &self.id ) ); dst.push( field!( &self.created_at ) ); @@ -47,11 +47,17 @@ for TestObject } else { - dst.push( ( "tools", OptionalCow::none() ) ); + dst.push( ( "tools", Option::None ) ); } dst.into_iter() } + +} + +pub fn is_borrowed( cow : &Option< Cow< '_, str > > ) -> bool +{ + matches!( cow, Some( Cow::Borrowed( _ ) ) ) } // @@ -76,16 +82,16 @@ fn basic_with_ref_display_debug() ), }; - let fields : Vec< ( &str, OptionalCow< '_, str, WithRef > ) > = - Fields::< &'static str, OptionalCow< '_, str, WithRef > >::fields( &test_object ).collect(); + let fields : Vec< ( &str, Option< Cow< '_, str > > ) > = + Fields::< &'static str, Option< Cow< '_, str > > >::fields( &test_object ).collect(); - // let fields : Vec< ( &str, OptionalCow< '_, str, WithRef > ) > = test_object.fields().collect(); + // let fields : Vec< ( &str, Option< Cow< '_, str > > ) > = test_object.fields().collect(); assert_eq!( fields.len(), 4 ); - assert!( fields[ 0 ].1.is_borrowed() ); - assert!( !fields[ 1 ].1.is_borrowed() ); - assert!( !fields[ 2 ].1.is_borrowed() ); - assert!( !fields[ 3 ].1.is_borrowed() ); + assert!( is_borrowed( &fields[ 0 ].1 ) ); + assert!( !is_borrowed( &fields[ 1 ].1 ) ); + assert!( !is_borrowed( &fields[ 2 ].1 ) ); + assert!( !is_borrowed( &fields[ 3 ].1 ) ); assert_eq!( fields[ 0 ], ( "id", Some( Cow::Borrowed( "12345" ) ).into() ) ); assert_eq!( fields[ 0 ], ( "id", Some( Cow::Owned( "12345".to_string() ) ).into() ) ); assert_eq!( fields[ 1 ], ( "created_at", Some( Cow::Owned( "1627845583".to_string() ) ).into() ) ); diff --git a/module/core/format_tools/tests/inc/format_records_test.rs b/module/core/format_tools/tests/inc/format_records_test.rs index 8325dea020..72f23a5ff5 100644 --- a/module/core/format_tools/tests/inc/format_records_test.rs +++ b/module/core/format_tools/tests/inc/format_records_test.rs @@ -23,7 +23,7 @@ fn basic() { let test_objects = test_object::test_objects_gen(); - let _as_table : AsTable< '_, Vec< test_object::TestObject >, usize, test_object::TestObject, str, WithRef > = AsTable::new( &test_objects ); + let _as_table : AsTable< '_, Vec< test_object::TestObject >, usize, test_object::TestObject, str> = AsTable::new( &test_objects ); let as_table = AsTable::new( &test_objects ); let mut output = String::new(); diff --git a/module/core/format_tools/tests/inc/format_ordinary_test.rs b/module/core/format_tools/tests/inc/format_table_test.rs similarity index 96% rename from module/core/format_tools/tests/inc/format_ordinary_test.rs rename to module/core/format_tools/tests/inc/format_table_test.rs index 5dbe2a95d2..eb8a3b17dd 100644 --- a/module/core/format_tools/tests/inc/format_ordinary_test.rs +++ b/module/core/format_tools/tests/inc/format_table_test.rs @@ -23,7 +23,7 @@ fn basic() { let test_objects = test_object::test_objects_gen(); - let _as_table : AsTable< '_, Vec< test_object::TestObject >, usize, test_object::TestObject, str, WithRef > = AsTable::new( &test_objects ); + let _as_table : AsTable< '_, Vec< test_object::TestObject >, usize, test_object::TestObject, str> = AsTable::new( &test_objects ); let as_table = AsTable::new( &test_objects ); let mut output = String::new(); @@ -70,7 +70,7 @@ fn table_to_string() // with explicit arguments - let as_table : AsTable< '_, Vec< test_object::TestObject >, usize, test_object::TestObject, str, WithRef > = AsTable::new( &test_objects ); + let as_table : AsTable< '_, Vec< test_object::TestObject >, usize, test_object::TestObject, str> = AsTable::new( &test_objects ); let table_string = as_table.table_to_string(); println!( "\ntable_string\n{table_string}" ); assert!( table_string.contains( "id" ) ); @@ -99,7 +99,7 @@ fn custom_format() // use the_module::TableFormatter; let test_objects = test_object::test_objects_gen(); - let mut format = output_format::Ordinary::default(); + let mut format = output_format::Table::default(); format.cell_prefix = "( ".into(); format.cell_postfix = " )".into(); format.cell_separator = "|".into(); @@ -140,7 +140,7 @@ fn custom_format() use the_module::TableFormatter; - let mut format = output_format::Ordinary::default(); + let mut format = output_format::Table::default(); format.cell_prefix = "( ".into(); format.cell_postfix = " )".into(); format.cell_separator = "|".into(); @@ -175,7 +175,7 @@ fn filter_col_none() { let test_objects = test_object::test_objects_gen(); - let mut format = output_format::Ordinary::default(); + let mut format = output_format::Table::default(); format.cell_prefix = "( ".into(); format.cell_postfix = " )".into(); format.cell_separator = "|".into(); @@ -210,7 +210,7 @@ fn filter_col_callback() { let test_objects = test_object::test_objects_gen(); - let mut format = output_format::Ordinary::default(); + let mut format = output_format::Table::default(); format.cell_prefix = "( ".into(); format.cell_postfix = " )".into(); format.cell_separator = "|".into(); @@ -254,7 +254,7 @@ fn filter_row_none() { let test_objects = test_object::test_objects_gen(); - let mut format = output_format::Ordinary::default(); + let mut format = output_format::Table::default(); format.cell_prefix = "( ".into(); format.cell_postfix = " )".into(); format.cell_separator = "|".into(); @@ -286,7 +286,7 @@ fn filter_row_callback() { let test_objects = test_object::test_objects_gen(); - let mut format = output_format::Ordinary::default(); + let mut format = output_format::Table::default(); format.cell_prefix = "( ".into(); format.cell_postfix = " )".into(); format.cell_separator = "|".into(); diff --git a/module/core/format_tools/tests/inc/mod.rs b/module/core/format_tools/tests/inc/mod.rs index 5188190547..5f35b24fcc 100644 --- a/module/core/format_tools/tests/inc/mod.rs +++ b/module/core/format_tools/tests/inc/mod.rs @@ -1,18 +1,19 @@ -#[ allow( unused_imports ) ] use super::*; #[ cfg( feature = "enabled" ) ] #[ path = "." ] mod fundamental { - #[ allow( unused_imports ) ] use super::*; mod test_object; mod table_test; - mod format_ordinary_test; + mod tabe_foreign_test; + + mod format_table_test; mod format_records_test; + // mod format_keys_test; // qqq : xxx : implement mod collection_test; mod fields_test; diff --git a/module/core/format_tools/tests/inc/tabe_foreign_test.rs b/module/core/format_tools/tests/inc/tabe_foreign_test.rs new file mode 100644 index 0000000000..6cbfd68249 --- /dev/null +++ b/module/core/format_tools/tests/inc/tabe_foreign_test.rs @@ -0,0 +1,131 @@ +use super::*; + +use the_module:: +{ + AsTable, + Cells, + TableRows, + TableHeader, + WithRef, +}; + +use std:: +{ + borrow::Cow, +}; + +// + +#[ test ] +fn iterator_over_objects_without_impl() +{ + use the_module::TestObjectWithoutImpl as TestObjectWithoutImpl; + use the_module:: + { + Fields, + IteratorTrait, + TableWithFields, + WithRef, + OptionalCow, + output_format, + }; + + // xxx : Clone should not be required + #[ derive( Debug, Clone ) ] + pub struct TestObjecWrap( TestObjectWithoutImpl ); + + impl TableWithFields for TestObjecWrap {} + impl Fields< &'_ str, Option< Cow< '_, str > > > + for TestObjecWrap + { + type Key< 'k > = &'k str; + type Val< 'v > = Option< Cow< 'v, str > >; + + fn fields( &self ) -> impl IteratorTrait< Item = ( &'_ str, Option< Cow< '_, str > > ) > + { + use format_tools::ref_or_display_or_debug_multiline::field; + let mut dst = Vec::new(); + + dst.push( field!( &self.0.id ) ); + dst.push( field!( &self.0.created_at ) ); + dst.push( field!( &self.0.file_ids ) ); + + if let Some( tools ) = &self.0.tools + { + dst.push( field!( tools ) ); + } + else + { + dst.push( ( "tools", Option::None ) ); + } + + dst.into_iter() + } + + } + + let data : collection_tools::Vec< TestObjecWrap > = the_module::test_objects_gen() + .into_iter() + .map( | e | TestObjecWrap( e ) ) + .collect() + ; + + use the_module::TableFormatter; + let _as_table : AsTable< '_, Vec< TestObjecWrap >, &str, TestObjecWrap, str > = AsTable::new( &data ); + let as_table = AsTable::new( &data ); + + let rows = TableRows::rows( &as_table ); + assert_eq!( rows.len(), 2 ); + + let mut output = String::new(); + let mut context = the_module::print::Context::new( &mut output, Default::default() ); + let _result = the_module::TableFormatter::fmt( &as_table, &mut context ); + + // = output as table + + let got = as_table.table_to_string(); + assert!( got.contains( "β”‚ id β”‚ created_at β”‚ file_ids β”‚ tools β”‚" ) ); + assert!( got.contains( "β”‚ 13 β”‚ [ β”‚ [ β”‚" ) ); + assert!( got.contains( "β”‚ 1627845583 β”‚ [ β”‚ β”‚" ) ); + + let got = AsTable::new( &data ).table_to_string(); + assert!( got.contains( "β”‚ id β”‚ created_at β”‚ file_ids β”‚ tools β”‚" ) ); + assert!( got.contains( "β”‚ 13 β”‚ [ β”‚ [ β”‚" ) ); + assert!( got.contains( "β”‚ 1627845583 β”‚ [ β”‚ β”‚" ) ); + + let got = AsTable::new( &data ).table_to_string_with_format( &output_format::Table::default() ); + println!( "{}", &got ); + assert!( got.contains( "β”‚ id β”‚ created_at β”‚ file_ids β”‚ tools β”‚" ) ); + assert!( got.contains( "β”‚ 13 β”‚ [ β”‚ [ β”‚" ) ); + assert!( got.contains( "β”‚ 1627845583 β”‚ [ β”‚ β”‚" ) ); + + // = output as records + + // let format = output_format::Records::default(); + let mut output = String::new(); + let format = the_module::output_format::Records::default(); + let printer = the_module::print::Printer::with_format( &format ); + let mut context = the_module::print::Context::new( &mut output, printer ); + let got = the_module::TableFormatter::fmt( &as_table, &mut context ); + assert!( got.is_ok() ); + + let got = AsTable::new( &data ).table_to_string_with_format( &output_format::Records::default() ); + println!( "{}", &got ); + assert!( got.contains( "β”‚ id β”‚ 1 β”‚" ) ); + assert!( got.contains( "β”‚ created_at β”‚ 1627845583 β”‚" ) ); + assert!( got.contains( "β”‚ id β”‚ 2 β”‚" ) ); + assert!( got.contains( "β”‚ created_at β”‚ 13 β”‚" ) ); + + // = output as keys + + let got = AsTable::new( &data ).table_to_string_with_format( &output_format::Keys::default() ); + println!( "{}", &got ); + assert!( got.contains( "- id" ) ); + assert!( got.contains( "- created_at" ) ); + assert!( got.contains( "- file_ids" ) ); + assert!( got.contains( "- tools" ) ); + assert!( got.contains( "4 fields" ) ); + + // assert!( false ); + +} diff --git a/module/core/format_tools/tests/inc/table_test.rs b/module/core/format_tools/tests/inc/table_test.rs index 2357d44aea..c5fd38a8e9 100644 --- a/module/core/format_tools/tests/inc/table_test.rs +++ b/module/core/format_tools/tests/inc/table_test.rs @@ -10,6 +10,11 @@ use the_module:: WithRef, }; +use std:: +{ + borrow::Cow, +}; + // #[ test ] @@ -19,13 +24,13 @@ fn basic() { let test_objects = test_object::test_objects_gen(); - let cells = Cells::< str, WithRef >::cells( &test_objects[ 0 ] ); + let cells = Cells::< str>::cells( &test_objects[ 0 ] ); assert_eq!( cells.len(), 4 ); - let cells = Cells::< str, WithRef >::cells( &test_objects[ 1 ] ); + let cells = Cells::< str>::cells( &test_objects[ 1 ] ); assert_eq!( cells.len(), 4 ); drop( cells ); - let as_table : AsTable< '_, Vec< test_object::TestObject >, usize, test_object::TestObject, str, WithRef > = AsTable::new( &test_objects ); + let as_table : AsTable< '_, Vec< test_object::TestObject >, usize, test_object::TestObject, str> = AsTable::new( &test_objects ); // let mcells = TableSize::mcells( &as_table ); // assert_eq!( mcells, [ 4, 3 ] ); let rows = TableRows::rows( &as_table ); @@ -45,3 +50,251 @@ fn basic() dbg!( header.collect::< Vec< _ > >() ); } + +// + +#[ test ] +fn iterator_over_optional_cow() +{ + // use test_object::TestObject2 as TestObject2; + use the_module:: + { + Fields, + IteratorTrait, + TableWithFields, + WithRef, + OptionalCow, + }; + + /// Struct representing a test object with various fields. + #[ derive( Clone, Debug, PartialEq, Eq ) ] + pub struct TestObject2 + { + pub id : String, + pub created_at : i64, + pub file_ids : Vec< String >, + pub tools : Option< Vec< HashMap< String, String > > >, + } + + impl TableWithFields for TestObject2 {} + + impl Fields< &'_ str, Option< Cow< '_, str > > > + for TestObject2 + { + type Key< 'k > = &'k str; + type Val< 'v > = Option< Cow< 'v, str > >; + + fn fields( &self ) -> impl IteratorTrait< Item = ( &'_ str, Option< Cow< '_, str > > ) > + { + use format_tools::ref_or_display_or_debug_multiline::field; + // use format_tools::ref_or_display_or_debug::field; + let mut dst : Vec< ( &'_ str, Option< Cow< '_, str > > ) > = Vec::new(); + + // trace_macros!( true ); + dst.push( field!( &self.id ) ); + // trace_macros!( false ); + + dst.push( field!( &self.created_at ) ); + dst.push( field!( &self.file_ids ) ); + + if let Some( tools ) = &self.tools + { + dst.push( field!( tools ) ); + } + else + { + dst.push( ( "tools", Option::None ) ); + } + + dst.into_iter() + } + + } + + let data : collection_tools::Vec< TestObject2 > = dlist! + { + TestObject2 + { + id : "1".to_string(), + created_at : 1627845583, + file_ids : vec![ "file1".to_string(), "file2".to_string() ], + tools : None + }, + TestObject2 + { + id : "2".to_string(), + created_at : 13, + file_ids : vec![ "file3".to_string(), "file4\nmore details".to_string() ], + tools : Some + ( + vec! + [ + { + let mut map = HashMap::new(); + map.insert( "tool1".to_string(), "value1".to_string() ); + map + }, + { + let mut map = HashMap::new(); + map.insert( "tool2".to_string(), "value2".to_string() ); + map + } + ] + ), + }, + }; + + use the_module::TableFormatter; + let _as_table : AsTable< '_, Vec< TestObject2 >, &str, TestObject2, str> = AsTable::new( &data ); + let as_table = AsTable::new( &data ); + + let rows = TableRows::rows( &as_table ); + assert_eq!( rows.len(), 2 ); + + let mut output = String::new(); + let mut context = the_module::print::Context::new( &mut output, Default::default() ); + let _got = the_module::TableFormatter::fmt( &as_table, &mut context ); + let got = as_table.table_to_string(); + assert!( got.contains( "β”‚ id β”‚ created_at β”‚ file_ids β”‚ tools β”‚" ) ); + assert!( got.contains( "β”‚ 13 β”‚ [ β”‚ [ β”‚" ) ); + assert!( got.contains( "β”‚ 1627845583 β”‚ [ β”‚ β”‚" ) ); + + let got = AsTable::new( &data ).table_to_string(); + assert!( got.contains( "β”‚ id β”‚ created_at β”‚ file_ids β”‚ tools β”‚" ) ); + assert!( got.contains( "β”‚ 13 β”‚ [ β”‚ [ β”‚" ) ); + assert!( got.contains( "β”‚ 1627845583 β”‚ [ β”‚ β”‚" ) ); + +} + +// + +#[ test ] +fn iterator_over_strings() +{ + + fn to_owned< 'a, T1 >( src : ( T1, Option< Cow< 'a, str > > ) ) -> ( T1, String ) + { + let val = match src.1 + { + Some( c ) => c.into_owned(), + None => String::default(), + }; + ( src.0, val ) + } + + // fn into< 'a, T1, T2 : Copy >( src : ( T1, OptionalCow< 'a, str, T2 > ) ) -> ( T1, Option< Cow< 'a, str > > ) + // { + // ( src.0, src.1.into() ) + // } + + // use test_object::TestObject as TestObject3; + use the_module:: + { + Fields, + IteratorTrait, + TableWithFields, + WithRef, + OptionalCow, + }; + + use std::borrow::Cow; + + /// Struct representing a test object with various fields. + #[ derive( Clone, Debug, PartialEq, Eq ) ] + pub struct TestObject3 + { + pub id : String, + pub created_at : i64, + pub file_ids : Vec< String >, + pub tools : Option< Vec< HashMap< String, String > > >, + } + + impl TableWithFields for TestObject3 {} + + impl Fields< &'_ str, String > + for TestObject3 + { + type Key< 'k > = &'k str; + type Val< 'v > = String; + + fn fields( &self ) -> impl IteratorTrait< Item = ( &'_ str, String ) > + { + use format_tools::ref_or_display_or_debug_multiline::field; + // use format_tools::ref_or_display_or_debug::field; + let mut dst : Vec< ( &'_ str, String ) > = Vec::new(); + + dst.push( to_owned( field!( &self.id ) ) ); + + dst.push( to_owned( field!( &self.created_at ) ) ); + dst.push( to_owned( field!( &self.file_ids ) ) ); + + if let Some( tools ) = &self.tools + { + dst.push( to_owned( field!( tools ) ) ); + } + else + { + dst.push( ( "tools", String::default() ) ); + } + + dst.into_iter() + } + + } + + let _data : collection_tools::Vec< TestObject3 > = dlist! + { + TestObject3 + { + id : "1".to_string(), + created_at : 1627845583, + file_ids : vec![ "file1".to_string(), "file2".to_string() ], + tools : None + }, + TestObject3 + { + id : "2".to_string(), + created_at : 13, + file_ids : vec![ "file3".to_string(), "file4\nmore details".to_string() ], + tools : Some + ( + vec! + [ + { + let mut map = HashMap::new(); + map.insert( "tool1".to_string(), "value1".to_string() ); + map + }, + { + let mut map = HashMap::new(); + map.insert( "tool2".to_string(), "value2".to_string() ); + map + } + ] + ), + }, + }; + + // no variability in what Fields iterate over by design! + + // use the_module::TableFormatter; + // let _as_table : AsTable< '_, Vec< TestObject3 >, &str, TestObject3, str> = AsTable::new( &data ); + // let as_table = AsTable::new( &data ); + +// let rows = TableRows::rows( &as_table ); +// assert_eq!( rows.len(), 2 ); +// +// let mut output = String::new(); +// let mut context = the_module::print::Context::new( &mut output, Default::default() ); +// let _got = the_module::TableFormatter::fmt( &as_table, &mut context ); +// let got = as_table.table_to_string(); +// assert!( got.contains( "β”‚ id β”‚ created_at β”‚ file_ids β”‚ tools β”‚" ) ); +// assert!( got.contains( "β”‚ 13 β”‚ [ β”‚ [ β”‚" ) ); +// assert!( got.contains( "β”‚ 1627845583 β”‚ [ β”‚ β”‚" ) ); + +// let got = AsTable::new( &data ).table_to_string(); +// assert!( got.contains( "β”‚ id β”‚ created_at β”‚ file_ids β”‚ tools β”‚" ) ); +// assert!( got.contains( "β”‚ 13 β”‚ [ β”‚ [ β”‚" ) ); +// assert!( got.contains( "β”‚ 1627845583 β”‚ [ β”‚ β”‚" ) ); + +} diff --git a/module/core/format_tools/tests/inc/test_object.rs b/module/core/format_tools/tests/inc/test_object.rs index 6bb7555aa8..f710266a4d 100644 --- a/module/core/format_tools/tests/inc/test_object.rs +++ b/module/core/format_tools/tests/inc/test_object.rs @@ -15,12 +15,12 @@ use std:: collections::HashMap, hash::Hasher, hash::Hash, - cmp::Ordering - // borrow::Cow, + cmp::Ordering, + borrow::Cow, }; /// Struct representing a test object with various fields. -#[ derive( Clone, Debug ) ] +#[ derive( Clone, Debug, PartialEq, Eq ) ] pub struct TestObject { pub id : String, @@ -31,19 +31,51 @@ pub struct TestObject impl TableWithFields for TestObject {} -impl Fields< &'_ str, OptionalCow< '_, str, WithRef > > +// impl Fields< &'_ str, Option< Cow< '_, str > > > +// for TestObject +// { +// type Key< 'k > = &'k str; +// type Val< 'v > = OptionalCow< 'v, str>; +// +// fn fields( &self ) -> impl IteratorTrait< Item = ( &'_ str, Option< Cow< '_, str > > ) > +// { +// use format_tools::ref_or_display_or_debug_multiline::field; +// // use format_tools::ref_or_display_or_debug::field; +// let mut dst : Vec< ( &'_ str, Option< Cow< '_, str > > ) > = Vec::new(); +// +// dst.push( field!( &self.id ) ); +// dst.push( field!( &self.created_at ) ); +// dst.push( field!( &self.file_ids ) ); +// +// if let Some( tools ) = &self.tools +// { +// dst.push( field!( tools ) ); +// } +// else +// { +// dst.push( ( "tools", OptionalCow::none() ) ); +// } +// +// dst.into_iter() +// } +// +// } + +impl Fields< &'_ str, Option< Cow< '_, str > > > for TestObject { type Key< 'k > = &'k str; - type Val< 'v > = OptionalCow< 'v, str, WithRef >; + type Val< 'v > = Option< Cow< 'v, str > >; - fn fields( &self ) -> impl IteratorTrait< Item = ( &'_ str, OptionalCow< '_, str, WithRef > ) > + fn fields( &self ) -> impl IteratorTrait< Item = ( &'_ str, Option< Cow< '_, str > > ) > { use format_tools::ref_or_display_or_debug_multiline::field; // use format_tools::ref_or_display_or_debug::field; - let mut dst : Vec< ( &'_ str, OptionalCow< '_, str, WithRef > ) > = Vec::new(); + let mut dst : Vec< ( &'_ str, Option< Cow< '_, str > > ) > = Vec::new(); + // trace_macros!( true ); dst.push( field!( &self.id ) ); + // trace_macros!( false ); dst.push( field!( &self.created_at ) ); dst.push( field!( &self.file_ids ) ); @@ -53,7 +85,7 @@ for TestObject } else { - dst.push( ( "tools", OptionalCow::none() ) ); + dst.push( ( "tools", Option::None ) ); } dst.into_iter() @@ -61,27 +93,27 @@ for TestObject } -impl Hash for TestObject +impl Hash for TestObject { - fn hash< H: Hasher >( &self, state: &mut H ) + fn hash< H: Hasher >( &self, state: &mut H ) { self.id.hash( state ); self.created_at.hash( state ); self.file_ids.hash( state ); - if let Some( tools ) = &self.tools + if let Some( tools ) = &self.tools { - for tool in tools + for tool in tools { - for ( key, value ) in tool + for ( key, value ) in tool { key.hash( state ); value.hash( state ); } } - } - else + } + else { state.write_u8( 0 ); } @@ -89,44 +121,44 @@ impl Hash for TestObject } -impl PartialEq for TestObject -{ - - fn eq( &self, other: &Self ) -> bool - { - self.id == other.id && - self.created_at == other.created_at && - self.file_ids == other.file_ids && - self.tools == other.tools - } - -} +// impl PartialEq for TestObject +// { +// +// fn eq( &self, other: &Self ) -> bool +// { +// self.id == other.id && +// self.created_at == other.created_at && +// self.file_ids == other.file_ids && +// self.tools == other.tools +// } +// +// } +// +// impl Eq for TestObject +// { +// } -impl Eq for TestObject +impl PartialOrd for TestObject { -} -impl PartialOrd for TestObject -{ - - fn partial_cmp( &self, other: &Self ) -> Option< Ordering > + fn partial_cmp( &self, other: &Self ) -> Option< Ordering > { Some( self.cmp( other ) ) } } -impl Ord for TestObject +impl Ord for TestObject { - fn cmp( &self, other: &Self ) -> Ordering + fn cmp( &self, other: &Self ) -> Ordering { self.id .cmp( &other.id ) .then_with( | | self.created_at.cmp( &other.created_at ) ) .then_with( | | self.file_ids.cmp( &other.file_ids ) ) } - + } // diff --git a/module/core/format_tools/tests/smoke_test.rs b/module/core/format_tools/tests/smoke_test.rs index 828e9b016b..cd7b1f36a8 100644 --- a/module/core/format_tools/tests/smoke_test.rs +++ b/module/core/format_tools/tests/smoke_test.rs @@ -1,12 +1,13 @@ +//! Smoke tests. - +/// Smoke test of local version of the crate. #[ test ] fn local_smoke_test() { ::test_tools::smoke_test_for_local_run(); } - +/// Smoke test of published version of the crate. #[ test ] fn published_smoke_test() { diff --git a/module/core/format_tools/tests/tests.rs b/module/core/format_tools/tests/tests.rs index eae1668ea0..4fca6dbc07 100644 --- a/module/core/format_tools/tests/tests.rs +++ b/module/core/format_tools/tests/tests.rs @@ -1,10 +1,10 @@ -// #![ feature( trace_macros ) ] +//! Primary tests. + +#![ feature( trace_macros ) ] +#![ allow( unused_imports ) ] -#[ allow( unused_imports ) ] use format_tools as the_module; -#[ allow( unused_imports ) ] use test_tools::exposed::*; #[ cfg( feature = "enabled" ) ] mod inc; - diff --git a/module/core/former/Cargo.toml b/module/core/former/Cargo.toml index 6ccdadb0b4..df2a419b2b 100644 --- a/module/core/former/Cargo.toml +++ b/module/core/former/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "former" -version = "2.9.0" +version = "2.11.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -65,5 +65,5 @@ former_types = { workspace = true } [dev-dependencies] -test_tools = { workspace = true, features = [ "full" ] } +test_tools = { workspace = true } collection_tools = { workspace = true, features = [ "collection_constructors" ] } diff --git a/module/core/former/License b/module/core/former/License index e3e9e057cf..c32986cee3 100644 --- a/module/core/former/License +++ b/module/core/former/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/former_meta/Cargo.toml b/module/core/former_meta/Cargo.toml index 1612da9af5..38845bc3f1 100644 --- a/module/core/former_meta/Cargo.toml +++ b/module/core/former_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "former_meta" -version = "2.9.0" +version = "2.11.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -57,4 +57,4 @@ iter_tools = { workspace = true } convert_case = { version = "0.6.0", default-features = false, optional = true, features = [] } [dev-dependencies] -test_tools = { workspace = true, features = [ "full" ] } +test_tools = { workspace = true } diff --git a/module/core/former_meta/License b/module/core/former_meta/License index e3e9e057cf..c32986cee3 100644 --- a/module/core/former_meta/License +++ b/module/core/former_meta/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/former_types/Cargo.toml b/module/core/former_types/Cargo.toml index 6baa5017e7..1049a6c8bd 100644 --- a/module/core/former_types/Cargo.toml +++ b/module/core/former_types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "former_types" -version = "2.8.0" +version = "2.12.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -50,4 +50,4 @@ collection_tools = { workspace = true, features = [ "collection_constructors" ] [dev-dependencies] -test_tools = { workspace = true, features = [ "full" ] } +test_tools = { workspace = true } diff --git a/module/core/former_types/License b/module/core/former_types/License index e3e9e057cf..c32986cee3 100644 --- a/module/core/former_types/License +++ b/module/core/former_types/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/fs_tools/License b/module/core/fs_tools/License index e3e9e057cf..c32986cee3 100644 --- a/module/core/fs_tools/License +++ b/module/core/fs_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/implements/Cargo.toml b/module/core/implements/Cargo.toml index 44a51ad680..8c468c0b60 100644 --- a/module/core/implements/Cargo.toml +++ b/module/core/implements/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "implements" -version = "0.8.0" +version = "0.10.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/implements/License b/module/core/implements/License index e3e9e057cf..c32986cee3 100644 --- a/module/core/implements/License +++ b/module/core/implements/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/impls_index/Cargo.toml b/module/core/impls_index/Cargo.toml index ea67dfa107..1845411740 100644 --- a/module/core/impls_index/Cargo.toml +++ b/module/core/impls_index/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "impls_index" -version = "0.7.0" +version = "0.9.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/impls_index/License b/module/core/impls_index/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/impls_index/License +++ b/module/core/impls_index/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/impls_index_meta/Cargo.toml b/module/core/impls_index_meta/Cargo.toml index ce629d78b3..036c5a03d0 100644 --- a/module/core/impls_index_meta/Cargo.toml +++ b/module/core/impls_index_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "impls_index_meta" -version = "0.7.0" +version = "0.9.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/impls_index_meta/License b/module/core/impls_index_meta/License index e3e9e057cf..c32986cee3 100644 --- a/module/core/impls_index_meta/License +++ b/module/core/impls_index_meta/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/include_md/License b/module/core/include_md/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/include_md/License +++ b/module/core/include_md/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/inspect_type/Cargo.toml b/module/core/inspect_type/Cargo.toml index cebba6d857..260320b11b 100644 --- a/module/core/inspect_type/Cargo.toml +++ b/module/core/inspect_type/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "inspect_type" -version = "0.10.0" +version = "0.12.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/inspect_type/License b/module/core/inspect_type/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/inspect_type/License +++ b/module/core/inspect_type/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/inspect_type/src/lib.rs b/module/core/inspect_type/src/lib.rs index 27e60ce850..8f65d3fb63 100644 --- a/module/core/inspect_type/src/lib.rs +++ b/module/core/inspect_type/src/lib.rs @@ -2,7 +2,9 @@ #![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] #![ doc( html_root_url = "https://docs.rs/inspect_type/latest/inspect_type/" ) ] #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] +#![ allow( unexpected_cfgs ) ] +// #[ allow( unexpected_cfgs ) ] // #[ cfg( RUSTC_IS_NIGHTLY ) ] #[ cfg( not( RUSTC_IS_STABLE ) ) ] mod nightly diff --git a/module/core/inspect_type/tests/inc/inspect_type_test.rs b/module/core/inspect_type/tests/inc/inspect_type_test.rs index 58eb0b82b1..01445f74c4 100644 --- a/module/core/inspect_type/tests/inc/inspect_type_test.rs +++ b/module/core/inspect_type/tests/inc/inspect_type_test.rs @@ -1,3 +1,4 @@ + #[ allow( unused_imports ) ] use super::*; diff --git a/module/core/inspect_type/tests/tests.rs b/module/core/inspect_type/tests/tests.rs index 1b4624edf8..8e5818a1f9 100644 --- a/module/core/inspect_type/tests/tests.rs +++ b/module/core/inspect_type/tests/tests.rs @@ -1,3 +1,5 @@ +// #![ allow( unexpected_cfgs ) ] + // #![ no_std ] // #![ cfg_attr( feature = "no_std", no_std ) ] diff --git a/module/core/interval_adapter/Cargo.toml b/module/core/interval_adapter/Cargo.toml index cf0fd7fe6c..787fac61c8 100644 --- a/module/core/interval_adapter/Cargo.toml +++ b/module/core/interval_adapter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "interval_adapter" -version = "0.24.0" +version = "0.27.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/interval_adapter/License b/module/core/interval_adapter/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/interval_adapter/License +++ b/module/core/interval_adapter/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/is_slice/Cargo.toml b/module/core/is_slice/Cargo.toml index b0945c3613..2854cf37cd 100644 --- a/module/core/is_slice/Cargo.toml +++ b/module/core/is_slice/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "is_slice" -version = "0.9.0" +version = "0.11.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/is_slice/License b/module/core/is_slice/License index e3e9e057cf..c32986cee3 100644 --- a/module/core/is_slice/License +++ b/module/core/is_slice/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/iter_tools/Cargo.toml b/module/core/iter_tools/Cargo.toml index 68cafe52bf..7e4dcad983 100644 --- a/module/core/iter_tools/Cargo.toml +++ b/module/core/iter_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iter_tools" -version = "0.21.0" +version = "0.24.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/iter_tools/License b/module/core/iter_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/iter_tools/License +++ b/module/core/iter_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/iter_tools/src/iter.rs b/module/core/iter_tools/src/iter.rs index 86fbda3f33..727e18409f 100644 --- a/module/core/iter_tools/src/iter.rs +++ b/module/core/iter_tools/src/iter.rs @@ -5,6 +5,8 @@ mod private #[ allow( unused_imports ) ] use crate::*; // use ::itertools::process_results; + + #[ cfg( feature = "iter_trait" ) ] use clone_dyn_types::CloneDyn; /// Trait that encapsulates an iterator with specific characteristics and implemetning `CloneDyn`. diff --git a/module/core/macro_tools/Cargo.toml b/module/core/macro_tools/Cargo.toml index 1213064721..99877d2e6f 100644 --- a/module/core/macro_tools/Cargo.toml +++ b/module/core/macro_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "macro_tools" -version = "0.40.0" +version = "0.44.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -108,5 +108,5 @@ iter_tools = { workspace = true, features = [ "iter_trait" ] } clone_dyn_types = { workspace = true, features = [] } former_types = { workspace = true, features = [ "types_component_assign" ] } -[dev-dependencies] -test_tools = { workspace = true } +# [dev-dependencies] +# test_tools = { workspace = true } diff --git a/module/core/macro_tools/License b/module/core/macro_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/macro_tools/License +++ b/module/core/macro_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/mem_tools/Cargo.toml b/module/core/mem_tools/Cargo.toml index fd90f9d727..cec41724d4 100644 --- a/module/core/mem_tools/Cargo.toml +++ b/module/core/mem_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mem_tools" -version = "0.6.0" +version = "0.8.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/mem_tools/License b/module/core/mem_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/mem_tools/License +++ b/module/core/mem_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/meta_tools/Cargo.toml b/module/core/meta_tools/Cargo.toml index 282db2f43f..0fc0b3c61d 100644 --- a/module/core/meta_tools/Cargo.toml +++ b/module/core/meta_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "meta_tools" -version = "0.10.0" +version = "0.12.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/meta_tools/License b/module/core/meta_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/meta_tools/License +++ b/module/core/meta_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/meta_tools/src/lib.rs b/module/core/meta_tools/src/lib.rs index cd49c9841e..352f7e0f3b 100644 --- a/module/core/meta_tools/src/lib.rs +++ b/module/core/meta_tools/src/lib.rs @@ -29,12 +29,15 @@ pub mod dependency } +mod private {} + // // qqq : meta interface should be optional dependancy. please fix writing equivalent code manually #[ cfg( feature = "enabled" ) ] mod_interface::mod_interface! { + // #![ debug ] layer meta; diff --git a/module/core/mod_interface/Cargo.toml b/module/core/mod_interface/Cargo.toml index 438141b1e3..8f3e3f76f4 100644 --- a/module/core/mod_interface/Cargo.toml +++ b/module/core/mod_interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mod_interface" -version = "0.24.0" +version = "0.30.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -28,8 +28,6 @@ all-features = false [features] default = [ "enabled" ] full = [ "enabled" ] -no_std = [] -use_alloc = [ "no_std" ] enabled = [ "mod_interface_meta/enabled" ] # keep these examples in directories diff --git a/module/core/mod_interface/License b/module/core/mod_interface/License index e3e9e057cf..c32986cee3 100644 --- a/module/core/mod_interface/License +++ b/module/core/mod_interface/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/mod_interface/Readme.md b/module/core/mod_interface/Readme.md index 72573cc881..47115efb68 100644 --- a/module/core/mod_interface/Readme.md +++ b/module/core/mod_interface/Readme.md @@ -5,109 +5,164 @@ [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_push.yml) [![docs.rs](https://img.shields.io/docsrs/mod_interface?color=e3e8f0&logo=docs.rs)](https://docs.rs/mod_interface) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -Protocol of modularity unifying interface of a module and introducing layers. +Protocol of modularity unifying interface. -### Basic use-case +### Problem Solved -Library file with code `inner.rs`: +The `mod_interface` crate provides a structured approach to modularity, addressing two key challenges in software development: -```rust ignore -mod private +1. **Meaningful Namespace Structuring**: The crate enables developers to organize program entities into meaningful namespaces ( read modules ) without additional development overhead. This is achieved through a set of auto-importing rules and a flexible inversion of control mechanism, allowing parent namespaces to delegate control over its items to child namespaces. This approach ensures that each namespace is self-contained and meaningful, promoting better organization and modularity. + +2. **Enhanced Readability and Tooling Independence**: By requiring a `mod private` section that lists all items ( read functions, structures, traits, types ) the `mod_interface` macro encourages developers to create a concise list of items at the beginning or end of a file. This improves readability, encourages refactoring, and reduces cognitive load by providing a clear, high-level grouping of items. Code tooling is not always reliable and can sometimes be counterproductive by automating tasks that should be done manually to achieve more concise code. While code tooling like `rust_analyzer` are useful, this approach minimizes reliance on them, making the program's structure easier to understand and manage. + +While some may argue that inversion of control over namespaces may not always achieve the desired outcome, and code tooling can be sufficient, the `mod_interface` crate offers a cathartic solution for designing complex systems where tooling and triditional structuring often fall short. By promoting a clear and organized structure, it helps developers grasp the semantics of their programs more holistically. + +### Example : Trivial + +This example demonstrates how to use the `mod_interface` crate to organize a Rust program into structured namespaces. The code is divided into a library file (`child.rs`) and a main function. The library file defines a module with private functions and uses the `mod_interface` macro to specify which functions should be exposed in different namespaces. The main function then tests the visibility and accessibility of these functions. + +```rust +use mod_interface::mod_interface; + +// Define a module named `child`. +mod child { - /// Routine of inner module. - pub fn inner_is() -> bool + + // Define a private namespace for all its items. + mod private { - true + /// Only my thing. + pub fn my_thing() -> bool { true } + /// Parent module should also has this thing. + pub fn orphan_thing() -> bool { true } + /// This thing should be exposed. + pub fn exposed_thing() -> bool { true } + /// This thing should be in prelude. + pub fn prelude_thing() -> bool { true } } -} -// + // + + crate::mod_interface! + { + own use my_thing; + orphan use orphan_thing; + exposed use exposed_thing; + prelude use prelude_thing; + } -mod_interface::mod_interface! -{ - prelude use inner_is; } -``` -Main file that generates modules and namespaces `main.rs` : +// Priave namespaces is necessary. +mod private {} -```rust ignore -use mod_interface::mod_interface; +crate::mod_interface! +{ + /// Inner. + use super::child; +} -// fn main() { - assert_eq!( prelude::inner_is(), inner::prelude::inner_is() ); -} -// + assert!( child::prelude_thing(), "prelude thing of child is there" ); + assert!( prelude_thing(), "and here" ); + assert!( own::prelude_thing(), "and here" ); + assert!( orphan::prelude_thing(), "and here" ); + assert!( exposed::prelude_thing(), "and here" ); + assert!( prelude::prelude_thing(), "and here" ); + + assert!( child::exposed_thing(), "exposed thing of child is there" ); + assert!( exposed_thing(), "and here" ); + assert!( own::exposed_thing(), "and here" ); + assert!( orphan::exposed_thing(), "and here" ); + assert!( exposed::exposed_thing(), "and here" ); + // assert!( prelude::exposed_thing(), "but not here" ); + + assert!( child::orphan_thing(), "orphan thing of child is there" ); + assert!( orphan_thing(), "orphan thing of child is here" ); + assert!( own::orphan_thing(), "and here" ); + // assert!( orphan::orphan_thing(), "but not here" ); + // assert!( exposed::orphan_thing(), "and not here" ); + // assert!( prelude::orphan_thing(), "and not here" ); + + assert!( child::my_thing(), "own thing of child is only there" ); + // assert!( my_thing(), "and not here" ); + // assert!( own::my_thing(), "and not here" ); + // assert!( orphan::my_thing(), "and not here" ); + // assert!( exposed::my_thing(), "and not here" ); + // assert!( prelude::my_thing(), "and not here" ); -mod_interface::mod_interface! -{ - /// Inner. - layer inner; } + ``` -It generates code : +
+The code above will be expanded to this ```rust use mod_interface::mod_interface; -// - -fn main() -{ - assert_eq!( prelude::inner_is(), inner::prelude::inner_is() ); -} - -// - -/// Inner. -pub mod inner +// Define a module named `child` +pub mod child { + // Define a private namespace for all its items. mod private { - /// Routine of inner module. - pub fn inner_is() -> bool { true } + /// Only my thing. + pub fn my_thing() -> bool { true } + /// Parent module should also has this thing. + pub fn orphan_thing() -> bool { true } + /// This thing should be exposed. + pub fn exposed_thing() -> bool { true } + /// This thing should be in prelude. + pub fn prelude_thing() -> bool { true } } + pub use own::*; + /// Own namespace of the module. pub mod own { - pub use orphan::*; + pub use super::orphan::*; + pub use super::private::my_thing; } - pub use own::*; /// Orphan namespace of the module. pub mod orphan { - pub use exposed::*; + pub use super::exposed::*; + pub use super::private::orphan_thing; } /// Exposed namespace of the module. pub mod exposed { - pub use prelude::*; + pub use super::prelude::*; + pub use super::private::exposed_thing; } /// Prelude to use essentials: `use my_module::prelude::*`. pub mod prelude { - pub use private::inner_is; + pub use super::private::prelude_thing; } } +// Priave namespaces is necessary. +mod private {} + +pub use own::*; + /// Own namespace of the module. #[ allow( unused_imports ) ] pub mod own { use super::*; pub use orphan::*; - pub use super::inner::orphan::*; + pub use super::child::orphan::*; } -pub use own::*; /// Orphan namespace of the module. #[ allow( unused_imports ) ] @@ -123,7 +178,7 @@ pub mod exposed { use super::*; pub use prelude::*; - pub use super::inner::exposed::*; + pub use super::child::exposed::*; } /// Prelude to use essentials: `use my_module::prelude::*`. @@ -131,10 +186,48 @@ pub mod exposed pub mod prelude { use super::*; - pub use super::inner::prelude::*; + pub use super::child::prelude::*; +} + +// + +fn main() +{ + + assert!( child::prelude_thing(), "prelude thing of child is there" ); + assert!( prelude_thing(), "and here" ); + assert!( own::prelude_thing(), "and here" ); + assert!( orphan::prelude_thing(), "and here" ); + assert!( exposed::prelude_thing(), "and here" ); + assert!( prelude::prelude_thing(), "and here" ); + + assert!( child::exposed_thing(), "exposed thing of child is there" ); + assert!( exposed_thing(), "and here" ); + assert!( own::exposed_thing(), "and here" ); + assert!( orphan::exposed_thing(), "and here" ); + assert!( exposed::exposed_thing(), "and here" ); + // assert!( prelude::exposed_thing(), "but not here" ); + + assert!( child::orphan_thing(), "orphan thing of child is there" ); + assert!( orphan_thing(), "orphan thing of child is here" ); + assert!( own::orphan_thing(), "and here" ); + // assert!( orphan::orphan_thing(), "but not here" ); + // assert!( exposed::orphan_thing(), "and not here" ); + // assert!( prelude::orphan_thing(), "and not here" ); + + assert!( child::my_thing(), "own thing of child is only there" ); + // assert!( my_thing(), "and not here" ); + // assert!( own::my_thing(), "and not here" ); + // assert!( orphan::my_thing(), "and not here" ); + // assert!( exposed::my_thing(), "and not here" ); + // assert!( prelude::my_thing(), "and not here" ); + } + ``` +
+ ### Debugging To debug module interface use directive `#![ debug ]` in macro `mod_interface`. Let's update the main file of the example : @@ -144,7 +237,7 @@ mod_interface::mod_interface! { #![ debug ] /// Inner. - layer inner; + layer child; } ``` diff --git a/module/core/mod_interface/examples/mod_interface_debug/Readme.md b/module/core/mod_interface/examples/mod_interface_debug/Readme.md index 6cc31966fb..d57023c6a5 100644 --- a/module/core/mod_interface/examples/mod_interface_debug/Readme.md +++ b/module/core/mod_interface/examples/mod_interface_debug/Readme.md @@ -6,8 +6,10 @@ A sample demonstrates basic usage of macro `mod_interface`. -In file `inner.rs` demonstrated how to generate module interface from namespace `private` and its public routine. +In file `child.rs` demonstrated how to generate module interface from namespace `private` and its public routine. In file `main.rs` demonstrated how to generate module interface from layer ( file with full module interface ). The directive `#![ debug ]` in declaration of macro `mod_interface` allow to show generated module interface as the standard output in compile time. + + \ No newline at end of file diff --git a/module/core/mod_interface/examples/mod_interface_debug/src/inner.rs b/module/core/mod_interface/examples/mod_interface_debug/src/child.rs similarity index 80% rename from module/core/mod_interface/examples/mod_interface_debug/src/inner.rs rename to module/core/mod_interface/examples/mod_interface_debug/src/child.rs index cc62b2c56b..dd734212d9 100644 --- a/module/core/mod_interface/examples/mod_interface_debug/src/inner.rs +++ b/module/core/mod_interface/examples/mod_interface_debug/src/child.rs @@ -1,6 +1,6 @@ mod private { - /// Routine of inner module. + /// Routine of child module. pub fn inner_is() -> bool { true diff --git a/module/core/mod_interface/examples/mod_interface_debug/src/main.rs b/module/core/mod_interface/examples/mod_interface_debug/src/main.rs index e316b7acd6..985f4f49f7 100644 --- a/module/core/mod_interface/examples/mod_interface_debug/src/main.rs +++ b/module/core/mod_interface/examples/mod_interface_debug/src/main.rs @@ -3,16 +3,18 @@ use mod_interface::mod_interface; // -fn main() +mod private {} +mod_interface! { - assert_eq!( prelude::inner_is(), inner::prelude::inner_is() ); + // Uncomment to see expanded code. + // #![ debug ] + /// Child. + layer child; } // -mod_interface! +fn main() { - #![ debug ] - /// Inner. - layer inner; + assert_eq!( prelude::inner_is(), child::prelude::inner_is() ); } diff --git a/module/core/mod_interface/examples/mod_interface_trivial/src/child.rs b/module/core/mod_interface/examples/mod_interface_trivial/src/child.rs new file mode 100644 index 0000000000..4ea0121559 --- /dev/null +++ b/module/core/mod_interface/examples/mod_interface_trivial/src/child.rs @@ -0,0 +1,23 @@ + +// Define a private namespace for all its items. +mod private +{ + /// Only my thing. + pub fn my_thing() -> bool { true } + /// Parent module should also has this thing. + pub fn orphan_thing() -> bool { true } + /// This thing should be exposed. + pub fn exposed_thing() -> bool { true } + /// This thing should be in prelude. + pub fn prelude_thing() -> bool { true } +} + +// + +crate::mod_interface! +{ + own use my_thing; + orphan use orphan_thing; + exposed use exposed_thing; + prelude use prelude_thing; +} diff --git a/module/core/mod_interface/examples/mod_interface_trivial/src/inner.rs b/module/core/mod_interface/examples/mod_interface_trivial/src/inner.rs deleted file mode 100644 index cc62b2c56b..0000000000 --- a/module/core/mod_interface/examples/mod_interface_trivial/src/inner.rs +++ /dev/null @@ -1,15 +0,0 @@ -mod private -{ - /// Routine of inner module. - pub fn inner_is() -> bool - { - true - } -} - -// - -mod_interface::mod_interface! -{ - prelude use inner_is; -} diff --git a/module/core/mod_interface/examples/mod_interface_trivial/src/main.rs b/module/core/mod_interface/examples/mod_interface_trivial/src/main.rs index 03b8905594..420a6c9fb4 100644 --- a/module/core/mod_interface/examples/mod_interface_trivial/src/main.rs +++ b/module/core/mod_interface/examples/mod_interface_trivial/src/main.rs @@ -1,21 +1,49 @@ -//! qqq : write proper descriptionuse mod_interface::mod_interface; - -// +//! This example demonstrates how to use the `mod_interface` crate to organize a Rust program into structured namespaces. The code is divided into a library file (`child.rs`) and a main function. The library file defines a module with private functions and uses the `mod_interface` macro to specify which functions should be exposed in different namespaces. The main function then tests the visibility and accessibility of these functions. use mod_interface::mod_interface; -fn main() -{ - assert_eq!( prelude::inner_is(), prelude::inner_is() ); -} +/// Children. +mod child; -// +// Priave namespaces is necessary. +mod private {} -mod_interface! +crate::mod_interface! { /// Inner. - layer inner; + use super::child; } -// qqq : rewrite sample -/* aaa : Dmytro : sample with layer */ + +fn main() +{ + + assert!( child::prelude_thing(), "prelude thing of child is there" ); + assert!( prelude_thing(), "and here" ); + assert!( own::prelude_thing(), "and here" ); + assert!( orphan::prelude_thing(), "and here" ); + assert!( exposed::prelude_thing(), "and here" ); + assert!( prelude::prelude_thing(), "and here" ); + + assert!( child::exposed_thing(), "exposed thing of child is there" ); + assert!( exposed_thing(), "and here" ); + assert!( own::exposed_thing(), "and here" ); + assert!( orphan::exposed_thing(), "and here" ); + assert!( exposed::exposed_thing(), "and here" ); + // assert!( prelude::exposed_thing(), "but not here" ); + + assert!( child::orphan_thing(), "orphan thing of child is there" ); + assert!( orphan_thing(), "orphan thing of child is here" ); + assert!( own::orphan_thing(), "and here" ); + // assert!( orphan::orphan_thing(), "but not here" ); + // assert!( exposed::orphan_thing(), "and not here" ); + // assert!( prelude::orphan_thing(), "and not here" ); + + assert!( child::my_thing(), "own thing of child is only there" ); + // assert!( my_thing(), "and not here" ); + // assert!( own::my_thing(), "and not here" ); + // assert!( orphan::my_thing(), "and not here" ); + // assert!( exposed::my_thing(), "and not here" ); + // assert!( prelude::my_thing(), "and not here" ); + +} diff --git a/module/core/mod_interface/src/lib.rs b/module/core/mod_interface/src/lib.rs index 30c7731f89..726b166188 100644 --- a/module/core/mod_interface/src/lib.rs +++ b/module/core/mod_interface/src/lib.rs @@ -1,4 +1,4 @@ -#![ cfg_attr( feature = "no_std", no_std ) ] +#![ no_std ] #![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] #![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] #![ doc( html_root_url = "https://docs.rs/mod_interface/latest/mod_interface/" ) ] diff --git a/module/core/mod_interface/tests/inc/derive/attr_debug/mod.rs b/module/core/mod_interface/tests/inc/derive/attr_debug/mod.rs index 939ebcdfb3..57b54aff39 100644 --- a/module/core/mod_interface/tests/inc/derive/attr_debug/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/attr_debug/mod.rs @@ -1,9 +1,11 @@ use super::*; +mod private {} + mod_interface! { - #![ debug ] + // #![ debug ] /// layer_a layer layer_a; diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules/mod.rs b/module/core/mod_interface/tests/inc/derive/micro_modules/mod.rs index 09c94a139e..80d4c7218a 100644 --- a/module/core/mod_interface/tests/inc/derive/micro_modules/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/micro_modules/mod.rs @@ -8,6 +8,7 @@ mod private mod_interface! { + // #![ debug ] /// mod_own own mod mod_own; diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules/mod_protected.rs b/module/core/mod_interface/tests/inc/derive/micro_modules/mod_own.rs similarity index 100% rename from module/core/mod_interface/tests/inc/derive/micro_modules/mod_protected.rs rename to module/core/mod_interface/tests/inc/derive/micro_modules/mod_own.rs diff --git a/module/core/mod_interface/tests/inc/manual/micro_modules/mod_protected.rs b/module/core/mod_interface/tests/inc/derive/micro_modules_glob/child.rs similarity index 100% rename from module/core/mod_interface/tests/inc/manual/micro_modules/mod_protected.rs rename to module/core/mod_interface/tests/inc/derive/micro_modules_glob/child.rs diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules_glob/mod.rs b/module/core/mod_interface/tests/inc/derive/micro_modules_glob/mod.rs new file mode 100644 index 0000000000..40ccb61f64 --- /dev/null +++ b/module/core/mod_interface/tests/inc/derive/micro_modules_glob/mod.rs @@ -0,0 +1,28 @@ + +// use super::*; + +/// Internal namespace. +mod private +{ + pub struct Struct1; + pub struct Struct2; +} + +// + +crate::mod_interface! +{ + own use + { + * + }; +} + +// + +#[ test ] +fn basic() +{ + let _s1 = Struct1; + let _s2 = Struct2; +} diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules_two/mod_protected1.rs b/module/core/mod_interface/tests/inc/derive/micro_modules_two/mod_own1.rs similarity index 100% rename from module/core/mod_interface/tests/inc/derive/micro_modules_two/mod_protected1.rs rename to module/core/mod_interface/tests/inc/derive/micro_modules_two/mod_own1.rs diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules_two/mod_protected2.rs b/module/core/mod_interface/tests/inc/derive/micro_modules_two/mod_own2.rs similarity index 100% rename from module/core/mod_interface/tests/inc/derive/micro_modules_two/mod_protected2.rs rename to module/core/mod_interface/tests/inc/derive/micro_modules_two/mod_own2.rs diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules_two_joined/mod_protected1.rs b/module/core/mod_interface/tests/inc/derive/micro_modules_two_joined/mod_own1.rs similarity index 100% rename from module/core/mod_interface/tests/inc/derive/micro_modules_two_joined/mod_protected1.rs rename to module/core/mod_interface/tests/inc/derive/micro_modules_two_joined/mod_own1.rs diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules_two_joined/mod_protected2.rs b/module/core/mod_interface/tests/inc/derive/micro_modules_two_joined/mod_own2.rs similarity index 100% rename from module/core/mod_interface/tests/inc/derive/micro_modules_two_joined/mod_protected2.rs rename to module/core/mod_interface/tests/inc/derive/micro_modules_two_joined/mod_own2.rs diff --git a/module/core/mod_interface/tests/inc/derive/reuse_basic/child.rs b/module/core/mod_interface/tests/inc/derive/reuse_basic/child.rs new file mode 100644 index 0000000000..d94a40b5bd --- /dev/null +++ b/module/core/mod_interface/tests/inc/derive/reuse_basic/child.rs @@ -0,0 +1,15 @@ +mod private +{ + pub struct Own; + pub struct Orphan; + pub struct Exposed; + pub struct Prelude; +} + +crate::mod_interface! +{ + own use Own; + orphan use Orphan; + exposed use Exposed; + prelude use Prelude; +} diff --git a/module/core/mod_interface/tests/inc/derive/reuse_basic/mod.rs b/module/core/mod_interface/tests/inc/derive/reuse_basic/mod.rs new file mode 100644 index 0000000000..55daeb2a1c --- /dev/null +++ b/module/core/mod_interface/tests/inc/derive/reuse_basic/mod.rs @@ -0,0 +1,34 @@ + +// use super::*; + +/// Internal namespace. +mod private +{ +} + +mod child; + +// + +crate::mod_interface! +{ + reuse child; +} + +// + +#[ test ] +fn basic() +{ + + let _ = child::Own; + let _ = child::Orphan; + let _ = child::Exposed; + let _ = child::Prelude; + + let _ = Own; + let _ = Orphan; + let _ = Exposed; + let _ = Prelude; + +} diff --git a/module/core/mod_interface/tests/inc/derive/use_as/derive.rs b/module/core/mod_interface/tests/inc/derive/use_as/derive.rs index 4c452702b0..a70260fc3c 100644 --- a/module/core/mod_interface/tests/inc/derive/use_as/derive.rs +++ b/module/core/mod_interface/tests/inc/derive/use_as/derive.rs @@ -4,6 +4,8 @@ use super::*; /// Layer X pub mod layer_x; +mod private {} + mod_interface! { // #![ debug ] @@ -13,7 +15,7 @@ mod_interface! // /// layer_a // pub use super::layer_x as layer_a; - // xxx : make that working + // zzz : make that working } diff --git a/module/core/mod_interface/tests/inc/derive/use_as/manual_only.rs b/module/core/mod_interface/tests/inc/derive/use_as/manual_only.rs index f6fcb2f162..9ce347e8fb 100644 --- a/module/core/mod_interface/tests/inc/derive/use_as/manual_only.rs +++ b/module/core/mod_interface/tests/inc/derive/use_as/manual_only.rs @@ -3,7 +3,7 @@ use layer_x as layer_a; #[doc(inline)] #[allow(unused_imports)] -pub use protected :: * ; +pub use own :: * ; #[doc = r" Own namespace of the module."] #[ allow( unused_imports ) ] diff --git a/module/core/mod_interface/tests/inc/derive/use_basic/mod.rs b/module/core/mod_interface/tests/inc/derive/use_basic/mod.rs index 3cfbb3ad53..fe3862d5b3 100644 --- a/module/core/mod_interface/tests/inc/derive/use_basic/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/use_basic/mod.rs @@ -4,6 +4,8 @@ use super::*; mod layer_a; mod layer_b; +mod private {} + mod_interface! { diff --git a/module/core/mod_interface/tests/inc/derive/use_layer/mod.rs b/module/core/mod_interface/tests/inc/derive/use_layer/mod.rs index 17247d2d07..a7f1790c60 100644 --- a/module/core/mod_interface/tests/inc/derive/use_layer/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/use_layer/mod.rs @@ -6,11 +6,6 @@ mod tools pub use super::super::*; } -// /// Private namespace of the module. -// mod private -// { -// } - mod layer_a; /// SuperStruct1. @@ -19,6 +14,8 @@ pub struct SuperStruct1 { } +mod private {} + mod_interface! { diff --git a/module/core/mod_interface/tests/inc/manual/micro_modules/mod_own.rs b/module/core/mod_interface/tests/inc/manual/micro_modules/mod_own.rs new file mode 100644 index 0000000000..a6619cc0c4 --- /dev/null +++ b/module/core/mod_interface/tests/inc/manual/micro_modules/mod_own.rs @@ -0,0 +1,5 @@ +/// has_own +pub fn has_own() -> bool +{ + true +} \ No newline at end of file diff --git a/module/core/mod_interface/tests/inc/manual/micro_modules_two/mod_protected1.rs b/module/core/mod_interface/tests/inc/manual/micro_modules_two/mod_own1.rs similarity index 100% rename from module/core/mod_interface/tests/inc/manual/micro_modules_two/mod_protected1.rs rename to module/core/mod_interface/tests/inc/manual/micro_modules_two/mod_own1.rs diff --git a/module/core/mod_interface/tests/inc/manual/micro_modules_two/mod_protected2.rs b/module/core/mod_interface/tests/inc/manual/micro_modules_two/mod_own2.rs similarity index 100% rename from module/core/mod_interface/tests/inc/manual/micro_modules_two/mod_protected2.rs rename to module/core/mod_interface/tests/inc/manual/micro_modules_two/mod_own2.rs diff --git a/module/core/mod_interface/tests/inc/mod.rs b/module/core/mod_interface/tests/inc/mod.rs index 5d8aaa7045..f838c57b50 100644 --- a/module/core/mod_interface/tests/inc/mod.rs +++ b/module/core/mod_interface/tests/inc/mod.rs @@ -22,6 +22,7 @@ mod derive mod micro_modules; mod micro_modules_two; mod micro_modules_two_joined; + mod micro_modules_glob; // layer mod layer; @@ -33,6 +34,7 @@ mod derive mod layer_use_cfg; mod layer_use_macro; + // use mod use_layer; mod use_basic; #[ path = "./use_as/derive.rs" ] @@ -40,9 +42,14 @@ mod derive #[ path = "./use_as/manual.rs" ] mod use_as_manual; + // reuse + mod reuse_basic; + // attr mod attr_debug; } -mod trybuild_test; +// mod trybuild_test; + +// xxx : enable \ No newline at end of file diff --git a/module/core/mod_interface_meta/Cargo.toml b/module/core/mod_interface_meta/Cargo.toml index b3de1c7f95..ab3e6c709c 100644 --- a/module/core/mod_interface_meta/Cargo.toml +++ b/module/core/mod_interface_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mod_interface_meta" -version = "0.24.0" +version = "0.29.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/mod_interface_meta/License b/module/core/mod_interface_meta/License index e3e9e057cf..c32986cee3 100644 --- a/module/core/mod_interface_meta/License +++ b/module/core/mod_interface_meta/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/mod_interface_meta/src/impls.rs b/module/core/mod_interface_meta/src/impls.rs index 737dab4d78..58fec18e93 100644 --- a/module/core/mod_interface_meta/src/impls.rs +++ b/module/core/mod_interface_meta/src/impls.rs @@ -16,7 +16,7 @@ mod private // = ? // x - // protected protected1; + // own own1; // orphan orphan1; // exposed exposed1; // prelude prelude1; @@ -33,7 +33,7 @@ mod private // x // orphan macromod mod_orphan1; - // : protected -> protected + // : own -> own // : orphan -> orphan // : exposed -> orphan // : prelude -> orphan @@ -42,14 +42,14 @@ mod private // x // prelude exposed macromod mod_own1; - // : protected -> exposed + // : own -> exposed // : orphan -> exposed // : exposed -> exposed // : prelude -> prelude // x - // prelude protected macromod mod_exposed1; - // : protected -> protected + // prelude own macromod mod_exposed1; + // : own -> own // : orphan -> orphan // : exposed -> exposed // : prelude -> prelude @@ -58,14 +58,14 @@ mod private // x // exposed exposed macromod mod_exposed1; - // : protected -> exposed + // : own -> exposed // : orphan -> exposed // : exposed -> exposed // : prelude -> exposed // x // exposed orphan macromod mod_exposed1; - // : protected -> orphan + // : own -> orphan // : orphan -> orphan // : exposed -> exposed // : prelude -> exposed @@ -102,12 +102,10 @@ mod private /// /// Handle record "use" with implicit visibility. /// - #[ allow ( dead_code ) ] - fn record_use_implicit + fn record_reuse_implicit ( record : &Record, c : &'_ mut RecordContext< '_ >, - // clauses_map : &mut HashMap< u32, Vec< proc_macro2::TokenStream > >, ) -> syn::Result< () > @@ -115,35 +113,88 @@ mod private let attrs1 = &record.attrs; let path = record.use_elements.as_ref().unwrap(); - // let vis = record.vis.clone(); - // if vis == Visibility::Inherited + let path = if let Some( rename ) = &path.rename + { + let pure_path = path.pure_without_super_path()?; + c.clauses_map.get_mut( &ClauseImmediates::Kind() ).unwrap().push( qt! + { + pub use #pure_path as #rename; + }); + parse_qt!{ #rename } + } + else + { + path.clone() + }; - // xxx + let adjsuted_path = path.prefixed_with_all(); - // let _path; - // let path2 = if path.prefix_is_needed() - // { - // _path = parse_qt!{ super::private::#path }; - // &_path - // } - // else - // { - // path - // }; + c.clauses_map.get_mut( &VisOwn::Kind() ).unwrap().push( qt! + { + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + #attrs1 + pub use #adjsuted_path::own::*; + }); - let adjsuted_path = path.adjsuted_implicit_path()?; + c.clauses_map.get_mut( &VisOrphan::Kind() ).unwrap().push( qt! + { + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + #attrs1 + pub use #adjsuted_path::orphan::*; + }); - // println!( "adjsuted_path : {}", qt!{ #adjsuted_path } ); + c.clauses_map.get_mut( &VisExposed::Kind() ).unwrap().push( qt! + { + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + #attrs1 + pub use #adjsuted_path::exposed::*; + }); - if let Some( rename ) = &path.rename + c.clauses_map.get_mut( &VisPrelude::Kind() ).unwrap().push( qt! + { + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + #attrs1 + pub use #adjsuted_path::prelude::*; + }); + + Ok( () ) + } + + /// + /// Handle record "use" with implicit visibility. + /// + fn record_use_implicit + ( + record : &Record, + c : &'_ mut RecordContext< '_ >, + ) + -> + syn::Result< () > + { + + let attrs1 = &record.attrs; + let path = record.use_elements.as_ref().unwrap(); + + let path = if let Some( rename ) = &path.rename { let pure_path = path.pure_without_super_path()?; c.clauses_map.get_mut( &ClauseImmediates::Kind() ).unwrap().push( qt! { pub use #pure_path as #rename; }); + parse_qt!{ #rename } } + else + { + path.clone() + }; + + let adjsuted_path = path.prefixed_with_all(); c.clauses_map.get_mut( &VisOwn::Kind() ).unwrap().push( qt! { @@ -175,12 +226,10 @@ mod private /// /// Handle record "use" with explicit visibility. /// - #[ allow ( dead_code ) ] fn record_use_explicit ( record : &Record, c : &'_ mut RecordContext< '_ >, - // clauses_map : &mut HashMap< u32, Vec< proc_macro2::TokenStream > >, ) -> syn::Result< () > @@ -200,8 +249,7 @@ mod private )); } - let adjsuted_path = path.adjsuted_explicit_path(); - + let adjsuted_path = path.prefixed_with_all(); let vis2 = if vis.restriction().is_some() { qt!{ pub( crate ) } @@ -248,13 +296,16 @@ mod private if !record.vis.valid_sub_namespace() { - return Err( syn_err! + return Err ( - record, - "To include a non-standard module use either {} visibility:\n {}", - VALID_VISIBILITY_LIST_STR, - qt!{ #record }, - )); + syn_err! + ( + record, + "To include a non-standard module use either {} visibility:\n {}", + VALID_VISIBILITY_LIST_STR, + qt!{ #record }, + ) + ); } c.clauses_map.get_mut( &record.vis.kind() ).unwrap().push( qt! @@ -263,7 +314,8 @@ mod private #[ allow( unused_imports ) ] #attrs1 #attrs2 - pub use #path; + pub use __all__::#path; + // pub use super::#path; // xxx : remove super? }); @@ -310,7 +362,7 @@ mod private #[ allow( unused_imports ) ] #attrs1 #attrs2 - pub use #path::orphan::*; + pub use __all__::#path::orphan::*; }); c.clauses_map.get_mut( &VisExposed::Kind() ).unwrap().push( qt! @@ -319,7 +371,7 @@ mod private #[ allow( unused_imports ) ] #attrs1 #attrs2 - pub use #path::exposed::*; + pub use __all__::#path::exposed::*; }); c.clauses_map.get_mut( &VisPrelude::Kind() ).unwrap().push( qt! @@ -328,7 +380,7 @@ mod private #[ allow( unused_imports ) ] #attrs1 #attrs2 - pub use #path::prelude::*; + pub use __all__::#path::prelude::*; }); Ok( () ) @@ -383,6 +435,23 @@ mod private record_use_explicit( record, &mut record_context )?; } }, + Reuse( _ ) => + { + let vis = &record.vis; + if vis == &Visibility::Inherited + { + record_reuse_implicit( record, &mut record_context )?; + } + else + { + return Err( syn_err! + ( + record, + "Using visibility usesd before `reuse` is illegal\n{}", + qt!{ #record }, + )); + } + }, _ => { record.elements.iter().try_for_each( | element | -> syn::Result::< () > @@ -397,8 +466,9 @@ mod private { record_layer( record, element, &mut record_context )?; }, - Use( _ ) => + _ => { + panic!( "Unexpected" ) }, } syn::Result::Ok( () ) @@ -410,7 +480,7 @@ mod private })?; let immediates_clause = clauses_map.get( &ClauseImmediates::Kind() ).unwrap(); - let protected_clause = clauses_map.get( &VisOwn::Kind() ).unwrap(); + let own_clause = clauses_map.get( &VisOwn::Kind() ).unwrap(); let orphan_clause = clauses_map.get( &VisOrphan::Kind() ).unwrap(); let exposed_clause = clauses_map.get( &VisExposed::Kind() ).unwrap(); let prelude_clause = clauses_map.get( &VisPrelude::Kind() ).unwrap(); @@ -420,6 +490,8 @@ mod private #( #immediates_clause )* + // use private as __private__; // this line is necessary for readable error in case private namespace is not present + #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use own::*; @@ -428,19 +500,34 @@ mod private #[ allow( unused_imports ) ] pub mod own { - use super::*; + // There must be internal private namespace + // Because it's not possible to direcly make `use super::*;` + // Because then items from super can't be exposed publicly complaining: + // `error[E0428]: the name `mod1` is defined multiple times` + // use super::*; + use super::private; // this line is necessary for readable error in case private namespace is not present + mod __all__ + { + pub use super::super::*; + pub use super::super::private::*; + } #[ doc( inline ) ] - pub use orphan::*; - #( #protected_clause )* + pub use super::orphan::*; + #( #own_clause )* } /// Orphan namespace of the module. #[ allow( unused_imports ) ] pub mod orphan { - use super::*; + // use super::*; + mod __all__ + { + pub use super::super::*; + pub use super::super::private::*; + } #[ doc( inline ) ] - pub use exposed::*; + pub use super::exposed::*; #( #orphan_clause )* } @@ -448,9 +535,14 @@ mod private #[ allow( unused_imports ) ] pub mod exposed { - use super::*; + // use super::*; + mod __all__ + { + pub use super::super::*; + pub use super::super::private::*; + } #[ doc( inline ) ] - pub use prelude::*; + pub use super::prelude::*; #( #exposed_clause )* } @@ -458,7 +550,12 @@ mod private #[ allow( unused_imports ) ] pub mod prelude { - use super::*; + // use super::*; + mod __all__ + { + pub use super::super::*; + pub use super::super::private::*; + } #( #prelude_clause )* } diff --git a/module/core/mod_interface_meta/src/lib.rs b/module/core/mod_interface_meta/src/lib.rs index bb595ba9a2..70dc68878e 100644 --- a/module/core/mod_interface_meta/src/lib.rs +++ b/module/core/mod_interface_meta/src/lib.rs @@ -1,9 +1,23 @@ #![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] #![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] #![ doc( html_root_url = "https://docs.rs/mod_interface_meta/latest/mod_interface_meta/" ) ] -#![ deny( dead_code ) ] #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] +#![ warn( dead_code ) ] + +// /// Derives. +// layer derive; +// own use super::derive; +// // xxx : change to remove need to write explicitly that + +// xxx : change to remove need to write explicitly that +// crate::mod_interface! +// { +// /// Derives. +// layer derive; +// own use super::derive; // xxx : change to remove need to write explicitly that +// } + // xxx : clean up, ad solve problems // - example based on simpified version of test::layer_have_layer with single sublayer // - example with attribute `#![ debug ]` @@ -29,7 +43,7 @@ // }; // } -// xxx : make use proper_path_tools::own::path working +// xxx : make use pth::own::path working // xxx : put modular files into a namespace `file` maybe // #[ cfg( feature = "enabled" ) ] diff --git a/module/core/mod_interface_meta/src/record.rs b/module/core/mod_interface_meta/src/record.rs index c60b0bb55c..70e8f289ec 100644 --- a/module/core/mod_interface_meta/src/record.rs +++ b/module/core/mod_interface_meta/src/record.rs @@ -11,6 +11,7 @@ mod private pub mod kw { super::syn::custom_keyword!( layer ); + super::syn::custom_keyword!( reuse ); } /// @@ -23,6 +24,7 @@ mod private MicroModule( syn::token::Mod ), Layer( kw::layer ), Use( syn::token::Use ), + Reuse( kw::reuse ), } // @@ -47,6 +49,10 @@ mod private { ElementType::Layer( input.parse()? ) }, + _case if lookahead.peek( kw::reuse ) => + { + ElementType::Reuse( input.parse()? ) + }, _default => { return Err( lookahead.error() ) @@ -69,6 +75,7 @@ mod private MicroModule( e ) => e.to_tokens( tokens ), Use( e ) => e.to_tokens( tokens ), Layer( e ) => e.to_tokens( tokens ), + Reuse( e ) => e.to_tokens( tokens ), } } } @@ -104,7 +111,7 @@ mod private match element_type { - ElementType::Use( _ ) => + ElementType::Use( _ ) | ElementType::Reuse( _ ) => { use_elements = Some( input.parse()? ); elements = syn::punctuated::Punctuated::new(); diff --git a/module/core/mod_interface_meta/src/use_tree.rs b/module/core/mod_interface_meta/src/use_tree.rs index f87ee133ad..de6805dd90 100644 --- a/module/core/mod_interface_meta/src/use_tree.rs +++ b/module/core/mod_interface_meta/src/use_tree.rs @@ -105,32 +105,50 @@ mod private Ok( path ) } - /// Adjusted path. - /// Add `super::private::` to path unless it starts from `::` or `super` or `crate`. - pub fn adjsuted_implicit_path( &self ) -> syn::Result< syn::punctuated::Punctuated< syn::Ident, Token![::] > > - { - // use syn::UseTree::*; - let pure_path = self.pure_path()?; - if self.prefix_is_needed() - { - Ok( parse_qt!{ super::private::#pure_path } ) - } - else - { - Ok( pure_path ) - } - } +// /// Adjusted path. +// /// Add `super::private::` to path unless it starts from `::` or `super` or `crate`. +// pub fn adjsuted_implicit_path( &self ) -> syn::Result< syn::punctuated::Punctuated< syn::Ident, Token![::] > > +// { +// // use syn::UseTree::*; +// let pure_path = self.pure_path()?; +// if self.prefix_is_needed() +// { +// Ok( parse_qt!{ super::private::#pure_path } ) +// } +// else +// { +// Ok( pure_path ) +// } +// } +// +// /// Adjusted path. +// /// Add `super::private::` to path unless it starts from `::` or `super` or `crate`. +// // pub fn adjsuted_explicit_path( &self ) -> syn::UseTree +// pub fn adjsuted_explicit_path( &self ) -> Self +// { +// // use syn::UseTree::*; +// if self.prefix_is_needed() +// { +// let mut clone = self.clone(); +// let tree = parse_qt!{ super::private::#self }; +// clone.tree = tree; +// clone +// } +// else +// { +// self.clone() +// } +// } - /// Adjusted path. - /// Add `super::private::` to path unless it starts from `::` or `super` or `crate`. - // pub fn adjsuted_explicit_path( &self ) -> syn::UseTree - pub fn adjsuted_explicit_path( &self ) -> Self + /// Prefix path with __all__ if it's appropriate. + pub fn prefixed_with_all( &self ) -> Self { + // use syn::UseTree::*; if self.prefix_is_needed() { let mut clone = self.clone(); - let tree = parse_qt!{ super::private::#self }; + let tree = parse_qt!{ __all__::#self }; clone.tree = tree; clone } @@ -138,6 +156,7 @@ mod private { self.clone() } + } } diff --git a/module/core/process_tools/Cargo.toml b/module/core/process_tools/Cargo.toml index 308881a600..e358031ef1 100644 --- a/module/core/process_tools/Cargo.toml +++ b/module/core/process_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "process_tools" -version = "0.9.0" +version = "0.12.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -31,7 +31,7 @@ full = [ "default" ] enabled = [ "mod_interface/enabled", "former/enabled", - "proper_path_tools/enabled", + "pth/enabled", "error_tools/enabled", "iter_tools/enabled", ] @@ -42,7 +42,7 @@ process_environment_is_cicd = [] [dependencies] mod_interface = { workspace = true } former = { workspace = true, features = [ "derive_former" ] } -proper_path_tools = { workspace = true } +pth = { workspace = true } error_tools = { workspace = true, features = [ "error_untyped" ] } iter_tools = { workspace = true } diff --git a/module/core/process_tools/License b/module/core/process_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/process_tools/License +++ b/module/core/process_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/process_tools/src/lib.rs b/module/core/process_tools/src/lib.rs index ceb35389ea..2f91e2f714 100644 --- a/module/core/process_tools/src/lib.rs +++ b/module/core/process_tools/src/lib.rs @@ -7,6 +7,8 @@ #[ cfg( feature = "enabled" ) ] use mod_interface::mod_interface; +mod private {} + #[ cfg( feature = "enabled" ) ] mod_interface! { diff --git a/module/core/program_tools/Cargo.toml b/module/core/program_tools/Cargo.toml index 1ba2675334..a5e28c9202 100644 --- a/module/core/program_tools/Cargo.toml +++ b/module/core/program_tools/Cargo.toml @@ -36,7 +36,7 @@ full = [ enabled = [ "mod_interface/enabled", "former/enabled", - "proper_path_tools/enabled", + "pth/enabled", "error_tools/enabled", "iter_tools/enabled", ] @@ -44,7 +44,7 @@ enabled = [ [dependencies] mod_interface = { workspace = true } former = { workspace = true, features = [ "derive_former" ] } -proper_path_tools = { workspace = true } +pth = { workspace = true } error_tools = { workspace = true, features = [ "error_untyped" ] } # qqq : xxx : rid of error_untyped iter_tools = { workspace = true } diff --git a/module/core/program_tools/License b/module/core/program_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/program_tools/License +++ b/module/core/program_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/proper_path_tools/Readme.md b/module/core/proper_path_tools/Readme.md deleted file mode 100644 index d142018019..0000000000 --- a/module/core/proper_path_tools/Readme.md +++ /dev/null @@ -1,35 +0,0 @@ - - -# Module :: proper_path_tools - - [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_proper_path_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_proper_path_tools_push.yml) [![docs.rs](https://img.shields.io/docsrs/proper_path_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/proper_path_tools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) - - -Collection of algorithms and structures to handle paths properly. - -All functions in the crate don't touch file system, but only process paths. - - diff --git a/module/core/proper_path_tools/Cargo.toml b/module/core/pth/Cargo.toml similarity index 87% rename from module/core/proper_path_tools/Cargo.toml rename to module/core/pth/Cargo.toml index 5c6387502b..79a2141441 100644 --- a/module/core/proper_path_tools/Cargo.toml +++ b/module/core/pth/Cargo.toml @@ -1,15 +1,15 @@ [package] -name = "proper_path_tools" -version = "0.10.0" +name = "pth" +version = "0.21.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", ] license = "MIT" readme = "Readme.md" -documentation = "https://docs.rs/proper_path_tools" -repository = "https://github.com/Wandalen/wTools/tree/master/module/core/proper_path_tools" -homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/proper_path_tools" +documentation = "https://docs.rs/pth" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/pth" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/pth" description = """ Collection of algorithms and structures to handle paths properly. """ @@ -35,6 +35,8 @@ full = [ "path_utf8", ] no_std = [] +# qqq : xxx : negate no_std +# use_std = [] use_alloc = [ "no_std" ] enabled = [ "mod_interface/enabled" ] diff --git a/module/core/pth/License b/module/core/pth/License new file mode 100644 index 0000000000..0804aed8e3 --- /dev/null +++ b/module/core/pth/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/core/pth/Readme.md b/module/core/pth/Readme.md new file mode 100644 index 0000000000..a6f4c2f04d --- /dev/null +++ b/module/core/pth/Readme.md @@ -0,0 +1,51 @@ + + +# Module :: pth + + [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_pth_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_pth_push.yml) [![docs.rs](https://img.shields.io/docsrs/pth?color=e3e8f0&logo=docs.rs)](https://docs.rs/pth) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + +Collection of algorithms and structures to handle paths properly. + +All functions in the crate don't touch file system, but only process paths. + +### Type `AbsolutePath` + +The AbsolutePath type ensures that paths are absolute, which helps reduce issues and maintenance costs associated with relative paths. Relative paths can be problematic as they introduce additional variables and complexities, making code analysis, integration, refactoring, and testing more difficult. By using absolute paths, software architecture can be improved, similar to how avoiding global variables can enhance code quality. It is recommended to use relative paths only at the outskirts of an application. + +### Trait `AsPath` + +This trait is used to avoid redundant allocation of memory by providing a reference to a Path. It is implemented only for types that can either be referenced or are references to Path itself. Unlike `TryIntoPath`, it does not allocate memory on the heap. However, `TryIntoPath` is implemented for a wider range of types because it is not restricted from allocating memory. Unlike `AsRef< Path >`, `AsPath` is implemented for a wider number of types, including those that are not directly convertible to a Path using `AsRef`. This is because `AsPath` is designed to provide a more flexible interface for path-like types, accommodating various representations that can logically be treated as paths. + +### Trait `TryIntoPath` + +This trait is used to convert any path-like type into an owned PathBuf. Unlike `TryIntoCowPath`, it always returns an owned PathBuf, so there is no need to differentiate between borrowed and owned paths at runtime. Unlike `AsPath`, it is implemented for a wider range of path-like types, similar to `TryIntoCowPath`. + +### Trait `TryIntoCowPath` + +This trait is designed to avoid redundant memory allocation. Unlike TryIntoPath, it does not allocate memory on the heap if it’s not necessary. Unlike `AsPath`, it is implemented for a wider number of path-like types, similar to TryIntoPath. The drawback is the necessity to differentiate borrowed and owned paths at runtime. + + diff --git a/module/core/pth/src/as_path.rs b/module/core/pth/src/as_path.rs new file mode 100644 index 0000000000..b94a4cf4d4 --- /dev/null +++ b/module/core/pth/src/as_path.rs @@ -0,0 +1,71 @@ +/// Internal namespace. +mod private +{ + #[ allow( unused_imports ) ] + use crate::*; + #[ cfg( feature = "no_std" ) ] + extern crate std; + + use std::path::Path; + + /// A trait for converting various types into a reference to a `Path`. + /// + /// This trait is used to avoid redundant allocation of memory by providing a reference to a `Path`. + /// It is implemented only for types that can either be referenced or are references to `Path` itself. + /// Unlike `TryIntoPath`, it does not allocate memory on the heap. However, `TryIntoPath` is implemented for a wider range of types because it is not restricted from allocating memory. + /// Unlike `AsRef`, `AsPath` is implemented for a wider number of types, including those that are not directly convertible to a `Path` using `AsRef`. + /// This is because `AsPath` is designed to provide a more flexible interface for path-like types, accommodating various representations that can logically be treated as paths. + pub trait AsPath + { + /// Converts the implementing type into a reference to a `Path`. + /// + /// # Returns + /// + /// A reference to a `Path`. + fn as_path( &self ) -> &Path; + } + + /// Implementation of `AsPath` for `str`. + impl AsPath for str + { + fn as_path( &self ) -> &Path + { + Path::new( self ) + } + } + + /// Implementation of `AsPath` for `Path`. + impl AsPath for Path + { + fn as_path( &self ) -> &Path + { + self + } + } + + /// Implementation of `AsPath` for `Utf8Path`. + #[cfg( feature = "path_utf8" )] + impl AsPath for Utf8Path + { + fn as_path( &self ) -> &Path + { + self.as_std_path() + } + } + + /// Blanket implementation of `AsPath` for all types that implement `AsRef`. + impl< T > AsPath for T + where + T : AsRef< Path >, + { + fn as_path( &self ) -> &Path + { + self.as_ref() + } + } +} + +crate::mod_interface! +{ + orphan use AsPath; +} \ No newline at end of file diff --git a/module/core/proper_path_tools/src/lib.rs b/module/core/pth/src/lib.rs similarity index 65% rename from module/core/proper_path_tools/src/lib.rs rename to module/core/pth/src/lib.rs index fe0f646c03..223020ac00 100644 --- a/module/core/proper_path_tools/src/lib.rs +++ b/module/core/pth/src/lib.rs @@ -1,7 +1,7 @@ #![ cfg_attr( feature = "no_std", no_std ) ] #![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] #![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] -#![ doc( html_root_url = "https://docs.rs/proper_path_tools/latest/proper_path_tools/" ) ] +#![ doc( html_root_url = "https://docs.rs/pth/latest/pth/" ) ] #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] #[ cfg( feature = "enabled" ) ] @@ -11,6 +11,8 @@ use mod_interface::mod_interface; #[ macro_use ] extern crate alloc; +mod private {} + #[ cfg( feature = "enabled" ) ] mod_interface! { @@ -18,12 +20,26 @@ mod_interface! /// Basic functionality. layer path; + /// AsPath trait. + layer as_path; + /// TryIntoPath trait. + layer try_into_path; + /// TryIntoPath trait. + layer try_into_cow_path; + /// Transitive TryFrom and TryInto. layer transitive; #[ cfg( feature = "path_utf8" ) ] own use ::camino::{ Utf8Path, Utf8PathBuf }; + + // #[ cfg( not( feature = "no_std" ) ) ] + // own use ::std::path::{ PathBuf, Path, Component }; + + #[ cfg( not( feature = "no_std" ) ) ] + own use ::std::path::*; + #[ cfg( not( feature = "no_std" ) ) ] - own use ::std::path::{ PathBuf, Path }; + own use ::std::borrow::Cow; } diff --git a/module/core/proper_path_tools/src/path.rs b/module/core/pth/src/path.rs similarity index 95% rename from module/core/proper_path_tools/src/path.rs rename to module/core/pth/src/path.rs index b11df6f466..7907a3268a 100644 --- a/module/core/proper_path_tools/src/path.rs +++ b/module/core/pth/src/path.rs @@ -2,6 +2,8 @@ mod private { + use crate::*; + #[ cfg( feature = "no_std" ) ] extern crate std; @@ -25,7 +27,7 @@ mod private /// # Examples: /// /// ``` - /// use proper_path_tools::path; + /// use pth::path; /// /// assert_eq!( path::is_glob( "file.txt" ), false ); // No glob patterns /// assert_eq!( path::is_glob( "*.txt" ), true ); // Contains unescaped glob character * @@ -110,7 +112,7 @@ mod private /// /// ``` /// use std::path::{ Path, PathBuf }; - /// use proper_path_tools::path as path; + /// use pth::path as path; /// /// let path = Path::new( "/a/b/./c/../d" ); /// let normalized_path = path::normalize( path ); @@ -260,7 +262,7 @@ mod private /// # Examples /// /// ``` - /// use proper_path_tools::path::unique_folder_name; + /// use pth::path::unique_folder_name; /// let folder_name = unique_folder_name().unwrap(); /// println!( "Generated folder name: {}", folder_name ); /// ``` @@ -299,6 +301,7 @@ mod private Ok( std::format!( "{}_{}_{}_{}", timestamp, pid, tid, count ) ) } + /// Joins a list of file system paths into a single absolute path. /// /// This function takes a list of file system paths and joins them into a single path, @@ -308,23 +311,22 @@ mod private /// /// ``` /// use std::path::PathBuf; - /// use proper_path_tools::path; + /// use pth::path; /// /// let paths = vec![ PathBuf::from( "a/b/c" ), PathBuf::from( "/d/e" ), PathBuf::from( "f/g" ) ]; - /// let joined = path::join_paths( paths.iter().map( | p | p.as_path() ) ); + /// let joined = path::iter_join( paths.iter().map( | p | p.as_path() ) ); /// assert_eq!( joined, std::path::PathBuf::from( "/d/e/f/g" ) ); /// /// let paths = vec![ PathBuf::from( "" ), PathBuf::from( "a/b" ), PathBuf::from( "" ), PathBuf::from( "c" ), PathBuf::from( "" ) ]; - /// let joined = path::join_paths( paths.iter().map( | p | p.as_path() ) ); + /// let joined = path::iter_join( paths.iter().map( | p | p.as_path() ) ); /// assert_eq!( joined, std::path::PathBuf::from( PathBuf::from( "/a/b/c" ) ) ); /// /// ``` // qqq : make macro paths_join!( ... ) - pub fn join_paths< 'a, I >( paths : I ) -> std::path::PathBuf + pub fn iter_join< 'a ,I, P >( paths : I ) -> PathBuf where - // AsPath : AsRef< std::path::Path >, - // I : Iterator< Item = AsPath >, - I : Iterator< Item = &'a std::path::Path >, + I : Iterator< Item = P >, + P : TryIntoCowPath< 'a >, { #[ cfg( feature = "no_std" ) ] extern crate alloc; @@ -337,8 +339,12 @@ mod private for path in paths { - let mut path = path.to_string_lossy().replace( '\\', "/" ); - path = path.replace( ':', "" ); + // let mut path = path.to_string_lossy().replace( '\\', "/" ); + // qqq : xxx : avoid unwrap + let path = path.try_into_cow_path().unwrap().to_string_lossy().replace( '\\', "/" ); + // qqq : xxx : avoid converting to String, keep it Path + + // path = path.replace( ':', "" ); // qqq : this is a bug let mut added_slah = false; @@ -449,7 +455,7 @@ mod private /// # Examples /// /// ``` - /// use proper_path_tools::path::exts; + /// use pth::path::exts; /// /// let path = "/path/to/file.tar.gz"; /// let extensions = exts( path ); @@ -457,7 +463,7 @@ mod private /// ``` /// /// ``` - /// use proper_path_tools::path::exts; + /// use pth::path::exts; /// /// let empty_path = ""; /// let extensions = exts( empty_path ); @@ -512,7 +518,7 @@ mod private /// /// ``` /// use std::path::PathBuf; - /// use proper_path_tools::path::without_ext; + /// use pth::path::without_ext; /// /// let path = "/path/to/file.txt"; /// let modified_path = without_ext(path); @@ -521,7 +527,7 @@ mod private /// /// ``` /// use std::path::PathBuf; - /// use proper_path_tools::path::without_ext; + /// use pth::path::without_ext; /// /// let empty_path = ""; /// let modified_path = without_ext(empty_path); @@ -591,7 +597,7 @@ mod private /// /// ``` /// use std::path::PathBuf; - /// use proper_path_tools::path::change_ext; + /// use pth::path::change_ext; /// /// let path = "/path/to/file.txt"; /// let modified_path = change_ext( path, "json" ); @@ -600,7 +606,7 @@ mod private /// /// ``` /// use std::path::PathBuf; - /// use proper_path_tools::path::change_ext; + /// use pth::path::change_ext; /// /// let empty_path = ""; /// let modified_path = change_ext( empty_path, "txt" ); @@ -642,7 +648,7 @@ mod private /// # Examples /// /// ``` - /// use proper_path_tools::path::path_common; + /// use pth::path::path_common; /// /// let paths = vec![ "/a/b/c", "/a/b/d", "/a/b/e" ]; /// let common_path = path_common( paths.into_iter() ); @@ -834,7 +840,7 @@ mod private /// /// let file_path = "/home/user/documents/file.txt"; /// let new_path = "/mnt/storage"; - /// let rebased_path = proper_path_tools::path::rebase( file_path, new_path, None ).unwrap(); + /// let rebased_path = pth::path::rebase( file_path, new_path, None ).unwrap(); /// assert_eq!( rebased_path, PathBuf::from( "/mnt/storage/home/user/documents/file.txt" ) ); /// ``` /// @@ -846,7 +852,7 @@ mod private /// let file_path = "/home/user/documents/file.txt"; /// let new_path = "/mnt/storage"; /// let old_path = "/home/user"; - /// let rebased_path = proper_path_tools::path::rebase( file_path, new_path, Some( old_path ) ).unwrap(); + /// let rebased_path = pth::path::rebase( file_path, new_path, Some( old_path ) ).unwrap(); /// assert_eq!( rebased_path, PathBuf::from( "/mnt/storage/documents/file.txt" ) ); /// ``` /// @@ -900,7 +906,7 @@ mod private /// /// let from = "/a/b"; /// let to = "/a/c/d"; - /// let relative_path = proper_path_tools::path::path_relative( from, to ); + /// let relative_path = pth::path::path_relative( from, to ); /// assert_eq!( relative_path, PathBuf::from( "../c/d" ) ); /// ``` pub fn path_relative< T : AsRef< std::path::Path > >( from : T, to : T ) -> std::path::PathBuf @@ -1008,7 +1014,7 @@ mod private /// # Examples /// /// ``` - /// use proper_path_tools::path::ext; + /// use pth::path::ext; /// /// let path = "/path/to/file.txt"; /// let extension = ext( path ); @@ -1016,7 +1022,7 @@ mod private /// ``` /// /// ``` - /// use proper_path_tools::path::ext; + /// use pth::path::ext; /// /// let empty_path = ""; /// let extension = ext( empty_path ); @@ -1047,17 +1053,20 @@ mod private crate::mod_interface! { - orphan use ext; - orphan use exts; - orphan use change_ext; - orphan use path_relative; - orphan use rebase; - orphan use path_common; - orphan use join_paths; - orphan use without_ext; - orphan use is_glob; - orphan use normalize; - orphan use canonicalize; + orphan use + { + ext, + exts, + change_ext, + path_relative, + rebase, + path_common, + iter_join, + without_ext, + is_glob, + normalize, + canonicalize, + }; #[ cfg( feature = "path_unique_folder_name" ) ] orphan use unique_folder_name; @@ -1071,4 +1080,7 @@ crate::mod_interface! /// Describe native path. Use to pass path to the platfrom. layer native_path; + /// Convenient joining. + layer joining; + } diff --git a/module/core/proper_path_tools/src/path/absolute_path.rs b/module/core/pth/src/path/absolute_path.rs similarity index 54% rename from module/core/proper_path_tools/src/path/absolute_path.rs rename to module/core/pth/src/path/absolute_path.rs index ba6e37f3ba..13a9686207 100644 --- a/module/core/proper_path_tools/src/path/absolute_path.rs +++ b/module/core/pth/src/path/absolute_path.rs @@ -1,55 +1,49 @@ /// Internal namespace. mod private { - use crate::*; - use std:: { - // borrow::Cow, path::{ Path, PathBuf }, io, }; - use core:: { fmt, - ops:: - { - Deref, - DerefMut, - }, + ops::{ Deref, DerefMut }, }; - - #[ cfg( feature="no_std" ) ] + #[ cfg( feature = "no_std" ) ] extern crate std; - - #[ cfg( feature="no_std" ) ] + #[ cfg( feature = "no_std" ) ] use alloc::string::String; - #[ cfg( feature = "derive_serde" ) ] use serde::{ Serialize, Deserialize }; - #[ cfg( feature = "path_utf8" ) ] - use camino::{ Utf8Path, Utf8PathBuf }; + // #[ cfg( feature = "path_utf8" ) ] + // use camino::{ Utf8Path, Utf8PathBuf }; - /// Absolute path. + /// A new type representing an absolute path. + /// + /// The `AbsolutePath` type ensures that paths are absolute, which helps reduce issues and maintenance costs associated with relative paths. + /// Relative paths can be problematic as they introduce additional variables and complexities, making code analysis, integration, refactoring, and testing more difficult. + /// By using absolute paths, software architecture can be improved, similar to how avoiding global variables can enhance code quality. + /// It is recommended to use relative paths only at the outskirts of an application. #[ cfg_attr( feature = "derive_serde", derive( Serialize, Deserialize ) ) ] #[ derive( Debug, Default, Clone, Ord, PartialOrd, Eq, PartialEq, Hash ) ] pub struct AbsolutePath( PathBuf ); impl AbsolutePath { - - /// Returns the Path without its final component, if there is one. - /// Returns None if the path terminates in a root or prefix, or if it's the empty string. + /// Returns the parent directory as an `AbsolutePath`, if it exists. + /// + /// Returns `None` if the path terminates in a root or prefix, or if it's the empty string. #[ inline ] pub fn parent( &self ) -> Option< AbsolutePath > { self.0.parent().map( PathBuf::from ).map( AbsolutePath ) } - /// Creates an owned `AbsolutePath` with path adjoined to self. + /// Creates an owned `AbsolutePath` by joining a given path to `self`. #[ inline ] pub fn join< P >( &self, path : P ) -> AbsolutePath where @@ -58,13 +52,7 @@ mod private Self::try_from( self.0.join( path ) ).unwrap() } - // /// Converts a `AbsolutePath` to a `Cow` - // pub fn to_string_lossy( &self ) -> Cow< '_, str > - // { - // self.0.to_string_lossy() - // } - - /// Determines whether base is a prefix of self. + /// Checks if the path starts with a given base path. /// /// Only considers whole path components to match. #[ inline ] @@ -73,13 +61,52 @@ mod private self.0.starts_with( base ) } - /// Returns inner type which is PathBuf. - #[ inline( always ) ] + /// Returns the inner `PathBuf`. + #[inline(always)] pub fn inner( self ) -> PathBuf { self.0 } + /// Creates an `AbsolutePath` from an iterator over items that implement `TryIntoCowPath`. + /// + /// This function joins all path segments into a single path and attempts to convert it + /// into an `AbsolutePath`. The resulting path must be absolute. + /// + /// # Arguments + /// + /// * `iter` - An iterator over path segments. + /// + /// # Returns + /// + /// * `Ok(AbsolutePath)` if the joined path is absolute. + /// * `Err(io::Error)` if the joined path is not absolute. + pub fn from_iter< 'a, I, P >( iter : I ) -> Result< Self, io::Error > + where + I : Iterator< Item = P >, + P : TryIntoCowPath< 'a >, + { + let joined_path = iter_join( iter ); + AbsolutePath::try_from( joined_path ) + } + + /// Joins path components into a `PathBuf`. + /// + /// This function leverages the `PathJoined` trait to join multiple path components into a single `PathBuf`. + /// + /// # Arguments + /// + /// * `paths` - A tuple of path components implementing the `PathJoined` trait. + /// + /// # Returns + /// + /// * `Ok(PathBuf)` - The joined path as a `PathBuf`. + /// * `Err(io::Error)` - An error if any component fails to convert. + pub fn from_paths< Paths : PathJoined >( paths : Paths ) -> Result< Self, io::Error > + { + Self::try_from( paths.iter_join()? ) + } + } impl fmt::Display for AbsolutePath @@ -94,8 +121,6 @@ mod private #[ inline ] fn is_absolute( path : &Path ) -> bool { - // None - not absolute - // with `.` or `..` at the first component - not absolute !path.components().next().is_some_and( | c | c.as_os_str() == "." || c.as_os_str() == ".." ) } @@ -121,7 +146,6 @@ mod private } } - // xxx : qqq : use Into< Path > impl TryFrom< &Path > for AbsolutePath { type Error = std::io::Error; @@ -129,13 +153,11 @@ mod private #[ inline ] fn try_from( src : &Path ) -> Result< Self, Self::Error > { - // < Self as TryFrom< &str > >::try_from( src.to_string_lossy() ) let path = path::canonicalize( src )?; - // xxx if !is_absolute( &path ) { - return Err( io::Error::new( io::ErrorKind::InvalidData, "Path expected to be absolute, but it's not {path}" ) ) + return Err( io::Error::new( io::ErrorKind::Other, format!( "Path expected to be absolute, but it's not {path:?}" ) ) ); } Ok( Self( path ) ) @@ -153,19 +175,29 @@ mod private } } -// impl TryFrom< &str > for AbsolutePath -// { -// type Error = std::io::Error; -// // type Error = PathError; -// -// #[ inline( always ) ] -// fn try_from( src : &str ) -> Result< Self, Self::Error > -// { -// Self::try_from( AbsolutePath::try_from( src )? ) -// } -// } - - #[ cfg( feature = "path_utf8" ) ] + impl< 'a > TryFrom< &'a String > for AbsolutePath + { + type Error = std::io::Error; + + #[ inline ] + fn try_from( src : &'a String ) -> Result< Self, Self::Error > + { + < Self as TryFrom< &Path > >::try_from( src.as_ref() ) + } + } + + impl< 'a > TryFrom< String > for AbsolutePath + { + type Error = std::io::Error; + + #[ inline ] + fn try_from( src : String ) -> Result< Self, Self::Error > + { + < Self as TryFrom< &Path > >::try_from( src.as_ref() ) + } + } + + #[cfg( feature = "path_utf8" )] impl TryFrom< Utf8PathBuf > for AbsolutePath { type Error = std::io::Error; @@ -177,7 +209,7 @@ mod private } } - #[ cfg( feature = "path_utf8" ) ] + #[cfg( feature = "path_utf8" )] impl TryFrom< &Utf8PathBuf > for AbsolutePath { type Error = std::io::Error; @@ -189,7 +221,7 @@ mod private } } - #[ cfg( feature = "path_utf8" ) ] + #[cfg( feature = "path_utf8" )] impl TryFrom< &Utf8Path > for AbsolutePath { type Error = std::io::Error; @@ -213,21 +245,18 @@ mod private impl< 'a > TryFrom< &'a AbsolutePath > for &'a str { type Error = std::io::Error; + #[ inline ] fn try_from( src : &'a AbsolutePath ) -> Result< &'a str, Self::Error > { - src - .to_str() - .ok_or_else - ( - move || io::Error::new( io::ErrorKind::Other, format!( "Can't convert &PathBuf into &str {src}" ) ) - ) + src.to_str().ok_or_else( || io::Error::new( io::ErrorKind::Other, format!( "Can't convert &PathBuf into &str {src}" ) ) ) } } impl TryFrom< &AbsolutePath > for String { type Error = std::io::Error; + #[ inline ] fn try_from( src : &AbsolutePath ) -> Result< String, Self::Error > { @@ -236,34 +265,23 @@ mod private } } -// impl TryFrom< Utf8PathBuf > for AbsolutePath -// { -// type Error = std::io::Error; -// -// fn try_from( src : Utf8PathBuf ) -> Result< Self, Self::Error > -// { -// AbsolutePath::try_from( src.as_std_path() ) -// } -// } - -// impl TryFrom< &Utf8Path > for AbsolutePath -// { -// type Error = std::io::Error; -// -// fn try_from( src : &Utf8Path ) -> Result< Self, Self::Error > -// { -// AbsolutePath::try_from( src.as_std_path() ) -// } -// } - - // // xxx : use derives - // impl AsRef< Path > for AbsolutePath - // { - // fn as_ref( &self ) -> &Path - // { - // self.0.as_ref() - // } - // } + impl TryIntoPath for AbsolutePath + { + #[ inline ] + fn try_into_path( self ) -> Result< PathBuf, io::Error > + { + Ok( self.0 ) + } + } + + impl< 'a > TryIntoCowPath< 'a > for AbsolutePath + { + #[ inline ] + fn try_into_cow_path( self ) -> Result< Cow<'a, Path>, io::Error > + { + Ok( Cow::Owned( self.0 ) ) + } + } impl AsRef< Path > for AbsolutePath { @@ -286,6 +304,7 @@ mod private impl Deref for AbsolutePath { type Target = Path; + #[ inline ] fn deref( &self ) -> &Self::Target { @@ -301,42 +320,9 @@ mod private &mut self.0 } } - -// /// Convertable into absolute path entity should implement the trait. -// pub trait TryIntoAbsolutePath -// { -// /// Error returned if conversion is failed. -// type Error; -// /// Method to convert the type into absolute path. -// fn into_absolute_path( self ) -> Result< AbsolutePath, Self::Error >; -// } -// -// // impl TryIntoAbsolutePath for AbsolutePath -// // { -// // type Error = std::io::Error; -// // #[ inline ] -// // fn into_absolute_path( self ) -> Result< AbsolutePath, Self::Error > -// // { -// // Ok( self ) -// // } -// // } -// -// impl< TryIntoAbsolutePathType > TryIntoAbsolutePath for TryIntoAbsolutePathType -// where -// TryIntoAbsolutePathType : TryInto< AbsolutePath >, -// { -// type Error = < Self as TryInto< AbsolutePath > >::Error; -// #[ inline ] -// fn into_absolute_path( self ) -> Result< AbsolutePath, Self::Error > -// { -// self.try_into() -// } -// } - } crate::mod_interface! { exposed use AbsolutePath; - // exposed use TryIntoAbsolutePath; -} +} \ No newline at end of file diff --git a/module/core/proper_path_tools/src/path/canonical_path.rs b/module/core/pth/src/path/canonical_path.rs similarity index 85% rename from module/core/proper_path_tools/src/path/canonical_path.rs rename to module/core/pth/src/path/canonical_path.rs index d6c84168da..b7a871af4d 100644 --- a/module/core/proper_path_tools/src/path/canonical_path.rs +++ b/module/core/pth/src/path/canonical_path.rs @@ -21,6 +21,7 @@ mod private }, }; + // qqq : xxx : redo #[ cfg( feature="no_std" ) ] extern crate std; @@ -30,8 +31,8 @@ mod private #[ cfg( feature = "derive_serde" ) ] use serde::{ Serialize, Deserialize }; - #[ cfg( feature = "path_utf8" ) ] - use camino::{ Utf8Path, Utf8PathBuf }; + // #[ cfg( feature = "path_utf8" ) ] + // use camino::{ Utf8Path, Utf8PathBuf }; /// Caninical path. #[ cfg_attr( feature = "derive_serde", derive( Serialize, Deserialize ) ) ] @@ -114,6 +115,28 @@ mod private } } + impl< 'a > TryFrom< &'a String > for CanonicalPath + { + type Error = std::io::Error; + + #[ inline ] + fn try_from( src : &'a String ) -> Result< Self, Self::Error > + { + < Self as TryFrom< &Path > >::try_from( src.as_ref() ) + } + } + + impl< 'a > TryFrom< String > for CanonicalPath + { + type Error = std::io::Error; + + #[ inline ] + fn try_from( src : String ) -> Result< Self, Self::Error > + { + < Self as TryFrom< &Path > >::try_from( src.as_ref() ) + } + } + impl TryFrom< PathBuf > for CanonicalPath { type Error = std::io::Error; @@ -216,6 +239,32 @@ mod private } } + impl TryIntoPath for CanonicalPath + { + #[ inline ] + fn try_into_path( self ) -> Result< PathBuf, io::Error > + { + Ok( self.0 ) + } + } + + impl< 'a > TryIntoCowPath< 'a > for CanonicalPath + { + #[ inline ] + fn try_into_cow_path( self ) -> Result< Cow<'a, Path>, io::Error > + { + Ok( Cow::Owned( self.0 ) ) + } + } + + // impl AsPath for CanonicalPath + // { + // fn as_path( &self ) -> &Path + // { + // self.0.as_path() + // } + // } + // impl TryFrom< Utf8PathBuf > for CanonicalPath // { // type Error = std::io::Error; diff --git a/module/core/proper_path_tools/src/path/current_path.rs b/module/core/pth/src/path/current_path.rs similarity index 67% rename from module/core/proper_path_tools/src/path/current_path.rs rename to module/core/pth/src/path/current_path.rs index a35c927c0f..cc5fe4aaaa 100644 --- a/module/core/proper_path_tools/src/path/current_path.rs +++ b/module/core/pth/src/path/current_path.rs @@ -4,7 +4,11 @@ mod private use crate::*; #[ cfg( not( feature = "no_std" ) ) ] - use std::env; + use std:: + { + env, + io, + }; /// Symbolize current path. #[ derive( Clone, Copy, Debug, Default, PartialEq, Eq ) ] @@ -48,7 +52,7 @@ mod private env::current_dir() } } - + #[ cfg( not( feature = "no_std" ) ) ] impl TryFrom< CurrentPath > for AbsolutePath { @@ -62,6 +66,39 @@ mod private } } + impl TryIntoPath for &CurrentPath + { + fn try_into_path( self ) -> Result< PathBuf, io::Error > + { + env::current_dir() + } + } + + impl TryIntoPath for CurrentPath + { + fn try_into_path( self ) -> Result< PathBuf, io::Error > + { + env::current_dir() + } + } + + impl< 'a > TryIntoCowPath< 'a > for CurrentPath + { + fn try_into_cow_path( self ) -> Result< Cow<'a, Path>, io::Error > + { + let current_dir = env::current_dir()?; + Ok( Cow::Owned( current_dir ) ) + } + } + + impl< 'a > TryIntoCowPath< 'a > for &CurrentPath + { + fn try_into_cow_path( self ) -> Result< Cow<'a, Path>, io::Error > + { + TryIntoCowPath::try_into_cow_path( *self ) + } + } + } crate::mod_interface! diff --git a/module/core/pth/src/path/joining.rs b/module/core/pth/src/path/joining.rs new file mode 100644 index 0000000000..6e8c0a1ddf --- /dev/null +++ b/module/core/pth/src/path/joining.rs @@ -0,0 +1,191 @@ +mod private +{ + use crate::*; + use std::{ io, path::PathBuf }; + + /// Joins path components into a `PathBuf`. + /// + /// This function leverages the `PathJoined` trait to join multiple path components into a single `PathBuf`. + /// + /// # Arguments + /// + /// * `paths` - A tuple of path components implementing the `PathJoined` trait. + /// + /// # Returns + /// + /// * `Ok(PathBuf)` - The joined path as a `PathBuf`. + /// * `Err(io::Error)` - An error if any component fails to convert. + pub fn join< Paths : PathJoined >( paths : Paths ) -> Result< PathBuf, io::Error > + { + paths.iter_join() + } + + /// A trait for joining path components into a `PathBuf`. + /// + /// This trait provides a method to join multiple path components into a single `PathBuf`. + /// It is implemented for tuples of varying lengths, allowing for flexible combinations of path components. + /// Each component must implement the `TryIntoCowPath` trait, enabling conversion into a `Cow`. + pub trait PathJoined + { + /// Joins the path components into a single `PathBuf`. + /// + /// # Returns + /// + /// * `Ok(PathBuf)` - The joined path as a `PathBuf`. + /// * `Err(io::Error)` - An error if any component fails to convert. + fn iter_join( self ) -> Result< PathBuf, io::Error >; + } + + // // Implementation for an Iterator over items implementing TryIntoCowPath + // impl< 'a, I, T > PathJoined for I + // where + // I : Iterator< Item = T >, + // T : TryIntoCowPath< 'a >, + // { + // fn iter_join( self ) -> Result< PathBuf, io::Error > + // { + // let mut result = PathBuf::new(); + // for item in self + // { + // result.push( item.try_into_cow_path()?.as_ref() ); + // } + // Ok( result ) + // } + // } + + // Implementation for a tuple of length 1 + impl< 'a, T1 > PathJoined for ( T1, ) + where + T1 : TryIntoCowPath< 'a >, + { + #[ inline ] + fn iter_join( self ) -> Result< PathBuf, io::Error > + { + let ( p1, ) = self; + let mut result = PathBuf::new(); + result.push( p1.try_into_cow_path()?.as_ref() ); + Ok( result ) + } + } + + // Implementation for a tuple of length 2 + impl< 'a, T1, T2 > PathJoined for ( T1, T2 ) + where + T1 : TryIntoCowPath< 'a >, + T2 : TryIntoCowPath< 'a >, + { + #[ inline ] + fn iter_join( self ) -> Result< PathBuf, io::Error > + { + let ( p1, p2 ) = self; + let mut result = PathBuf::new(); + result.push( p1.try_into_cow_path()?.as_ref() ); + result.push( p2.try_into_cow_path()?.as_ref() ); + Ok( result ) + } + } + + // Implementation for a tuple of length 3 + impl< 'a, T1, T2, T3 > PathJoined for ( T1, T2, T3 ) + where + T1 : TryIntoCowPath< 'a >, + T2 : TryIntoCowPath< 'a >, + T3 : TryIntoCowPath< 'a >, + { + #[ inline ] + fn iter_join( self ) -> Result< PathBuf, io::Error > + { + let ( p1, p2, p3 ) = self; + let mut result = PathBuf::new(); + result.push( p1.try_into_cow_path()?.as_ref() ); + result.push( p2.try_into_cow_path()?.as_ref() ); + result.push( p3.try_into_cow_path()?.as_ref() ); + Ok( result ) + } + } + + // Implementation for a tuple of length 4 + impl< 'a, T1, T2, T3, T4 > PathJoined for ( T1, T2, T3, T4 ) + where + T1 : TryIntoCowPath< 'a >, + T2 : TryIntoCowPath< 'a >, + T3 : TryIntoCowPath< 'a >, + T4 : TryIntoCowPath< 'a >, + { + #[ inline ] + fn iter_join( self ) -> Result< PathBuf, io::Error > + { + let ( p1, p2, p3, p4 ) = self; + let mut result = PathBuf::new(); + result.push( p1.try_into_cow_path()?.as_ref() ); + result.push( p2.try_into_cow_path()?.as_ref() ); + result.push( p3.try_into_cow_path()?.as_ref() ); + result.push( p4.try_into_cow_path()?.as_ref() ); + Ok( result ) + } + } + + // Implementation for a tuple of length 5 + impl< 'a, T1, T2, T3, T4, T5 > PathJoined for ( T1, T2, T3, T4, T5 ) + where + T1 : TryIntoCowPath< 'a >, + T2 : TryIntoCowPath< 'a >, + T3 : TryIntoCowPath< 'a >, + T4 : TryIntoCowPath< 'a >, + T5 : TryIntoCowPath< 'a >, + { + #[ inline ] + fn iter_join( self ) -> Result< PathBuf, io::Error > + { + let ( p1, p2, p3, p4, p5 ) = self; + let mut result = PathBuf::new(); + result.push( p1.try_into_cow_path()?.as_ref() ); + result.push( p2.try_into_cow_path()?.as_ref() ); + result.push( p3.try_into_cow_path()?.as_ref() ); + result.push( p4.try_into_cow_path()?.as_ref() ); + result.push( p5.try_into_cow_path()?.as_ref() ); + Ok( result ) + } + } + + // Implementation for slices + impl< 'a, T > PathJoined for &'a [ T ] + where + T : TryIntoCowPath< 'a > + Clone, + { + #[ inline ] + fn iter_join( self ) -> Result< PathBuf, io::Error > + { + let mut result = PathBuf::new(); + for item in self + { + result.push( item.clone().try_into_cow_path()?.as_ref() ); + } + Ok( result ) + } + } + + // Implementation for arrays + impl< 'a, T, const N : usize > PathJoined for [ T; N ] + where + T : TryIntoCowPath< 'a > + Clone, + { + #[ inline ] + fn iter_join( self ) -> Result< PathBuf, io::Error > + { + let mut result = PathBuf::new(); + for item in &self + { + result.push( item.clone().try_into_cow_path()?.as_ref() ); + } + Ok( result ) + } + } + +} + +crate::mod_interface! +{ + orphan use join; + exposed use PathJoined; +} diff --git a/module/core/proper_path_tools/src/path/native_path.rs b/module/core/pth/src/path/native_path.rs similarity index 86% rename from module/core/proper_path_tools/src/path/native_path.rs rename to module/core/pth/src/path/native_path.rs index d41b449acc..09dfaaed62 100644 --- a/module/core/proper_path_tools/src/path/native_path.rs +++ b/module/core/pth/src/path/native_path.rs @@ -30,8 +30,8 @@ mod private #[ cfg( feature = "derive_serde" ) ] use serde::{ Serialize, Deserialize }; - #[ cfg( feature = "path_utf8" ) ] - use camino::{ Utf8Path, Utf8PathBuf }; + // #[ cfg( feature = "path_utf8" ) ] + // use camino::{ Utf8Path, Utf8PathBuf }; /// Caninical path. #[ cfg_attr( feature = "derive_serde", derive( Serialize, Deserialize ) ) ] @@ -114,6 +114,28 @@ mod private } } + impl< 'a > TryFrom< &'a String > for NativePath + { + type Error = std::io::Error; + + #[ inline ] + fn try_from( src : &'a String ) -> Result< Self, Self::Error > + { + < Self as TryFrom< &Path > >::try_from( src.as_ref() ) + } + } + + impl< 'a > TryFrom< String > for NativePath + { + type Error = std::io::Error; + + #[ inline ] + fn try_from( src : String ) -> Result< Self, Self::Error > + { + < Self as TryFrom< &Path > >::try_from( src.as_ref() ) + } + } + impl TryFrom< PathBuf > for NativePath { type Error = std::io::Error; @@ -231,6 +253,32 @@ mod private } } + impl TryIntoPath for NativePath + { + #[ inline ] + fn try_into_path( self ) -> Result< PathBuf, io::Error > + { + Ok( self.0 ) + } + } + + impl< 'a > TryIntoCowPath< 'a > for NativePath + { + #[ inline ] + fn try_into_cow_path( self ) -> Result< Cow<'a, Path>, io::Error > + { + Ok( Cow::Owned( self.0 ) ) + } + } + + // impl AsPath for NativePath + // { + // fn as_path( &self ) -> &Path + // { + // self.0.as_path() + // } + // } + // impl TryFrom< Utf8PathBuf > for NativePath // { // type Error = std::io::Error; diff --git a/module/core/proper_path_tools/src/transitive.rs b/module/core/pth/src/transitive.rs similarity index 98% rename from module/core/proper_path_tools/src/transitive.rs rename to module/core/pth/src/transitive.rs index 9de7eef34b..93bbcd3e10 100644 --- a/module/core/proper_path_tools/src/transitive.rs +++ b/module/core/pth/src/transitive.rs @@ -49,7 +49,7 @@ mod private /// # Example /// /// ```rust - /// use proper_path_tools::TransitiveTryFrom; + /// use pth::TransitiveTryFrom; /// use std::convert::TryFrom; /// /// struct InitialType; @@ -132,7 +132,7 @@ mod private /// # Example /// /// ```rust - /// use proper_path_tools::TransitiveTryInto; + /// use pth::TransitiveTryInto; /// use std::convert::TryInto; /// /// struct InitialType; diff --git a/module/core/pth/src/try_into_cow_path.rs b/module/core/pth/src/try_into_cow_path.rs new file mode 100644 index 0000000000..b9f04524ce --- /dev/null +++ b/module/core/pth/src/try_into_cow_path.rs @@ -0,0 +1,111 @@ +/// Internal namespace. +mod private +{ + use crate::*; + use std:: + { + borrow::Cow, + io, + path::{ Component, Path, PathBuf }, + }; + // use camino::{ Utf8Path, Utf8PathBuf }; + + /// A trait for converting various types into a `Cow`. + /// + /// This trait is designed to avoid redundant memory allocation. + /// Unlike `TryIntoPath`, it does not allocate memory on the heap if it's not necessary. + /// Unlike `AsPath`, it is implemented for a wider number of path-like types, similar to `TryIntoPath`. + /// The drawback is the necessity to differentiate borrowed and owned paths at runtime. + pub trait TryIntoCowPath<'a> + { + /// Converts the implementing type into a `Cow`. + /// + /// # Returns + /// + /// * `Ok(Cow)` - A `Cow` that may be either borrowed or owned, depending on the input type. + /// * `Err(io::Error)` - An error if the conversion fails. + fn try_into_cow_path( self ) -> Result< Cow<'a, Path>, io::Error >; + } + + /// Implementation of `TryIntoCowPath` for `String`. + impl<'a> TryIntoCowPath<'a> for &'a str + { + fn try_into_cow_path( self ) -> Result< Cow<'a, Path>, io::Error > + { + Ok( Cow::Borrowed( self.as_path() ) ) + } + } + + /// Implementation of `TryIntoCowPath` for `String`. + impl<'a> TryIntoCowPath<'a> for String + { + fn try_into_cow_path( self ) -> Result< Cow<'a, Path>, io::Error > + { + Ok( Cow::Owned( PathBuf::from( self ) ) ) + } + } + + /// Implementation of `TryIntoCowPath` for `PathBuf`. + impl<'a> TryIntoCowPath<'a> for PathBuf + { + fn try_into_cow_path( self ) -> Result< Cow<'a, Path>, io::Error > + { + Ok( Cow::Owned( self ) ) + } + } + + /// Implementation of `TryIntoCowPath` for a reference to `Path`. + impl<'a> TryIntoCowPath<'a> for &'a Path + { + fn try_into_cow_path( self ) -> Result< Cow<'a, Path>, io::Error > + { + Ok( Cow::Borrowed( self ) ) + } + } + + /// Implementation of `TryIntoCowPath` for a reference to `Utf8Path`. + #[cfg( feature = "path_utf8" )] + impl< 'a > TryIntoCowPath< 'a > for &'a Utf8Path + { + fn try_into_cow_path( self ) -> Result< Cow<'a, Path>, io::Error > + { + Ok( Cow::Borrowed( self.as_std_path() ) ) + } + } + + /// Implementation of `TryIntoCowPath` for `Utf8PathBuf`. + #[cfg( feature = "path_utf8" )] + impl<'a> TryIntoCowPath<'a> for Utf8PathBuf + { + fn try_into_cow_path( self ) -> Result< Cow<'a, Path>, io::Error > + { + Ok( Cow::Owned( self.as_std_path().to_path_buf() ) ) + } + } + + /// Implementation of `TryIntoCowPath` for `std::path::Component`. + impl<'a> TryIntoCowPath<'a> for Component<'a> + { + fn try_into_cow_path( self ) -> Result< Cow<'a, Path>, io::Error > + { + Ok( Cow::Owned( PathBuf::from( self.as_os_str() ) ) ) + } + } + + /// Blanket implementation of `TryIntoCowPath` for references to types implementing `AsPath`. + impl<'a, T> TryIntoCowPath< 'a > for &'a T + where + T : AsPath, + { + fn try_into_cow_path( self ) -> Result< Cow<'a, Path>, io::Error > + { + Ok( Cow::Borrowed( self.as_path() ) ) + } + } + +} + +crate::mod_interface! +{ + orphan use TryIntoCowPath; +} \ No newline at end of file diff --git a/module/core/pth/src/try_into_path.rs b/module/core/pth/src/try_into_path.rs new file mode 100644 index 0000000000..29f508ec1b --- /dev/null +++ b/module/core/pth/src/try_into_path.rs @@ -0,0 +1,109 @@ +/// Internal namespace. +mod private +{ + #[ allow( unused_imports ) ] + use crate::*; + use std:: + { + io, + path::{ Component, Path, PathBuf }, + }; + // use camino::{ Utf8Path, Utf8PathBuf }; + + /// A trait for converting various types into a `PathBuf`. + /// + /// This trait is used to convert any path-like type into an owned `PathBuf`. + /// Unlike `TryIntoCowPath`, it always returns an owned `PathBuf`, so there is no need to differentiate between borrowed and owned paths at runtime. + /// Unlike `AsPath`, it is implemented for a wider range of path-like types, similar to `TryIntoCowPath`. + pub trait TryIntoPath + { + /// Converts the implementing type into a `PathBuf`. + /// + /// # Returns + /// + /// * `Ok(PathBuf)` - The owned path buffer. + /// * `Err(io::Error)` - An error if the conversion fails. + fn try_into_path( self ) -> Result< PathBuf, io::Error >; + } + + /// Implementation of `TryIntoPath` for `&str`. + impl TryIntoPath for &str + { + fn try_into_path( self ) -> Result< PathBuf, io::Error > + { + Ok( PathBuf::from( self ) ) + } + } + + /// Implementation of `TryIntoPath` for `String`. + impl TryIntoPath for String + { + fn try_into_path( self ) -> Result< PathBuf, io::Error > + { + Ok( PathBuf::from( self ) ) + } + } + + /// Implementation of `TryIntoPath` for a reference to `Path`. + impl TryIntoPath for &Path + { + fn try_into_path( self ) -> Result< PathBuf, io::Error > + { + Ok( self.to_path_buf() ) + } + } + + /// Implementation of `TryIntoPath` for `PathBuf`. + impl TryIntoPath for PathBuf + { + fn try_into_path( self ) -> Result< PathBuf, io::Error > + { + Ok( self ) + } + } + + /// Implementation of `TryIntoPath` for a reference to `Utf8Path`. + #[cfg( feature = "path_utf8" )] + impl TryIntoPath for &Utf8Path + { + fn try_into_path( self ) -> Result< PathBuf, io::Error > + { + Ok( self.as_std_path().to_path_buf() ) + } + } + + /// Implementation of `TryIntoPath` for `Utf8PathBuf`. + #[cfg( feature = "path_utf8" )] + impl TryIntoPath for Utf8PathBuf + { + fn try_into_path( self ) -> Result< PathBuf, io::Error > + { + Ok( self.as_std_path().to_path_buf() ) + } + } + + /// Implementation of `TryIntoPath` for `std::path::Component`. + impl TryIntoPath for Component<'_> + { + fn try_into_path( self ) -> Result< PathBuf, io::Error > + { + Ok( self.as_os_str().into() ) + } + } + + /// Blanket implementation of `TryIntoPath` for references to types implementing `AsRef`. + impl< T > TryIntoPath for &T + where + T : AsRef< Path >, + { + fn try_into_path( self ) -> Result< PathBuf, io::Error > + { + Ok( self.as_ref().to_path_buf() ) + } + } +} + +crate::mod_interface! +{ + orphan use TryIntoPath; +} \ No newline at end of file diff --git a/module/core/proper_path_tools/tests/experiment.rs b/module/core/pth/tests/experiment.rs similarity index 94% rename from module/core/proper_path_tools/tests/experiment.rs rename to module/core/pth/tests/experiment.rs index 29e2cd3eba..60e36f8879 100644 --- a/module/core/proper_path_tools/tests/experiment.rs +++ b/module/core/pth/tests/experiment.rs @@ -2,7 +2,7 @@ include!( "../../../../module/step/meta/src/module/terminal.rs" ); #[ allow( unused_imports ) ] -use proper_path_tools as the_module; +use pth as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/pth/tests/inc/absolute_path_test.rs b/module/core/pth/tests/inc/absolute_path_test.rs new file mode 100644 index 0000000000..6d15a1fb2b --- /dev/null +++ b/module/core/pth/tests/inc/absolute_path_test.rs @@ -0,0 +1,5 @@ +use super::*; + +mod basic_test; +mod from_paths_test; +mod try_from_test; diff --git a/module/core/proper_path_tools/tests/inc/absolute_path.rs b/module/core/pth/tests/inc/absolute_path_test/basic_test.rs similarity index 93% rename from module/core/proper_path_tools/tests/inc/absolute_path.rs rename to module/core/pth/tests/inc/absolute_path_test/basic_test.rs index 94e4ff2ab2..3f8a254ba0 100644 --- a/module/core/proper_path_tools/tests/inc/absolute_path.rs +++ b/module/core/pth/tests/inc/absolute_path_test/basic_test.rs @@ -1,7 +1,5 @@ -#[ allow( unused_imports ) ] use super::*; -#[ cfg( not( feature="no_std" ) ) ] use the_module:: { AbsolutePath, @@ -9,12 +7,6 @@ use the_module:: PathBuf, }; -#[ cfg( feature="no_std" ) ] -use crate::the_module::AbsolutePath; - -// #[ cfg( feature = "path_utf8" ) ] -// use the_module::Utf8PathBuf; - #[ test ] fn basic() { @@ -75,7 +67,6 @@ fn test_join() assert_eq!( joined_path.to_string_lossy(), "/path/to/some/file.txt" ); } - #[test] fn test_relative_path_try_from_str() { diff --git a/module/core/pth/tests/inc/absolute_path_test/from_paths_test.rs b/module/core/pth/tests/inc/absolute_path_test/from_paths_test.rs new file mode 100644 index 0000000000..3e5bd05dd4 --- /dev/null +++ b/module/core/pth/tests/inc/absolute_path_test/from_paths_test.rs @@ -0,0 +1,92 @@ +use super::*; + +// xxx : make it working + +#[ test ] +fn test_from_paths_single_absolute_segment() +{ + use the_module::AbsolutePath; + use std::convert::TryFrom; + + let segments = vec![ "/single" ]; + let got = AbsolutePath::from_iter( segments.iter().map( |s| *s ) ).unwrap(); + let exp = AbsolutePath::try_from( "/single" ).unwrap(); + + assert_eq!( got, exp ); +} + +#[ test ] +fn test_from_paths_multiple_segments() +{ + use the_module::AbsolutePath; + use std::convert::TryFrom; + + let segments = vec![ "/path", "to", "file" ]; + let got = AbsolutePath::from_iter( segments.iter().map( |s| *s ) ).unwrap(); + let exp = AbsolutePath::try_from( "/path/to/file" ).unwrap(); + + assert_eq!( got, exp ); +} + +#[ test ] +fn test_from_paths_empty_segments() +{ + use the_module::AbsolutePath; + + let segments : Vec< &str > = vec![]; + let result = AbsolutePath::from_iter( segments.iter().map( | s | *s ) ); + + assert!( result.is_err(), "Expected an error for empty segments" ); +} + +#[ test ] +fn test_from_paths_with_dot_segments() +{ + use the_module::AbsolutePath; + use std::convert::TryFrom; + + let segments = vec![ "/path", ".", "to", "file" ]; + let got = AbsolutePath::from_iter( segments.iter().map( |s| *s ) ).unwrap(); + let exp = AbsolutePath::try_from( "/path/to/file" ).unwrap(); + + assert_eq!( got, exp ); +} + +#[ test ] +fn test_from_paths_with_dotdot_segments() +{ + use the_module::AbsolutePath; + use std::convert::TryFrom; + + let segments = vec![ "/path", "to", "..", "file" ]; + let got = AbsolutePath::from_iter( segments.iter().map( |s| *s ) ).unwrap(); + let exp = AbsolutePath::try_from( "/path/file" ).unwrap(); + + assert_eq!( got, exp ); +} + +#[ test ] +fn test_from_paths_with_trailing_slash() +{ + use the_module::AbsolutePath; + use std::convert::TryFrom; + + let segments = vec![ "/path", "to", "file/" ]; + let got = AbsolutePath::from_iter( segments.iter().map( |s| *s ) ).unwrap(); + let exp = AbsolutePath::try_from( "/path/to/file/" ).unwrap(); + + assert_eq!( got, exp ); +} + +#[ test ] +fn test_from_paths_with_mixed_slashes() +{ + use the_module::AbsolutePath; + use std::convert::TryFrom; + + let segments = vec![ "/path\\to", "file" ]; + let got = AbsolutePath::from_iter( segments.iter().map( |s| *s ) ).unwrap(); + let exp = AbsolutePath::try_from( "/path/to/file" ).unwrap(); + + assert_eq!( got, exp ); +} diff --git a/module/core/pth/tests/inc/absolute_path_test/try_from_test.rs b/module/core/pth/tests/inc/absolute_path_test/try_from_test.rs new file mode 100644 index 0000000000..ee1aa2b3a1 --- /dev/null +++ b/module/core/pth/tests/inc/absolute_path_test/try_from_test.rs @@ -0,0 +1,55 @@ +use super::*; +use std::convert::TryFrom; + +#[ test ] +fn try_from_absolute_path_test() +{ + use std::path::{ Path, PathBuf }; + use the_module::AbsolutePath; + + // Create an AbsolutePath instance + let absolute_path = AbsolutePath::try_from( "/absolute/path" ).unwrap(); + + // Test conversion to &str + let path_str : &str = TryFrom::try_from( &absolute_path ).unwrap(); + println!( "&str from AbsolutePath: {:?}", path_str ); + assert_eq!( path_str, "/absolute/path" ); + + // Test conversion to String + let path_string : String = TryFrom::try_from( &absolute_path ).unwrap(); + println!( "String from AbsolutePath: {:?}", path_string ); + assert_eq!( path_string, "/absolute/path" ); + + // Test conversion to PathBuf + let path_buf : PathBuf = TryFrom::try_from( absolute_path.clone() ).unwrap(); + println!( "PathBuf from AbsolutePath: {:?}", path_buf ); + assert_eq!( path_buf, PathBuf::from( "/absolute/path" ) ); + + // Test conversion to &Path + let path_ref : &Path = absolute_path.as_ref(); + println!( "&Path from AbsolutePath: {:?}", path_ref ); + assert_eq!( path_ref, Path::new( "/absolute/path" ) ); + + // Test conversion from &String + let string_path : String = String::from( "/absolute/path" ); + let absolute_path_from_string : AbsolutePath = TryFrom::try_from( &string_path ).unwrap(); + println!( "AbsolutePath from &String: {:?}", absolute_path_from_string ); + assert_eq!( absolute_path_from_string, absolute_path ); + + // Test conversion from String + let absolute_path_from_owned_string : AbsolutePath = TryFrom::try_from( string_path.clone() ).unwrap(); + println!( "AbsolutePath from String: {:?}", absolute_path_from_owned_string ); + assert_eq!( absolute_path_from_owned_string, absolute_path ); + + // Test conversion from &Path + let path_ref : &Path = Path::new( "/absolute/path" ); + let absolute_path_from_path_ref : AbsolutePath = TryFrom::try_from( path_ref ).unwrap(); + println!( "AbsolutePath from &Path: {:?}", absolute_path_from_path_ref ); + assert_eq!( absolute_path_from_path_ref, absolute_path ); + + // Test conversion from PathBuf + let path_buf_instance : PathBuf = PathBuf::from( "/absolute/path" ); + let absolute_path_from_path_buf : AbsolutePath = TryFrom::try_from( path_buf_instance.clone() ).unwrap(); + println!( "AbsolutePath from PathBuf: {:?}", absolute_path_from_path_buf ); + assert_eq!( absolute_path_from_path_buf, absolute_path ); +} \ No newline at end of file diff --git a/module/core/pth/tests/inc/as_path_test.rs b/module/core/pth/tests/inc/as_path_test.rs new file mode 100644 index 0000000000..340a6540ca --- /dev/null +++ b/module/core/pth/tests/inc/as_path_test.rs @@ -0,0 +1,103 @@ +use super::*; + +#[ test ] +fn as_path_test() +{ + use std::path::{ Component, Path, PathBuf }; + #[ cfg( feature = "path_utf8" ) ] + use the_module::{ Utf8Path, Utf8PathBuf }; + use the_module::{ AsPath, AbsolutePath, CanonicalPath, NativePath, CurrentPath }; + + // Test with &str + let path_str : &str = "/some/path"; + let path : &Path = AsPath::as_path( path_str ); + println!( "Path from &str: {:?}", path ); + + // Test with &String + let string_path : String = String::from( "/another/path" ); + let path : &Path = AsPath::as_path( &string_path ); + println!( "Path from &String: {:?}", path ); + + // Test with String + let path : &Path = AsPath::as_path( &string_path ); + println!( "Path from String: {:?}", path ); + + // Test with &Path + let path_ref : &Path = Path::new( "/yet/another/path" ); + let path : &Path = AsPath::as_path( path_ref ); + println!( "Path from &Path: {:?}", path ); + + // Test with &PathBuf + let path_buf : PathBuf = PathBuf::from( "/yet/another/path" ); + let path : &Path = AsPath::as_path( &path_buf ); + println!( "Path from &PathBuf: {:?}", path ); + + // Test with PathBuf + let path : &Path = AsPath::as_path( &path_buf ); + println!( "Path from PathBuf: {:?}", path ); + + // Test with &AbsolutePath + let absolute_path : AbsolutePath = AbsolutePath::try_from( "/absolute/path" ).unwrap(); + let path : &Path = AsPath::as_path( &absolute_path ); + println!( "Path from &AbsolutePath: {:?}", path ); + + // Test with AbsolutePath + let path : &Path = AsPath::as_path( &absolute_path ); + println!( "Path from AbsolutePath: {:?}", path ); + + // Test with &CanonicalPath + let canonical_path = CanonicalPath::try_from( "/canonical/path" ).unwrap(); + let path : &Path = AsPath::as_path( &canonical_path ); + println!( "Path from &CanonicalPath: {:?}", path ); + + // Test with CanonicalPath + let path : &Path = AsPath::as_path( &canonical_path ); + println!( "Path from CanonicalPath: {:?}", path ); + + // Test with &NativePath + let native_path = NativePath::try_from( PathBuf::from( "/native/path" ) ).unwrap(); + let path : &Path = AsPath::as_path( &native_path ); + println!( "Path from &NativePath: {:?}", path ); + + // Test with NativePath + let path : &Path = AsPath::as_path( &native_path ); + println!( "Path from NativePath: {:?}", path ); + + // Test with &Component + let root_component : Component< '_ > = Component::RootDir; + let path : &Path = AsPath::as_path( &root_component ); + println!( "Path from &Component: {:?}", path ); + + // Test with Component + let path : &Path = AsPath::as_path( &root_component ); + println!( "Path from Component: {:?}", path ); + + // Test with Component + let path = Path::new( "/component/path" ); + for component in path.components() + { + let path : &Path = AsPath::as_path( &component ); + println!( "Path from Component: {:?}", path ); + } + + #[ cfg( feature = "path_utf8" ) ] + { + // Test with &Utf8Path + let utf8_path = Utf8Path::new( "/utf8/path" ); + let path : &Path = AsPath::as_path( &utf8_path ); + println!( "Path from &Utf8Path: {:?}", path ); + + // Test with Utf8Path + let path : &Path = AsPath::as_path( &utf8_path ); + println!( "Path from Utf8Path: {:?}", path ); + + // Test with &Utf8PathBuf + let utf8_path_buf = Utf8PathBuf::from( "/utf8/pathbuf" ); + let path : &Path = AsPath::as_path( &utf8_path_buf ); + println!( "Path from &Utf8PathBuf: {:?}", path ); + + // Test with Utf8PathBuf + let path : &Path = AsPath::as_path( &utf8_path_buf ); + println!( "Path from Utf8PathBuf: {:?}", path ); + } +} diff --git a/module/core/proper_path_tools/tests/inc/current_path.rs b/module/core/pth/tests/inc/current_path.rs similarity index 100% rename from module/core/proper_path_tools/tests/inc/current_path.rs rename to module/core/pth/tests/inc/current_path.rs diff --git a/module/core/proper_path_tools/tests/inc/mod.rs b/module/core/pth/tests/inc/mod.rs similarity index 57% rename from module/core/proper_path_tools/tests/inc/mod.rs rename to module/core/pth/tests/inc/mod.rs index 58e8721710..8026b293ba 100644 --- a/module/core/proper_path_tools/tests/inc/mod.rs +++ b/module/core/pth/tests/inc/mod.rs @@ -1,8 +1,14 @@ -#[allow(unused_imports)] use super::*; -mod absolute_path; +mod as_path_test; +mod try_into_path_test; +mod try_into_cow_path_test; + +mod absolute_path_test; +mod path_join_fn_test; +mod path_join_trait_test; + mod current_path; mod path_canonicalize; mod path_change_ext; @@ -10,12 +16,11 @@ mod path_common; mod path_ext; mod path_exts; mod path_is_glob; -mod path_join; mod path_normalize; mod path_relative; mod rebase_path; mod transitive; mod without_ext; -#[cfg(feature = "path_unique_folder_name")] +#[ cfg( feature = "path_unique_folder_name" ) ] mod path_unique_folder_name; diff --git a/module/core/proper_path_tools/tests/inc/path_canonicalize.rs b/module/core/pth/tests/inc/path_canonicalize.rs similarity index 71% rename from module/core/proper_path_tools/tests/inc/path_canonicalize.rs rename to module/core/pth/tests/inc/path_canonicalize.rs index 9e0c5c10e0..ae94013a4c 100644 --- a/module/core/proper_path_tools/tests/inc/path_canonicalize.rs +++ b/module/core/pth/tests/inc/path_canonicalize.rs @@ -7,10 +7,10 @@ use the_module::path; fn assumptions() { - assert_eq!( PathBuf::from( "c:/src/" ).is_absolute(), false ); - assert_eq!( PathBuf::from( "/c/src/" ).is_absolute(), true ); - assert_eq!( PathBuf::from( "/c:/src/" ).is_absolute(), true ); - assert_eq!( PathBuf::from( "/c/src/" ).is_absolute(), true ); + // assert_eq!( PathBuf::from( "c:/src/" ).is_absolute(), false ); // qqq : xxx : this assumption is false on linux + // assert_eq!( PathBuf::from( "/c/src/" ).is_absolute(), true ); // qqq : xxx : this assumption is false, seems + // assert_eq!( PathBuf::from( "/c:/src/" ).is_absolute(), true ); // qqq : xxx : this assumption is false, too + // assert_eq!( PathBuf::from( "/c/src/" ).is_absolute(), true ); // qqq : xxx : this assumption is false, too } diff --git a/module/core/proper_path_tools/tests/inc/path_change_ext.rs b/module/core/pth/tests/inc/path_change_ext.rs similarity index 100% rename from module/core/proper_path_tools/tests/inc/path_change_ext.rs rename to module/core/pth/tests/inc/path_change_ext.rs diff --git a/module/core/proper_path_tools/tests/inc/path_common.rs b/module/core/pth/tests/inc/path_common.rs similarity index 100% rename from module/core/proper_path_tools/tests/inc/path_common.rs rename to module/core/pth/tests/inc/path_common.rs diff --git a/module/core/proper_path_tools/tests/inc/path_ext.rs b/module/core/pth/tests/inc/path_ext.rs similarity index 100% rename from module/core/proper_path_tools/tests/inc/path_ext.rs rename to module/core/pth/tests/inc/path_ext.rs diff --git a/module/core/proper_path_tools/tests/inc/path_exts.rs b/module/core/pth/tests/inc/path_exts.rs similarity index 100% rename from module/core/proper_path_tools/tests/inc/path_exts.rs rename to module/core/pth/tests/inc/path_exts.rs diff --git a/module/core/proper_path_tools/tests/inc/path_is_glob.rs b/module/core/pth/tests/inc/path_is_glob.rs similarity index 100% rename from module/core/proper_path_tools/tests/inc/path_is_glob.rs rename to module/core/pth/tests/inc/path_is_glob.rs diff --git a/module/core/proper_path_tools/tests/inc/path_join.rs b/module/core/pth/tests/inc/path_join_fn_test.rs similarity index 76% rename from module/core/proper_path_tools/tests/inc/path_join.rs rename to module/core/pth/tests/inc/path_join_fn_test.rs index fa526ee19d..f5a2acd005 100644 --- a/module/core/proper_path_tools/tests/inc/path_join.rs +++ b/module/core/pth/tests/inc/path_join_fn_test.rs @@ -5,7 +5,7 @@ use std::path::PathBuf; fn join_empty() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "".into(), vec![ "".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -21,7 +21,7 @@ fn join_empty() fn join_several_empties() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "".into(), vec![ "".into(), "".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -37,7 +37,7 @@ fn join_several_empties() fn root_with_absolute() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/a/b".into(), vec![ "/".into(), "/a/b".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -53,7 +53,7 @@ fn root_with_absolute() fn root_with_relative() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/a/b".into(), vec![ "/".into(), "a/b".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -69,7 +69,7 @@ fn root_with_relative() fn dir_with_absolute() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/a/b".into(), vec![ "/dir".into(), "/a/b".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -85,7 +85,7 @@ fn dir_with_absolute() fn dir_with_relative() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/dir/a/b".into(), vec![ "/dir".into(), "a/b".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -101,7 +101,7 @@ fn dir_with_relative() fn trailed_dir_with_absolute() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/a/b".into(), vec![ "/dir/".into(), "/a/b".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -117,7 +117,7 @@ fn trailed_dir_with_absolute() fn trailed_dir_with_relative() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/dir/a/b".into(), vec![ "/dir/".into(), "a/b".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -133,7 +133,7 @@ fn trailed_dir_with_relative() fn dir_with_down() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/a/b".into(), vec![ "/dir".into(), "../a/b".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -149,7 +149,7 @@ fn dir_with_down() fn trailed_dir_with_down() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/dir/a/b".into(), vec![ "/dir/".into(), "../a/b".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -165,7 +165,7 @@ fn trailed_dir_with_down() fn dir_with_several_down() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/a/b".into(), vec![ "/dir/dir2".into(), "../../a/b".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -181,7 +181,7 @@ fn dir_with_several_down() fn trailed_dir_with_several_down() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/a/b".into(), vec![ "/dir/".into(), "../../a/b".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -197,7 +197,7 @@ fn trailed_dir_with_several_down() fn dir_with_several_down_go_out_of_root() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/../a/b".into(), vec![ "/dir".into(), "../../a/b".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -213,7 +213,7 @@ fn dir_with_several_down_go_out_of_root() fn trailed_absolute_with_trailed_down() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/a/b/".into(), vec![ "/a/b/".into(), "../".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -229,7 +229,7 @@ fn trailed_absolute_with_trailed_down() fn absolute_with_trailed_down() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/a/".into(), vec![ "/a/b".into(), "../".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -245,7 +245,7 @@ fn absolute_with_trailed_down() fn trailed_absolute_with_down() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/a/b".into(), vec![ "/a/b/".into(), "..".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -261,7 +261,7 @@ fn trailed_absolute_with_down() fn trailed_absolute_with_trailed_here() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/a/b/".into(), vec![ "/a/b/".into(), "./".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -277,7 +277,7 @@ fn trailed_absolute_with_trailed_here() fn absolute_with_trailed_here() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/a/b/".into(), vec![ "/a/b".into(), "./".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -293,7 +293,7 @@ fn absolute_with_trailed_here() fn trailed_absolute_with_here() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/a/b".into(), vec![ "/a/b/".into(), ".".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -309,7 +309,7 @@ fn trailed_absolute_with_here() fn join_with_empty() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/a/b/c".into(), vec![ "".into(), "a/b".into(), "".into(), "c".into(), "".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -324,8 +324,8 @@ fn join_with_empty() #[ test ] fn join_windows_os_paths() { - let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/c/foo/bar/".into(), vec![ "c:\\".into(), "foo\\".into(), "bar\\".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/c:/foo/bar/".into(), vec![ "c:\\".into(), "foo\\".into(), "bar\\".into() ] ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -341,7 +341,7 @@ fn join_windows_os_paths() fn join_unix_os_paths() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/baz/foo".into(), vec![ "/bar/".into(), "/baz".into(), "foo/".into(), ".".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -357,7 +357,7 @@ fn join_unix_os_paths() fn join_unix_os_paths_2() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/baz/foo/z".into(), vec![ "/bar/".into(), "/baz".into(), "foo/".into(), ".".into(), "z".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -373,7 +373,7 @@ fn join_unix_os_paths_2() fn more_complicated_cases_1() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/aa/bb//cc".into(), vec![ "/aa".into(), "bb//".into(), "cc".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -389,7 +389,7 @@ fn more_complicated_cases_1() fn more_complicated_cases_2() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/bb/cc".into(), vec![ "/aa".into(), "/bb".into(), "cc".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -405,7 +405,7 @@ fn more_complicated_cases_2() fn more_complicated_cases_3() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "//aa/bb//cc//".into(), vec![ "//aa".into(), "bb//".into(), "cc//".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -421,7 +421,7 @@ fn more_complicated_cases_3() fn more_complicated_cases_4() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "/aa/bb//cc".into(), vec![ "/aa".into(), "bb//".into(), "cc".into(), ".".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, @@ -437,7 +437,7 @@ fn more_complicated_cases_4() fn more_complicated_cases_5() { let ( expected, paths ) : ( PathBuf, Vec< PathBuf > ) = ( "//b//d/..e".into(), vec![ "/".into(), "a".into(), "//b//".into(), "././c".into(), "../d".into(), "..e".into() ] ); - let result = the_module::path::join_paths( paths.iter().map( |p| p.as_path() ) ); + let result = the_module::path::iter_join( paths.iter().map( |p| p.as_path() ) ); assert_eq! ( result, diff --git a/module/core/pth/tests/inc/path_join_trait_test.rs b/module/core/pth/tests/inc/path_join_trait_test.rs new file mode 100644 index 0000000000..74f302166b --- /dev/null +++ b/module/core/pth/tests/inc/path_join_trait_test.rs @@ -0,0 +1,206 @@ +use super::*; +use std:: +{ + borrow::Cow, + io, + path::{ Path, PathBuf }, +}; + +#[ test ] +fn basic() -> Result< (), io::Error > +{ + use the_module::PathJoined; + use std::path::PathBuf; + + let path1 : &str = "/some"; + let path2 : String = "path".into(); + let path3 : PathBuf = "to/file".into(); + let path4 : &str = "extra"; + let path5 : String = "components".into(); + + // Test with a tuple of length 1 + let joined1 : PathBuf = ( path1, ).iter_join()?; + println!( "Joined PathBuf (1): {:?}", joined1 ); + + // Test with a tuple of length 2 + let joined2 : PathBuf = ( path1, path2.clone() ).iter_join()?; + println!( "Joined PathBuf (2): {:?}", joined2 ); + + // Test with a tuple of length 3 + let joined3 : PathBuf = ( path1, path2.clone(), path3.clone() ).iter_join()?; + println!( "Joined PathBuf (3): {:?}", joined3 ); + + // Test with a tuple of length 4 + let joined4 : PathBuf = ( path1, path2.clone(), path3.clone(), path4 ).iter_join()?; + println!( "Joined PathBuf (4): {:?}", joined4 ); + + // Test with a tuple of length 5 + let joined5 : PathBuf = ( path1, path2, path3, path4, path5 ).iter_join()?; + println!( "Joined PathBuf (5): {:?}", joined5 ); + + Ok( () ) +} + +#[ test ] +fn array_join_paths_test() -> Result< (), io::Error > +{ + use the_module::{ PathJoined, TryIntoCowPath }; + use std::path::PathBuf; + + // Define a slice of path components + let path_components : [ &str; 3 ] = [ "/some", "path", "to/file" ]; + // Join the path components into a PathBuf + let joined : PathBuf = path_components.iter_join()?; + println!( "Joined PathBuf from slice: {:?}", joined ); + let expected = PathBuf::from( "/some/path/to/file" ); + assert_eq!( joined, expected ); + + Ok( () ) +} + +#[ test ] +fn slice_join_paths_test() -> Result< (), io::Error > +{ + use the_module::{ PathJoined, TryIntoCowPath }; + use std::path::PathBuf; + + // Define a slice of path components + let path_components : [ &str; 3 ] = [ "/some", "path", "to/file" ]; + let slice : &[ &str ] = &path_components[ .. ]; + // Join the path components into a PathBuf + let joined : PathBuf = slice.iter_join()?; + println!( "Joined PathBuf from slice: {:?}", joined ); + let expected = PathBuf::from( "/some/path/to/file" ); + assert_eq!( joined, expected ); + + Ok( () ) +} + +#[ test ] +fn all_types() -> Result< (), io::Error > +{ + use std::path::Path; + use the_module::{ AbsolutePath, CanonicalPath, NativePath, CurrentPath }; + use the_module::{ PathJoined, AsPath, TryIntoPath }; + + // AbsolutePath and CurrentPath + { + let absolute_path = AbsolutePath::try_from( "/absolute/path" ).unwrap(); + let current_path = CurrentPath; + let joined = ( absolute_path.clone(), current_path ).iter_join()?; + let expected = current_path.try_into_path()?; + println!( "Joined PathBuf: {:?}", joined ); + assert_eq!( joined, expected ); + } + + // // CurrentPath and AbsolutePath + // { + // let absolute_path = AbsolutePath::try_from( "/absolute/path" ).unwrap(); + // let current_path = CurrentPath; + // let joined = ( current_path, absolute_path.clone() ).iter_join()?; + // let expected = absolute_path.as_path().to_path_buf(); + // println!( "Joined PathBuf: {:?}", joined ); + // assert_eq!( joined, expected ); + // } + // // qqq : qqq2 : for Denys : bad + + // AbsolutePath and Component + { + let absolute_path = AbsolutePath::try_from( "/absolute/path" ).unwrap(); + let component = Path::new( "/component/path" ).components().next().unwrap(); + println!( "component : {component:?}" ); + let joined = ( absolute_path, component ).iter_join()?; + let expected = component.as_path(); + println!( "Joined PathBuf: {:?}", joined ); + assert_eq!( joined, expected ); + } + + // AbsolutePath and &str + { + let absolute_path = AbsolutePath::try_from( "/absolute/path" ).unwrap(); + let path_str : &str = "additional/str"; + let joined = ( absolute_path, path_str ).iter_join()?; + let expected = PathBuf::from( "/absolute/path/additional/str" ); + println!( "Joined PathBuf: {:?}", joined ); + assert_eq!( joined, expected ); + } + + // AbsolutePath and NativePath + { + let absolute_path = AbsolutePath::try_from( "/absolute/path" ).unwrap(); + let native_path = NativePath::try_from( PathBuf::from( "/native/path" ) ).unwrap(); + let joined = ( absolute_path, native_path ).iter_join()?; + let expected = PathBuf::from( "/native/path" ); + println!( "Joined PathBuf: {:?}", joined ); + assert_eq!( joined, expected ); + } + + // AbsolutePath and CanonicalPath + { + let absolute_path = AbsolutePath::try_from( "/absolute/path" ).unwrap(); + let canonical_path = CanonicalPath::try_from( "/canonical/path" ).unwrap(); + let joined = ( absolute_path, canonical_path ).iter_join()?; + let expected = PathBuf::from( "/canonical/path" ); + println!( "Joined PathBuf: {:?}", joined ); + assert_eq!( joined, expected ); + } + + // NativePath and CurrentPath + { + let native_path = NativePath::try_from( PathBuf::from( "/native/path" ) ).unwrap(); + let current_path = CurrentPath; + let joined = ( native_path, current_path ).iter_join()?; + let expected = current_path.try_into_path()?; + println!( "Joined PathBuf: {:?}", joined ); + assert_eq!( joined, expected ); + } + + // CanonicalPath and Component + { + let canonical_path = CanonicalPath::try_from( "/canonical/path" ).unwrap(); + let component = Path::new( "/component/path" ).components().next().unwrap(); + println!( "component : {component:?}" ); + let joined = ( canonical_path, component ).iter_join()?; + let expected = component.as_path(); + // let expected = PathBuf::from( "/canonical/component" ); + println!( "Joined PathBuf: {:?}", joined ); + assert_eq!( joined, expected ); + } + + Ok( () ) +} + +#[ test ] +fn join_function_test() -> Result< (), io::Error > +{ + use the_module::path; + use std::path::PathBuf; + + // Test joining a tuple of path components + let path1 : &str = "/some"; + let path2 : String = "path".into(); + let path3 : PathBuf = "to/file".into(); + + // Use the join function to join the path components + let joined : PathBuf = path::join( ( path1, path2.clone(), path3.clone() ) )?; + println!( "Joined PathBuf: {:?}", joined ); + // Verify the expected outcome + let expected = PathBuf::from( "/some/path/to/file" ); + assert_eq!( joined, expected ); + + // Test joining a tuple of length 2 + let joined : PathBuf = path::join( ( path1, path2.clone() ) )?; + println!( "Joined PathBuf (2 components): {:?}", joined ); + // Verify the expected outcome + let expected = PathBuf::from( "/some/path" ); + assert_eq!( joined, expected ); + + // Test joining a tuple of length 1 + let joined : PathBuf = path::join( ( path1, ) )?; + println!( "Joined PathBuf (1 component): {:?}", joined ); + // Verify the expected outcome + let expected = PathBuf::from( "/some" ); + assert_eq!( joined, expected ); + + Ok( () ) +} \ No newline at end of file diff --git a/module/core/proper_path_tools/tests/inc/path_normalize.rs b/module/core/pth/tests/inc/path_normalize.rs similarity index 100% rename from module/core/proper_path_tools/tests/inc/path_normalize.rs rename to module/core/pth/tests/inc/path_normalize.rs diff --git a/module/core/proper_path_tools/tests/inc/path_relative.rs b/module/core/pth/tests/inc/path_relative.rs similarity index 100% rename from module/core/proper_path_tools/tests/inc/path_relative.rs rename to module/core/pth/tests/inc/path_relative.rs diff --git a/module/core/proper_path_tools/tests/inc/path_unique_folder_name.rs b/module/core/pth/tests/inc/path_unique_folder_name.rs similarity index 100% rename from module/core/proper_path_tools/tests/inc/path_unique_folder_name.rs rename to module/core/pth/tests/inc/path_unique_folder_name.rs diff --git a/module/core/proper_path_tools/tests/inc/rebase_path.rs b/module/core/pth/tests/inc/rebase_path.rs similarity index 100% rename from module/core/proper_path_tools/tests/inc/rebase_path.rs rename to module/core/pth/tests/inc/rebase_path.rs diff --git a/module/core/proper_path_tools/tests/inc/transitive.rs b/module/core/pth/tests/inc/transitive.rs similarity index 96% rename from module/core/proper_path_tools/tests/inc/transitive.rs rename to module/core/pth/tests/inc/transitive.rs index e0b2da7acc..8224024e5b 100644 --- a/module/core/proper_path_tools/tests/inc/transitive.rs +++ b/module/core/pth/tests/inc/transitive.rs @@ -4,7 +4,7 @@ use super::*; #[ test ] fn basic_from() { - use proper_path_tools::TransitiveTryFrom; + use pth::TransitiveTryFrom; use std::convert::TryFrom; struct InitialType; @@ -42,7 +42,7 @@ fn basic_from() #[ test ] fn test_transitive_try_into() { - use proper_path_tools::TransitiveTryInto; + use pth::TransitiveTryInto; // Define NewType1 wrapping a String #[ derive( Debug, PartialEq ) ] diff --git a/module/core/pth/tests/inc/try_into_cow_path_test.rs b/module/core/pth/tests/inc/try_into_cow_path_test.rs new file mode 100644 index 0000000000..73a3910c52 --- /dev/null +++ b/module/core/pth/tests/inc/try_into_cow_path_test.rs @@ -0,0 +1,124 @@ +use super::*; + +#[ test ] +fn try_into_cow_path_test() +{ + use std:: + { + borrow::Cow, + path::{ Component, Path, PathBuf }, + }; + #[ cfg( feature = "path_utf8" ) ] + use the_module::{ Utf8Path, Utf8PathBuf }; + use the_module:: + { + TryIntoCowPath, AbsolutePath, CanonicalPath, NativePath, CurrentPath, + }; + + // Test with &str + let path_str : &str = "/some/path"; + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( path_str ).unwrap(); + println!( "Cow from &str: {:?}", cow_path ); + + // Test with &String + let string_path : String = String::from( "/another/path" ); + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( &string_path ).unwrap(); + println!( "Cow from &String: {:?}", cow_path ); + + // Test with String + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( string_path.clone() ).unwrap(); + println!( "Cow from String: {:?}", cow_path ); + + // Test with &Path + let path : &Path = Path::new( "/yet/another/path" ); + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( path ).unwrap(); + println!( "Cow from &Path: {:?}", cow_path ); + + // Test with &PathBuf + let path_buf : PathBuf = PathBuf::from( "/yet/another/path" ); + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( &path_buf ).unwrap(); + println!( "Cow from &PathBuf: {:?}", cow_path ); + + // Test with PathBuf + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( path_buf.clone() ).unwrap(); + println!( "Cow from PathBuf: {:?}", cow_path ); + + // Test with &AbsolutePath + let absolute_path : AbsolutePath = AbsolutePath::try_from( "/absolute/path" ).unwrap(); + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( &absolute_path ).unwrap(); + println!( "Cow from &AbsolutePath: {:?}", cow_path ); + + // Test with AbsolutePath + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( absolute_path.clone() ).unwrap(); + println!( "Cow from AbsolutePath: {:?}", cow_path ); + + // Test with &CanonicalPath + let canonical_path = CanonicalPath::try_from( "/canonical/path" ).unwrap(); + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( &canonical_path ).unwrap(); + println!( "Cow from &CanonicalPath: {:?}", cow_path ); + + // Test with CanonicalPath + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( canonical_path.clone() ).unwrap(); + println!( "Cow from CanonicalPath: {:?}", cow_path ); + + // Test with &NativePath + let native_path = NativePath::try_from( PathBuf::from( "/native/path" ) ).unwrap(); + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( &native_path ).unwrap(); + println!( "Cow from &NativePath: {:?}", cow_path ); + + // Test with NativePath + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( native_path.clone() ).unwrap(); + println!( "Cow from NativePath: {:?}", cow_path ); + + // Test with &CurrentPath + let current_path = CurrentPath; + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( ¤t_path ).unwrap(); + println!( "Cow from &CurrentPath: {:?}", cow_path ); + assert!( cow_path.to_string_lossy().len() > 1 ); + + // Test with CurrentPath + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( current_path ).unwrap(); + println!( "Cow from CurrentPath: {:?}", cow_path ); + assert!( cow_path.to_string_lossy().len() > 1 ); + + // Test with &Component + let root_component : Component< '_ > = Component::RootDir; + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( &root_component ).unwrap(); + println!( "Cow from &Component: {:?}", cow_path ); + assert!( cow_path.to_string_lossy().len() >= 1 ); + + // Test with Component + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( root_component ).unwrap(); + println!( "Cow from Component: {:?}", cow_path ); + assert!( cow_path.to_string_lossy().len() >= 1 ); + + // Test with Component + let path = Path::new( "/component/path" ); + for component in path.components() + { + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( component ).unwrap(); + println!( "Cow from Component: {:?}", cow_path ); + assert!( cow_path.to_string_lossy().len() >= 1 ); + } + + #[ cfg( feature = "path_utf8" ) ] + { + // Test with &Utf8Path + let utf8_path = Utf8Path::new( "/utf8/path" ); + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( &utf8_path ).unwrap(); + println!( "Cow from &Utf8Path: {:?}", cow_path ); + + // Test with Utf8Path + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( utf8_path ).unwrap(); + println!( "Cow from Utf8Path: {:?}", cow_path ); + + // Test with &Utf8PathBuf + let utf8_path_buf = Utf8PathBuf::from( "/utf8/pathbuf" ); + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( &utf8_path_buf ).unwrap(); + println!( "Cow from &Utf8PathBuf: {:?}", cow_path ); + + // Test with Utf8PathBuf + let cow_path : Cow< '_ , Path > = TryIntoCowPath::try_into_cow_path( utf8_path_buf.clone() ).unwrap(); + println!( "Cow from Utf8PathBuf: {:?}", cow_path ); + } +} diff --git a/module/core/pth/tests/inc/try_into_path_test.rs b/module/core/pth/tests/inc/try_into_path_test.rs new file mode 100644 index 0000000000..b7623d5c60 --- /dev/null +++ b/module/core/pth/tests/inc/try_into_path_test.rs @@ -0,0 +1,117 @@ +use super::*; + +#[ test ] +fn try_into_path_test() +{ + use std::path::{ Component, Path, PathBuf }; + #[ cfg( feature = "path_utf8" ) ] + use the_module::{ Utf8Path, Utf8PathBuf }; + use the_module::{ TryIntoPath, AbsolutePath, CanonicalPath, NativePath, CurrentPath }; + + // Test with &str + let path_str : &str = "/some/path"; + let path_buf : PathBuf = TryIntoPath::try_into_path( path_str ).unwrap(); + println!( "PathBuf from &str: {:?}", path_buf ); + + // Test with &String + let string_path : String = String::from( "/another/path" ); + let path_buf : PathBuf = TryIntoPath::try_into_path( &string_path ).unwrap(); + println!( "PathBuf from &String: {:?}", path_buf ); + + // Test with String + let path_buf : PathBuf = TryIntoPath::try_into_path( string_path.clone() ).unwrap(); + println!( "PathBuf from String: {:?}", path_buf ); + + // Test with &Path + let path : &Path = Path::new( "/yet/another/path" ); + let path_buf : PathBuf = TryIntoPath::try_into_path( path ).unwrap(); + println!( "PathBuf from &Path: {:?}", path_buf ); + + // Test with &PathBuf + let path_buf_instance : PathBuf = PathBuf::from( "/yet/another/path" ); + let path_buf : PathBuf = TryIntoPath::try_into_path( &path_buf_instance ).unwrap(); + println!( "PathBuf from &PathBuf: {:?}", path_buf ); + + // Test with PathBuf + let path_buf : PathBuf = TryIntoPath::try_into_path( path_buf_instance.clone() ).unwrap(); + println!( "PathBuf from PathBuf: {:?}", path_buf ); + + // Test with &AbsolutePath + let absolute_path : AbsolutePath = AbsolutePath::try_from( "/absolute/path" ).unwrap(); + let path_buf : PathBuf = TryIntoPath::try_into_path( &absolute_path ).unwrap(); + println!( "PathBuf from &AbsolutePath: {:?}", path_buf ); + + // Test with AbsolutePath + let path_buf : PathBuf = TryIntoPath::try_into_path( absolute_path.clone() ).unwrap(); + println!( "PathBuf from AbsolutePath: {:?}", path_buf ); + + // Test with &CanonicalPath + let canonical_path = CanonicalPath::try_from( "/canonical/path" ).unwrap(); + let path_buf : PathBuf = TryIntoPath::try_into_path( &canonical_path ).unwrap(); + println!( "PathBuf from &CanonicalPath: {:?}", path_buf ); + + // Test with CanonicalPath + let path_buf : PathBuf = TryIntoPath::try_into_path( canonical_path.clone() ).unwrap(); + println!( "PathBuf from CanonicalPath: {:?}", path_buf ); + + // Test with &NativePath + let native_path = NativePath::try_from( PathBuf::from( "/native/path" ) ).unwrap(); + let path_buf : PathBuf = TryIntoPath::try_into_path( &native_path ).unwrap(); + println!( "PathBuf from &NativePath: {:?}", path_buf ); + + // Test with NativePath + let path_buf : PathBuf = TryIntoPath::try_into_path( native_path.clone() ).unwrap(); + println!( "PathBuf from NativePath: {:?}", path_buf ); + + // Test with &CurrentPath + let current_path = CurrentPath; + let path_buf : PathBuf = TryIntoPath::try_into_path( ¤t_path ).unwrap(); + println!( "PathBuf from &CurrentPath: {:?}", path_buf ); + assert!( path_buf.to_string_lossy().len() > 1 ); + + // Test with CurrentPath + let path_buf : PathBuf = TryIntoPath::try_into_path( current_path ).unwrap(); + println!( "PathBuf from CurrentPath: {:?}", path_buf ); + assert!( path_buf.to_string_lossy().len() > 1 ); + + // Test with &Component + let root_component : Component< '_ > = Component::RootDir; + let path_buf : PathBuf = TryIntoPath::try_into_path( &root_component ).unwrap(); + println!( "PathBuf from &Component: {:?}", path_buf ); + assert!( path_buf.to_string_lossy().len() >= 1 ); + + // Test with Component + let path_buf : PathBuf = TryIntoPath::try_into_path( root_component ).unwrap(); + println!( "PathBuf from Component: {:?}", path_buf ); + assert!( path_buf.to_string_lossy().len() >= 1 ); + + // Test with Component + let path = Path::new( "/component/path" ); + for component in path.components() + { + let path_buf : PathBuf = TryIntoPath::try_into_path( component ).unwrap(); + println!( "PathBuf from Component: {:?}", path_buf ); + assert!( path_buf.to_string_lossy().len() >= 1 ); + } + + #[ cfg( feature = "path_utf8" ) ] + { + // Test with &Utf8Path + let utf8_path = Utf8Path::new( "/utf8/path" ); + let path_buf : PathBuf = TryIntoPath::try_into_path( &utf8_path ).unwrap(); + println!( "PathBuf from &Utf8Path: {:?}", path_buf ); + + // Test with Utf8Path + let path_buf : PathBuf = TryIntoPath::try_into_path( utf8_path ).unwrap(); + println!( "PathBuf from Utf8Path: {:?}", path_buf ); + + // Test with &Utf8PathBuf + let utf8_path_buf = Utf8PathBuf::from( "/utf8/pathbuf" ); + let path_buf : PathBuf = TryIntoPath::try_into_path( &utf8_path_buf ).unwrap(); + println!( "PathBuf from &Utf8PathBuf: {:?}", path_buf ); + + // Test with Utf8PathBuf + let path_buf : PathBuf = TryIntoPath::try_into_path( utf8_path_buf.clone() ).unwrap(); + println!( "PathBuf from Utf8PathBuf: {:?}", path_buf ); + } +} diff --git a/module/core/proper_path_tools/tests/inc/without_ext.rs b/module/core/pth/tests/inc/without_ext.rs similarity index 100% rename from module/core/proper_path_tools/tests/inc/without_ext.rs rename to module/core/pth/tests/inc/without_ext.rs diff --git a/module/core/pth/tests/smoke_test.rs b/module/core/pth/tests/smoke_test.rs new file mode 100644 index 0000000000..828e9b016b --- /dev/null +++ b/module/core/pth/tests/smoke_test.rs @@ -0,0 +1,14 @@ + + +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + + +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/core/pth/tests/tests.rs b/module/core/pth/tests/tests.rs new file mode 100644 index 0000000000..49fa343161 --- /dev/null +++ b/module/core/pth/tests/tests.rs @@ -0,0 +1,9 @@ +#![ allow( unused_imports ) ] + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +use pth as the_module; +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/core/reflect_tools/License b/module/core/reflect_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/reflect_tools/License +++ b/module/core/reflect_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/reflect_tools/src/reflect/fields/vec.rs b/module/core/reflect_tools/src/reflect/fields/vec.rs index bdf3977601..0a18259738 100644 --- a/module/core/reflect_tools/src/reflect/fields/vec.rs +++ b/module/core/reflect_tools/src/reflect/fields/vec.rs @@ -9,6 +9,7 @@ use collection_tools::Vec; impl< V, Borrowed > Fields< usize, &'_ Borrowed > for Vec< V > where Borrowed : std::borrow::ToOwned + 'static + ?Sized, + // Borrowed : ?Sized + 'static, V : std::borrow::Borrow< Borrowed >, { @@ -28,6 +29,7 @@ where impl< V, Borrowed > Fields< usize, Option< Cow< '_, Borrowed > > > for Vec< V > where Borrowed : std::borrow::ToOwned + 'static + ?Sized, + // Borrowed : ?Sized + 'static, V : std::borrow::Borrow< Borrowed >, { @@ -39,6 +41,7 @@ where fn fields< 's >( &'s self ) -> impl IteratorTrait< Item = ( Self::Key< 's >, Self::Val< 's > ) > { + // self.iter().enumerate().map( move | ( key, val ) | ( key, Some( Cow::Borrowed( &val ) ) ) ) self.iter().enumerate().map( move | ( key, val ) | ( key, Some( Cow::Borrowed( val.borrow() ) ) ) ) } @@ -47,6 +50,7 @@ where impl< V, Borrowed, Marker > Fields< usize, OptionalCow< '_, Borrowed, Marker > > for Vec< V > where Borrowed : std::borrow::ToOwned + 'static + ?Sized, + // Borrowed : ?Sized + 'static, V : std::borrow::Borrow< Borrowed >, Marker : Clone + Copy + 'static, { diff --git a/module/core/reflect_tools/src/reflect/wrapper.rs b/module/core/reflect_tools/src/reflect/wrapper.rs index defbe192f1..31ad09a99a 100644 --- a/module/core/reflect_tools/src/reflect/wrapper.rs +++ b/module/core/reflect_tools/src/reflect/wrapper.rs @@ -7,7 +7,7 @@ mod private { } -mod maybe_as; +mod optional_cow; #[ doc( inline ) ] #[ allow( unused_imports ) ] @@ -40,7 +40,7 @@ pub mod exposed #[ allow( unused_imports ) ] pub use super:: { - maybe_as::OptionalCow, + optional_cow::OptionalCow, }; } diff --git a/module/core/reflect_tools/src/reflect/wrapper/maybe_as.rs b/module/core/reflect_tools/src/reflect/wrapper/optional_cow.rs similarity index 88% rename from module/core/reflect_tools/src/reflect/wrapper/maybe_as.rs rename to module/core/reflect_tools/src/reflect/wrapper/optional_cow.rs index f1351f8c92..5f329cc459 100644 --- a/module/core/reflect_tools/src/reflect/wrapper/maybe_as.rs +++ b/module/core/reflect_tools/src/reflect/wrapper/optional_cow.rs @@ -20,6 +20,19 @@ where Marker : Clone + Copy + 'static, { + /// Creates owned data from borrowed data, usually by cloning. + #[ inline( always ) ] + pub fn into_owned( &self ) -> < T as std::borrow::ToOwned >::Owned + where + < T as std::borrow::ToOwned >::Owned : Default, + { + match self.0.as_ref() + { + Some( c ) => c.clone().into_owned(), + None => < T as std::borrow::ToOwned >::Owned::default(), + } + } + /// Check is it borrowed. #[ inline( always ) ] pub fn is_borrowed( &self ) -> bool @@ -212,3 +225,15 @@ where T : Eq, { } + +impl< 'a, T, Marker > From< OptionalCow< 'a, T, Marker > > for Option< Cow< 'a, T > > +where + T : std::borrow::ToOwned + ?Sized, + Marker : Clone + Copy + 'static, +{ + #[ inline( always ) ] + fn from( src : OptionalCow< 'a, T, Marker > ) -> Self + { + src.0 + } +} diff --git a/module/core/reflect_tools/tests/inc/fundamental/fields_bset.rs b/module/core/reflect_tools/tests/inc/fundamental/fields_bset.rs index 5a811ad569..abaee19fd5 100644 --- a/module/core/reflect_tools/tests/inc/fundamental/fields_bset.rs +++ b/module/core/reflect_tools/tests/inc/fundamental/fields_bset.rs @@ -4,7 +4,6 @@ use super::*; use the_module:: { Fields, - }; // xxx : implement for other collections diff --git a/module/core/reflect_tools_meta/License b/module/core/reflect_tools_meta/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/reflect_tools_meta/License +++ b/module/core/reflect_tools_meta/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/strs_tools/Cargo.toml b/module/core/strs_tools/Cargo.toml index 77dd2eeab5..37b6231be0 100644 --- a/module/core/strs_tools/Cargo.toml +++ b/module/core/strs_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strs_tools" -version = "0.17.0" +version = "0.18.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/strs_tools/License b/module/core/strs_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/strs_tools/License +++ b/module/core/strs_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/test_tools/Cargo.toml b/module/core/test_tools/Cargo.toml index 2093e6b0b2..6d30222997 100644 --- a/module/core/test_tools/Cargo.toml +++ b/module/core/test_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test_tools" -version = "0.9.0" +version = "0.11.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -59,7 +59,7 @@ enabled = [ "typing_tools/enabled", "data_type/enabled", "diagnostics_tools/enabled", - "process_tools_published/enabled", + "process_tools/enabled", "collection_tools/enabled", ] # nightly = [ "typing_tools/nightly" ] @@ -83,7 +83,7 @@ mem_tools = { workspace = true, features = [ "full" ] } typing_tools = { workspace = true, features = [ "full" ] } data_type = { workspace = true, features = [ "full" ] } diagnostics_tools = { workspace = true, features = [ "full" ] } -process_tools_published = { workspace = true, features = [ "full" ] } +process_tools = { workspace = true, features = [ "full" ] } collection_tools = { workspace = true, features = [ "full" ] } # former_stable = { workspace = true, features = [ "full" ] } diff --git a/module/core/test_tools/License b/module/core/test_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/test_tools/License +++ b/module/core/test_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/test_tools/src/lib.rs b/module/core/test_tools/src/lib.rs index 8baa4d9530..f9870e775e 100644 --- a/module/core/test_tools/src/lib.rs +++ b/module/core/test_tools/src/lib.rs @@ -42,13 +42,18 @@ pub mod dependency #[ doc( inline ) ] #[ allow( unused_imports ) ] - pub use ::process_tools_published; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use ::process_tools_published as process_tools; + pub use ::process_tools; + + // #[ doc( inline ) ] + // #[ allow( unused_imports ) ] + // pub use ::process_tools as process_tools; } +mod private {} + +// + #[ cfg( feature = "enabled" ) ] // #[ cfg( not( feature = "no_std" ) ) ] ::meta_tools::mod_interface! @@ -83,6 +88,8 @@ pub mod dependency prelude use ::collection_tools as collection; // prelude use ::process_tools as process; + use ::collection_tools; // xxx : do that for all dependencies + prelude use ::meta_tools:: { impls, @@ -91,6 +98,7 @@ pub mod dependency tests_impls_optional, tests_index, }; + prelude use ::typing_tools::{ implements }; } diff --git a/module/core/test_tools/src/test/compiletime.rs b/module/core/test_tools/src/test/compiletime.rs index 77f9d362ac..4f29ec998e 100644 --- a/module/core/test_tools/src/test/compiletime.rs +++ b/module/core/test_tools/src/test/compiletime.rs @@ -10,10 +10,72 @@ mod private pub use ::trybuild::*; } +// // // +// #[ doc( inline ) ] +// #[ allow( unused_imports ) ] +// pub use own::*; +// +// #[ doc = r" Own namespace of the module." ] +// #[ allow( unused_imports ) ] +// pub mod own +// { +// use super::private; +// mod __all__ +// { +// pub use super::super::*; +// pub use super::super::private::*; +// } +// #[ doc( inline ) ] +// pub use super::orphan::*; +// #[ doc( inline ) ] +// #[ allow( unused_imports ) ] +// pub use private::{*}; +// } +// +// #[ doc = r" Orphan namespace of the module." ] +// #[ allow( unused_imports ) ] +// pub mod orphan +// { +// mod __all__ +// { +// pub use super::super::*; +// pub use super::super::private::*; +// } +// #[ doc( inline ) ] +// pub use super::exposed::*; +// } +// +// #[ doc = r" Exposed namespace of the module." ] +// #[ allow( unused_imports ) ] +// pub mod exposed +// { +// mod __all__ +// { +// pub use super::super::*; +// pub use super::super::private::*; +// } +// #[ doc( inline ) ] +// pub use super::prelude::*; +// #[ doc( inline ) ] +// #[ allow( unused_imports ) ] +// pub use super::super::compiletime; +// } +// +// #[ doc = r" Prelude to use essentials: `use my_module::prelude::*`." ] +// #[ allow( unused_imports ) ] +// pub mod prelude +// { +// mod __all__ +// { +// pub use super::super::*; +// pub use super::super::private::*; +// } +// } crate::mod_interface! { + // #![ debug ] // xxx : make it working // exposed use super; exposed use super::super::compiletime; diff --git a/module/core/test_tools/src/test/helper.rs b/module/core/test_tools/src/test/helper.rs index fe79e69784..49675e2ada 100644 --- a/module/core/test_tools/src/test/helper.rs +++ b/module/core/test_tools/src/test/helper.rs @@ -75,10 +75,10 @@ mod private pub use doc_file_test; } -// - crate::mod_interface! { + // xxx + // #![ debug ] // exposed use super; exposed use super::super::helper; diff --git a/module/core/test_tools/src/test/mod.rs b/module/core/test_tools/src/test/mod.rs index 60ec182ac4..158406fbd1 100644 --- a/module/core/test_tools/src/test/mod.rs +++ b/module/core/test_tools/src/test/mod.rs @@ -3,6 +3,8 @@ //! Tools for testing. //! +mod private {} + // #[ cfg( not( feature = "no_std" ) ) ] crate::mod_interface! { diff --git a/module/core/time_tools/License b/module/core/time_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/time_tools/License +++ b/module/core/time_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/typing_tools/Cargo.toml b/module/core/typing_tools/Cargo.toml index 5b128ba0e5..2d75db2449 100644 --- a/module/core/typing_tools/Cargo.toml +++ b/module/core/typing_tools/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "typing_tools" -version = "0.8.0" +version = "0.10.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/typing_tools/License b/module/core/typing_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/typing_tools/License +++ b/module/core/typing_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/variadic_from/Cargo.toml b/module/core/variadic_from/Cargo.toml index e3d1871e12..073a4f994a 100644 --- a/module/core/variadic_from/Cargo.toml +++ b/module/core/variadic_from/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "variadic_from" -version = "0.23.0" +version = "0.27.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/variadic_from/License b/module/core/variadic_from/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/core/variadic_from/License +++ b/module/core/variadic_from/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/core/wtools/Cargo.toml b/module/core/wtools/Cargo.toml index 8488ccd02b..4d2e2f1f29 100644 --- a/module/core/wtools/Cargo.toml +++ b/module/core/wtools/Cargo.toml @@ -318,7 +318,6 @@ dt_default = [ # "dt_use_std", "data_type/default", "dt_either", - "dt_prelude", # "dt_type_constructor", # "dt_make", # "dt_vectorized_from", @@ -329,7 +328,6 @@ dt_full = [ # "dt_use_std", "data_type/full", "dt_either", - "dt_prelude", # "dt_type_constructor", # "dt_make", # "dt_vectorized_from", @@ -341,7 +339,6 @@ dt_full = [ dt_use_alloc = [ "dt", "data_type/use_alloc" ] dt_either = [ "dt", "data_type/dt_either" ] -dt_prelude = [ "dt", "data_type/dt_prelude" ] # dt_type_constructor = [ "dt", "data_type/dt_type_constructor" ] # dt_make = [ "dt", "data_type/dt_make" ] # dt_vectorized_from = [ "dt", "data_type/dt_vectorized_from" ] diff --git a/module/core/wtools/License b/module/core/wtools/License index e3e9e057cf..c32986cee3 100644 --- a/module/core/wtools/License +++ b/module/core/wtools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/move/assistant/Cargo.toml b/module/move/assistant/Cargo.toml index 6e2af1a870..144cfb6557 100644 --- a/module/move/assistant/Cargo.toml +++ b/module/move/assistant/Cargo.toml @@ -34,10 +34,11 @@ enabled = [ [dependencies] # xxx : qqq : optimze features +mod_interface = { workspace = true, features = [ "full" ] } former = { workspace = true, features = [ "full" ] } format_tools = { workspace = true, features = [ "full" ] } reflect_tools = { workspace = true, features = [ "full" ] } -openai-api-rs = { version = "4.0.9" } +openai-api-rs = { version = "=5.0.11" } tokio = { version = "1", features = ["full"] } dotenv = "0.15" diff --git a/module/move/assistant/License b/module/move/assistant/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/move/assistant/License +++ b/module/move/assistant/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/move/assistant/Readme.md b/module/move/assistant/Readme.md index 0e9402c634..9296447b86 100644 --- a/module/move/assistant/Readme.md +++ b/module/move/assistant/Readme.md @@ -3,7 +3,9 @@ # Module :: assistant [![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleassistantPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleassistantPush.yml) [![docs.rs](https://img.shields.io/docsrs/assistant?color=e3e8f0&logo=docs.rs)](https://docs.rs/assistant) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -Assist AI in writing code. +**NOT ready for production** + + -Graphs tools. +**NOT ready for production** + - ```rust #[ cfg( all( feature = "cell_factory", feature = "use_std" ) ) ] { @@ -37,3 +36,4 @@ cd wTools cd examples/graphs_tools_trivial cargo run ``` +--> diff --git a/module/move/optimization_tools/License b/module/move/optimization_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/move/optimization_tools/License +++ b/module/move/optimization_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/move/plot_interface/License b/module/move/plot_interface/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/move/plot_interface/License +++ b/module/move/plot_interface/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/move/plot_interface/Readme.md b/module/move/plot_interface/Readme.md index 0e604acfb8..6102a14813 100644 --- a/module/move/plot_interface/Readme.md +++ b/module/move/plot_interface/Readme.md @@ -5,11 +5,12 @@ [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_plot_interface_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_plot_interface_push.yml) [![docs.rs](https://img.shields.io/docsrs/plot_interface?color=e3e8f0&logo=docs.rs)](https://docs.rs/plot_interface) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -Plot interface. +**NOT ready for production** + + ```rust ``` @@ -27,4 +28,4 @@ git clone https://github.com/Wandalen/wTools cd wTools cd examples/plot_interface_trivial cargo run -``` +``` --> diff --git a/module/move/refiner/License b/module/move/refiner/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/move/refiner/License +++ b/module/move/refiner/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/move/sqlx_query/License b/module/move/sqlx_query/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/move/sqlx_query/License +++ b/module/move/sqlx_query/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/move/unitore/Cargo.toml b/module/move/unitore/Cargo.toml index 8f98fba818..fa560e6cae 100644 --- a/module/move/unitore/Cargo.toml +++ b/module/move/unitore/Cargo.toml @@ -32,7 +32,7 @@ enabled = [] [dependencies] error_tools = { workspace = true, features = [ "default" ] } -proper_path_tools = { workspace = true, features = [ "default" ] } +pth = { workspace = true, features = [ "default" ] } tokio = { version = "1.36.0", features = [ "rt", "rt-multi-thread", "io-std", "macros" ] } hyper = { version = "1.1.0", features = [ "client" ] } hyper-tls = "0.6.0" diff --git a/module/move/unitore/src/action/config.rs b/module/move/unitore/src/action/config.rs index 9dfc356fe0..a2da010f41 100644 --- a/module/move/unitore/src/action/config.rs +++ b/module/move/unitore/src/action/config.rs @@ -16,7 +16,7 @@ use gluesql::{ prelude::Payload, sled_storage::SledStorage }; /// Add configuration file with subscriptions to storage. pub async fn config_add( mut storage : FeedStorage< SledStorage >, path : &PathBuf ) -> Result< impl Report > { - let path = proper_path_tools::path::normalize( path ); + let path = pth::path::normalize( path ); let mut err_str = format!( "Invalid path for config file {:?}", path ); @@ -63,7 +63,7 @@ pub async fn config_add( mut storage : FeedStorage< SledStorage >, path : &PathB /// Remove configuration file from storage. pub async fn config_delete( mut storage : FeedStorage< SledStorage >, path : &PathBuf ) -> Result< impl Report > { - let path = proper_path_tools::path::normalize( path ); + let path = pth::path::normalize( path ); let path = path.canonicalize().context( format!( "Invalid path for config file {:?}", path ) )?; let config = Config::new( path.to_string_lossy().to_string() ); diff --git a/module/move/unitore/src/command/config.rs b/module/move/unitore/src/command/config.rs index bbd436ccb9..b1e678a732 100644 --- a/module/move/unitore/src/command/config.rs +++ b/module/move/unitore/src/command/config.rs @@ -18,7 +18,28 @@ impl ConfigCommand /// Create command for adding config. pub fn add() -> Result< Command > { - let rt = tokio::runtime::Runtime::new()?; + #[ tokio::main ] + async fn add_command( o : VerifiedCommand ) + { + // qqq: could we print something on None value? + let Some( path ) = o.args.get_owned::< PathBuf >( 0 ) else { return; }; + + let path_to_storage = std::env::var( "UNITORE_STORAGE_PATH" ).ok() + .unwrap_or_else( || String::from( "./_data" ) ); + let config = Config::default().path( path_to_storage ); + + let res = ( || async + { + let feed_storage = FeedStorage::init_storage( &config ).await?; + config_add( feed_storage, &path ).await + } )().await; + + match res + { + Ok( report ) => report.report(), + Err( err ) => println!( "{:?}", err ), + } + } Ok ( @@ -37,38 +58,7 @@ impl ConfigCommand " link = \"https://feeds.bbci.co.uk/news/world/rss.xml\"\n", )) .subject().hint( "Path" ).kind( Type::Path ).optional( false ).end() - .routine( move | o : VerifiedCommand | - { - let path_arg = o.args - .get_owned::< wca::Value >( 0 ); - - if let Some( path ) = path_arg - { - let path : PathBuf = path.into(); - - let res = rt.block_on - ( async move - { - let path_to_storage = std::env::var( "UNITORE_STORAGE_PATH" ) - .unwrap_or( String::from( "./_data" ) ) - ; - - let config = Config::default() - .path( path_to_storage ) - ; - - let feed_storage = FeedStorage::init_storage( &config ).await?; - config_add( feed_storage, &path ).await - } - ); - - match res - { - Ok( report ) => report.report(), - Err( err ) => println!( "{:?}", err ), - } - } - }) + .routine( add_command ) .end() ) } @@ -76,8 +66,29 @@ impl ConfigCommand /// Create command for deleting config. pub fn delete() -> Result< Command > { - let rt = tokio::runtime::Runtime::new()?; - + #[ tokio::main ] + async fn delete_command( o : VerifiedCommand ) + { + // qqq: could we print something on None value? + let Some( path ) = o.args.get_owned::< PathBuf >( 0 ) else { return; }; + + let path_to_storage = std::env::var( "UNITORE_STORAGE_PATH" ).ok() + .unwrap_or_else( || String::from( "./_data" ) ); + let config = Config::default().path( path_to_storage ); + + let res = ( || async + { + let feed_storage = FeedStorage::init_storage( &config ).await?; + config_delete( feed_storage, &path ).await + } )().await; + + match res + { + Ok( report ) => report.report(), + Err( err ) => println!( "{:?}", err ), + } + } + Ok( Command::former() .phrase( "config.delete" ) @@ -87,38 +98,7 @@ impl ConfigCommand " Example: .config.delete ./config/feeds.toml", )) .subject().hint( "Path" ).kind( Type::Path ).optional( false ).end() - .routine( move | o : VerifiedCommand | - { - let path_arg = o.args - .get_owned::< wca::Value >( 0 ); - - if let Some( path ) = path_arg - { - let path : PathBuf = path.into(); - - let res = rt.block_on - ( async move - { - let path_to_storage = std::env::var( "UNITORE_STORAGE_PATH" ) - .unwrap_or( String::from( "./_data" ) ) - ; - - let config = Config::default() - .path( path_to_storage ) - ; - - let feed_storage = FeedStorage::init_storage( &config ).await?; - config_delete( feed_storage, &path ).await - } - ); - - match res - { - Ok( report ) => report.report(), - Err( err ) => println!( "{:?}", err ), - } - } - }) + .routine( delete_command ) .end() ) } diff --git a/module/move/unitore/src/entity/config.rs b/module/move/unitore/src/entity/config.rs index 92f9f550d6..536c1c5142 100644 --- a/module/move/unitore/src/entity/config.rs +++ b/module/move/unitore/src/entity/config.rs @@ -44,7 +44,7 @@ pub trait ConfigStore // qqq : use AbsolutePath newtype from `path_tools` // qqq : normalize all paths with `path_tools::path::normalize` -// https://docs.rs/proper_path_tools/latest/proper_path_tools/path/fn.normalize.html +// https://docs.rs/pth/latest/pth/path/fn.normalize.html // added path normalization // unitore .query.execute \'SELECT \* FROM feed\' diff --git a/module/move/unitore/tests/config_add.rs b/module/move/unitore/tests/config_add.rs index 7f080622b8..6673b0f608 100644 --- a/module/move/unitore/tests/config_add.rs +++ b/module/move/unitore/tests/config_add.rs @@ -12,7 +12,7 @@ use error_tools::untyped::Result; async fn config_add() -> Result< () > { let path = PathBuf::from( "./tests/fixtures/test_config.toml" ); - let temp_path = proper_path_tools::path::unique_folder_name().unwrap(); + let temp_path = pth::path::unique_folder_name().unwrap(); let config = Config::default() .path( format!( "./{}", temp_path ) ) diff --git a/module/move/unitore/tests/config_delete.rs b/module/move/unitore/tests/config_delete.rs index 9a7ffdf10a..c3393702cc 100644 --- a/module/move/unitore/tests/config_delete.rs +++ b/module/move/unitore/tests/config_delete.rs @@ -16,7 +16,7 @@ async fn config_delete() -> Result< () > { let path = std::path::PathBuf::from( "./tests/fixtures/test_config.toml" ); - let temp_path = proper_path_tools::path::unique_folder_name().unwrap(); + let temp_path = pth::path::unique_folder_name().unwrap(); let config = Config::default() .path( format!( "./{}", temp_path ) ) diff --git a/module/move/unitore/tests/frames_download.rs b/module/move/unitore/tests/frames_download.rs index 11494838f9..0b78b077d0 100644 --- a/module/move/unitore/tests/frames_download.rs +++ b/module/move/unitore/tests/frames_download.rs @@ -2,7 +2,7 @@ use feed_rs::parser as feed_parser; use gluesql:: { core:: - { + { chrono::{ DateTime, Utc }, data::Value }, @@ -20,7 +20,7 @@ use error_tools::untyped::Result; #[ tokio::test ] async fn test_save() -> Result< () > { - let temp_path = proper_path_tools::path::unique_folder_name().unwrap(); + let temp_path = pth::path::unique_folder_name().unwrap(); let config = Config::default() .path( format!( "./{}", temp_path ) ) @@ -52,7 +52,7 @@ async fn test_save() -> Result< () > #[ tokio::test ] async fn test_update() -> Result< () > { - let temp_path = proper_path_tools::path::unique_folder_name().unwrap(); + let temp_path = pth::path::unique_folder_name().unwrap(); let config = Config::default() .path( format!( "./{}", temp_path ) ) diff --git a/module/move/unitore/tests/query_execute.rs b/module/move/unitore/tests/query_execute.rs index 4215971781..0e47c9e576 100644 --- a/module/move/unitore/tests/query_execute.rs +++ b/module/move/unitore/tests/query_execute.rs @@ -41,14 +41,14 @@ fn query_execute() -> Result< () > assert!( res.is_ok() ); // test action - let rt = tokio::runtime::Runtime::new()?; + let rt = tokio::runtime::Runtime::new()?; let ca = CommandsAggregator::former() .command( "query.execute" ) .hint( "hint" ) .long_hint( "long_hint" ) .subject().hint( "SQL query" ).kind( Type::String ).optional( false ).end() .routine( move | o : VerifiedCommand | - { + { let mut f_store = MockStore::new(); f_store .expect_query_execute() @@ -62,19 +62,19 @@ fn query_execute() -> Result< () > ] ) ) ) - ; + ; _ = rt.block_on( async move { let query_arg = o.args .get_owned::< String >( 0 ) ; - + let query_str = query_arg.unwrap(); query::query_execute( f_store, query_str ).await - } ); + } ); } ) .end() - .perform(); + .perform(); let entries = ca.perform( vec![ ".query.execute".to_string(), "SELECT title FROM frame".into() ] ); assert!( entries.is_ok() ); Ok( () ) @@ -84,7 +84,7 @@ fn query_execute() -> Result< () > async fn query_feeds() -> Result< () > { let path = PathBuf::from( "./tests/fixtures/test_config.toml" ); - let temp_path = proper_path_tools::path::unique_folder_name().unwrap(); + let temp_path = pth::path::unique_folder_name().unwrap(); let config = sled::Config::default() .path( format!( "./{}", temp_path ) ) @@ -114,7 +114,7 @@ async fn query_feeds() -> Result< () > #[ tokio::test ] async fn query_frames() -> Result< () > { - let temp_path = proper_path_tools::path::unique_folder_name().unwrap(); + let temp_path = pth::path::unique_folder_name().unwrap(); let config = sled::Config::default() .path( format!( "./{}", temp_path ) ) @@ -160,7 +160,7 @@ async fn query_frames() -> Result< () > async fn query_configs() -> Result< () > { let path = PathBuf::from( "./tests/fixtures/test_config.toml" ); - let temp_path = proper_path_tools::path::unique_folder_name().unwrap(); + let temp_path = pth::path::unique_folder_name().unwrap(); let config = sled::Config::default() .path( format!( "./{}", temp_path ) ) @@ -182,6 +182,6 @@ async fn query_configs() -> Result< () > { assert!( false ); } - + Ok( () ) } diff --git a/module/move/unitore/tests/table_list.rs b/module/move/unitore/tests/table_list.rs index ff06deae00..88b16d519e 100644 --- a/module/move/unitore/tests/table_list.rs +++ b/module/move/unitore/tests/table_list.rs @@ -13,7 +13,7 @@ use error_tools::untyped::Result; #[ tokio::test ] async fn table_list() -> Result< () > { - let temp_path = proper_path_tools::path::unique_folder_name().unwrap(); + let temp_path = pth::path::unique_folder_name().unwrap(); let config = Config::default() .path( format!( "./{}", temp_path ) ) @@ -30,7 +30,7 @@ async fn table_list() -> Result< () > .map( | row | row[ 1 ].clone() ) .collect::< Vec< _ > >() ; - + assert_eq!( column_names.len(), 9 ); assert!( column_names.contains( &Str( String::from( "published") ) ) ); assert!( column_names.contains( &Str( String::from( "authors") ) ) ); diff --git a/module/move/unitore/tests/tables_list.rs b/module/move/unitore/tests/tables_list.rs index f740e94b08..7f5fbb57f7 100644 --- a/module/move/unitore/tests/tables_list.rs +++ b/module/move/unitore/tests/tables_list.rs @@ -9,7 +9,7 @@ use error_tools::untyped::Result; #[ tokio::test ] async fn tables_list() -> Result< () > { - let temp_path = proper_path_tools::path::unique_folder_name().unwrap(); + let temp_path = pth::path::unique_folder_name().unwrap(); let config = Config::default() .path( format!( "./{}", temp_path ) ) diff --git a/module/move/wca/Cargo.toml b/module/move/wca/Cargo.toml index eab9096bd4..da8d1227b6 100644 --- a/module/move/wca/Cargo.toml +++ b/module/move/wca/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wca" -version = "0.21.0" +version = "0.23.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/move/wca/License b/module/move/wca/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/move/wca/License +++ b/module/move/wca/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/move/wca/src/ca/executor/mod.rs b/module/move/wca/src/ca/executor/mod.rs index 77789544d0..1793a9d23f 100644 --- a/module/move/wca/src/ca/executor/mod.rs +++ b/module/move/wca/src/ca/executor/mod.rs @@ -1,3 +1,5 @@ +mod private {} + crate::mod_interface! { diff --git a/module/move/wca/src/ca/grammar/mod.rs b/module/move/wca/src/ca/grammar/mod.rs index f31e992b38..28a87f9e2b 100644 --- a/module/move/wca/src/ca/grammar/mod.rs +++ b/module/move/wca/src/ca/grammar/mod.rs @@ -1,3 +1,5 @@ +mod private {} + crate::mod_interface! { /// User grammar settings. diff --git a/module/move/wca/src/ca/mod.rs b/module/move/wca/src/ca/mod.rs index 3526d2c8fa..66c6832f28 100644 --- a/module/move/wca/src/ca/mod.rs +++ b/module/move/wca/src/ca/mod.rs @@ -2,6 +2,8 @@ //! Commands aggregator library. //! +mod private {} + crate::mod_interface! { diff --git a/module/move/wca/src/ca/parser/mod.rs b/module/move/wca/src/ca/parser/mod.rs index 6d21385d36..50322eee12 100644 --- a/module/move/wca/src/ca/parser/mod.rs +++ b/module/move/wca/src/ca/parser/mod.rs @@ -1,3 +1,5 @@ +mod private {} + crate::mod_interface! { /// This module defines a raw representation of parsed commands, providing a foundation for further processing and @@ -5,7 +7,7 @@ crate::mod_interface! /// a straightforward and easy-to-work-with format, allowing for efficient manipulation and subsequent conversion to /// other representations. layer command; - + /// This module is responsible for processing command-line arguments and parsing them into a raw representation of a /// program containing multiple parsed commands. The input list of arguments is transformed into a structured format, /// allowing the program to efficiently handle and manipulate the parsed commands. diff --git a/module/move/wca/src/ca/tool/mod.rs b/module/move/wca/src/ca/tool/mod.rs index 116804b97d..91290592a7 100644 --- a/module/move/wca/src/ca/tool/mod.rs +++ b/module/move/wca/src/ca/tool/mod.rs @@ -1,3 +1,5 @@ +mod private {} + crate::mod_interface! { diff --git a/module/move/wca/src/ca/verifier/mod.rs b/module/move/wca/src/ca/verifier/mod.rs index 7ed35ae7b9..4723d0bdcc 100644 --- a/module/move/wca/src/ca/verifier/mod.rs +++ b/module/move/wca/src/ca/verifier/mod.rs @@ -1,3 +1,5 @@ +mod private {} + crate::mod_interface! { /// Represents a grammatically correct command with a phrase descriptor, a list of command subjects, and a set of command options.. diff --git a/module/move/wca/src/lib.rs b/module/move/wca/src/lib.rs index c318aa58fd..7f42a20e14 100644 --- a/module/move/wca/src/lib.rs +++ b/module/move/wca/src/lib.rs @@ -11,6 +11,8 @@ use mod_interface::mod_interface; pub mod ca; +mod private {} + crate::mod_interface! { use super::ca; diff --git a/module/move/willbe/Cargo.toml b/module/move/willbe/Cargo.toml index a1cd2b21d8..4f16918129 100644 --- a/module/move/willbe/Cargo.toml +++ b/module/move/willbe/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "willbe" -version = "0.15.0" +version = "0.20.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -41,7 +41,7 @@ enabled = [ "iter_tools/enabled", "mod_interface/enabled", "wca/enabled", - "proper_path_tools/enabled", + "pth/enabled", "process_tools/enabled", "derive_tools/enabled", "data_type/enabled", @@ -88,7 +88,7 @@ former = { workspace = true, features = [ "default" ] } iter_tools = { workspace = true, features = [ "default" ] } mod_interface = { workspace = true, features = [ "default" ] } wca = { workspace = true, features = [ "default" ] } -proper_path_tools = { workspace = true, features = [ "default", "path_utf8" ] } +pth = { workspace = true, features = [ "default", "path_utf8" ] } process_tools = { workspace = true, features = [ "default" ] } derive_tools = { workspace = true, features = [ "derive_display", "derive_from_str", "derive_deref", "derive_from", "derive_as_ref" ] } data_type = { workspace = true, features = [ "either" ] } diff --git a/module/move/willbe/License b/module/move/willbe/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/move/willbe/License +++ b/module/move/willbe/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/move/willbe/src/action/deploy_renew.rs b/module/move/willbe/src/action/deploy_renew.rs index 2a6d3b52fd..0f1c965332 100644 --- a/module/move/willbe/src/action/deploy_renew.rs +++ b/module/move/willbe/src/action/deploy_renew.rs @@ -5,146 +5,76 @@ mod private use error::{ untyped::Context }; use tool::template::*; - // /// Template for creating deploy files. - // /// - // /// Includes terraform deploy options to GCP, and Hetzner, - // /// a Makefile for useful commands, and a key directory. - // #[ derive( Debug ) ] - // pub struct DeployTemplate - // { - // files : DeployTemplateFiles, - // parameters : TemplateParameters, - // values : TemplateValues, - // } - - // // qqq : for Viktor : why DeployTemplate can't be part of template.rs? - - // impl Template< DeployTemplateFiles > for DeployTemplate - // { - // fn create_all( self, path : &Path ) -> error::untyped::Result< () > - // { - // self.files.create_all( path, &self.values ) - // } - - // fn parameters( &self ) -> &TemplateParameters - // { - // &self.parameters - // } - - // fn set_values( &mut self, values : TemplateValues ) - // { - // self.values = values - // } - - // fn get_values( &self ) -> &TemplateValues - // { - // &self.values - // } - - // fn get_values_mut( &mut self ) -> &mut TemplateValues - // { - // &mut self.values - // } - - // fn parameter_storage( &self ) -> &Path { - // "./.deploy_template.toml".as_ref() - // } - - // fn template_name( &self ) -> &'static str { - // "deploy" - // } - // } - - // impl Default for DeployTemplate - // { - // fn default() -> Self - // { - // let parameters = TemplateParameters::former() - // .parameter( "gcp_project_id" ).is_mandatory( true ).end() - // .parameter( "gcp_region" ).end() - // .parameter( "gcp_artifact_repo_name" ).end() - // .parameter( "docker_image_name" ).end() - // .form(); - - // Self - // { - // files : Default::default(), - // parameters, - // values : Default::default(), - // } - // } - // } - - // // qqq : for Viktor : is that structure required? - // /// Files for the deploy template. - // /// - // /// Default implementation contains all required files. - // #[ derive( Debug ) ] - // pub struct DeployTemplateFiles( Vec< TemplateFileDescriptor > ); - - // impl Default for DeployTemplateFiles - // { - // fn default() -> Self - // { - // let formed = TemplateFilesBuilder::former() - // // root - // .file().data( include_str!( "../../template/deploy/.deploy_template.toml.hbs" ) ).path( "./.deploy_template.toml" ).mode( WriteMode::TomlExtend ).is_template( true ).end() - // .file().data( include_str!( "../../template/deploy/Makefile.hbs" ) ).path( "./Makefile" ).is_template( true ).end() - // // /key - // .file().data( include_str!( "../../template/deploy/key/pack.sh" ) ).path( "./key/pack.sh" ).end() - // .file().data( include_str!( "../../template/deploy/key/Readme.md" ) ).path( "./key/Readme.md" ).end() - // // /deploy/ - // .file().data( include_str!( "../../template/deploy/deploy/Dockerfile" ) ).path( "./deploy/Dockerfile" ).end() - // .file().data( include_str!( "../../template/deploy/deploy/Readme.md" ) ).path( "./deploy/Readme.md" ).end() - // // /deploy/gar - // .file().data( include_str!( "../../template/deploy/deploy/gar/Readme.md" ) ).path( "./deploy/gar/Readme.md" ).end() - // .file().data( include_str!( "../../template/deploy/deploy/gar/main.tf" ) ).path( "./deploy/gar/main.tf" ).end() - // .file().data( include_str!( "../../template/deploy/deploy/gar/outputs.tf" ) ).path( "./deploy/gar/outputs.tf" ).end() - // .file().data( include_str!( "../../template/deploy/deploy/gar/variables.tf" ) ).path( "./deploy/gar/variables.tf" ).end() - // // /deploy/gce - // .file().data( include_str!( "../../template/deploy/deploy/gce/Readme.md" ) ).path( "./deploy/gce/Readme.md" ).end() - // .file().data( include_str!( "../../template/deploy/deploy/gce/main.tf" ) ).path( "./deploy/gce/main.tf" ).end() - // .file().data( include_str!( "../../template/deploy/deploy/gce/outputs.tf" ) ).path( "./deploy/gce/outputs.tf" ).end() - // .file().data( include_str!( "../../template/deploy/deploy/gce/variables.tf" ) ).path( "./deploy/gce/variables.tf" ).end() - // // /deploy/gce/templates - // .file().data( include_str!( "../../template/deploy/deploy/gce/templates/cloud-init.tpl" ) ).path( "./deploy/gce/templates/cloud-init.tpl" ).end() - // // /deploy/gcs - // .file().data( include_str!( "../../template/deploy/deploy/gcs/main.tf" ) ).path( "./deploy/gcs/main.tf" ).end() - // // /deploy/hetzner - // .file().data( include_str!( "../../template/deploy/deploy/hetzner/main.tf" ) ).path( "./deploy/hetzner/main.tf" ).end() - // .file().data( include_str!( "../../template/deploy/deploy/hetzner/outputs.tf" ) ).path( "./deploy/hetzner/outputs.tf" ).end() - // .file().data( include_str!( "../../template/deploy/deploy/hetzner/variables.tf" ) ).path( "./deploy/hetzner/variables.tf" ).end() - // // /deploy/hetzner/templates - // .file().data( include_str!( "../../template/deploy/deploy/hetzner/templates/cloud-init.tpl" ) ).path( "./deploy/hetzner/templates/cloud-init.tpl" ).end() - // // /deploy/aws - // .file().data( include_str!( "../../template/deploy/deploy/aws/main.tf" ) ).path( "./deploy/aws/main.tf" ).end() - // .file().data( include_str!( "../../template/deploy/deploy/aws/outputs.tf" ) ).path( "./deploy/aws/outputs.tf" ).end() - // .file().data( include_str!( "../../template/deploy/deploy/aws/variables.tf" ) ).path( "./deploy/aws/variables.tf" ).end() - // // /deploy/aws/templates - // .file().data( include_str!( "../../template/deploy/deploy/aws/templates/cloud-init.tpl" ) ).path( "./deploy/aws/templates/cloud-init.tpl" ).end() - // .form(); - - // Self( formed.files ) - // } - // } - - // // qqq : for Viktor : should not be required - // impl TemplateFiles for DeployTemplateFiles {} - // // qqq : for Viktor : should not be required - // impl IntoIterator for DeployTemplateFiles - // { - // type Item = TemplateFileDescriptor; - - // type IntoIter = std::vec::IntoIter< Self::Item >; - - // fn into_iter( self ) -> Self::IntoIter - // { - // self.0.into_iter() - // } - // } + /// Template for creating deploy files. + /// + /// Includes terraform deploy options to GCP, and Hetzner, + /// a Makefile for useful commands, and a key directory. + #[ derive( Debug ) ] + pub struct DeployTemplate; + + impl DeployTemplate + { + /// Creates am instance of `[TemplateHolder]` for deployment template. + /// + /// Used for properly initializing a template + pub fn default() -> TemplateHolder + { + let parameters = TemplateParameters::former() + .parameter( "gcp_project_id" ).is_mandatory( true ).end() + .parameter( "gcp_region" ).end() + .parameter( "gcp_artifact_repo_name" ).end() + .parameter( "docker_image_name" ).end() + .form(); + + TemplateHolder + { + files : get_deploy_template_files(), + parameters, + values : Default::default(), + parameter_storage : "./.deploy_template.toml".as_ref(), + template_name : "deploy", + } + } + } - // aaa : for Petro : redundant function - // aaa : this function not my, but ok I'll remove it. + fn get_deploy_template_files() -> Vec< TemplateFileDescriptor > + { + let formed = TemplateFilesBuilder::former() + // root + .file().data( include_str!( "../../template/deploy/.deploy_template.toml.hbs" ) ).path( "./.deploy_template.toml" ).mode( WriteMode::TomlExtend ).is_template( true ).end() + .file().data( include_str!( "../../template/deploy/Makefile.hbs" ) ).path( "./Makefile" ).is_template( true ).end() + // /key + .file().data( include_str!( "../../template/deploy/key/pack.sh" ) ).path( "./key/pack.sh" ).end() + .file().data( include_str!( "../../template/deploy/key/Readme.md" ) ).path( "./key/Readme.md" ).end() + // /deploy/ + .file().data( include_str!( "../../template/deploy/deploy/redeploy.sh" ) ).path( "./deploy/redeploy.sh" ).end() + .file().data( include_str!( "../../template/deploy/deploy/cloud-init.tpl.hbs" ) ).path( "./deploy/cloud-init.tpl" ).is_template( true ).end() + .file().data( include_str!( "../../template/deploy/deploy/Dockerfile" ) ).path( "./deploy/Dockerfile" ).end() + .file().data( include_str!( "../../template/deploy/deploy/Readme.md" ) ).path( "./deploy/Readme.md" ).end() + // /deploy/gar + .file().data( include_str!( "../../template/deploy/deploy/gar/Readme.md" ) ).path( "./deploy/gar/Readme.md" ).end() + .file().data( include_str!( "../../template/deploy/deploy/gar/main.tf.hbs" ) ).path( "./deploy/gar/main.tf" ).is_template( true ).end() + .file().data( include_str!( "../../template/deploy/deploy/gar/outputs.tf" ) ).path( "./deploy/gar/outputs.tf" ).end() + .file().data( include_str!( "../../template/deploy/deploy/gar/variables.tf" ) ).path( "./deploy/gar/variables.tf" ).end() + // /deploy/gce + .file().data( include_str!( "../../template/deploy/deploy/gce/Readme.md" ) ).path( "./deploy/gce/Readme.md" ).end() + .file().data( include_str!( "../../template/deploy/deploy/gce/main.tf.hbs" ) ).path( "./deploy/gce/main.tf" ).is_template( true ).end() + .file().data( include_str!( "../../template/deploy/deploy/gce/outputs.tf.hbs" ) ).path( "./deploy/gce/outputs.tf" ).is_template( true ).end() + .file().data( include_str!( "../../template/deploy/deploy/gce/variables.tf" ) ).path( "./deploy/gce/variables.tf" ).end() + // /deploy/gcs + .file().data( include_str!( "../../template/deploy/deploy/gcs/main.tf" ) ).path( "./deploy/gcs/main.tf" ).end() + // /deploy/hetzner + .file().data( include_str!( "../../template/deploy/deploy/hetzner/main.tf.hbs" ) ).path( "./deploy/hetzner/main.tf" ).is_template( true ).end() + .file().data( include_str!( "../../template/deploy/deploy/hetzner/outputs.tf.hbs" ) ).path( "./deploy/hetzner/outputs.tf" ).is_template( true ).end() + .file().data( include_str!( "../../template/deploy/deploy/hetzner/variables.tf" ) ).path( "./deploy/hetzner/variables.tf" ).end() + // /deploy/aws + .file().data( include_str!( "../../template/deploy/deploy/aws/main.tf" ) ).path( "./deploy/aws/main.tf" ).end() + .file().data( include_str!( "../../template/deploy/deploy/aws/outputs.tf" ) ).path( "./deploy/aws/outputs.tf" ).end() + .file().data( include_str!( "../../template/deploy/deploy/aws/variables.tf" ) ).path( "./deploy/aws/variables.tf" ).end() + .form(); + + formed.files + } fn dir_name_to_formatted( dir_name : &str, separator : &str ) -> String { @@ -179,7 +109,6 @@ mod private template .values .insert_if_empty( "gcp_artifact_repo_name", wca::Value::String( artifact_repo_name ) ); - template .values .insert_if_empty( "docker_image_name", wca::Value::String( docker_image_name ) ); @@ -187,7 +116,7 @@ mod private .values .insert_if_empty( "gcp_region", wca::Value::String( "europe-central2".into() ) ); } - template.create_all( path )?; + template.files.create_all( path, &template.values )?; Ok( () ) } @@ -196,5 +125,5 @@ mod private crate::mod_interface! { orphan use deploy_renew; - //orphan use DeployTemplate; + orphan use DeployTemplate; } diff --git a/module/move/willbe/src/action/mod.rs b/module/move/willbe/src/action/mod.rs index 728271c2a5..c824bfd6f7 100644 --- a/module/move/willbe/src/action/mod.rs +++ b/module/move/willbe/src/action/mod.rs @@ -1,3 +1,5 @@ +mod private {} + crate::mod_interface! { /// Deploy new. diff --git a/module/move/willbe/src/action/readme_modules_headers_renew.rs b/module/move/willbe/src/action/readme_modules_headers_renew.rs index 5370a9d0fa..9b613d97fa 100644 --- a/module/move/willbe/src/action/readme_modules_headers_renew.rs +++ b/module/move/willbe/src/action/readme_modules_headers_renew.rs @@ -179,7 +179,7 @@ mod private &self.module_name ) { - let relative_path = proper_path_tools::path::path_relative + let relative_path = pth::path::path_relative ( workspace_path.try_into().unwrap(), name diff --git a/module/move/willbe/src/command/deploy_renew.rs b/module/move/willbe/src/command/deploy_renew.rs index c66107fe8d..7e1e68e476 100644 --- a/module/move/willbe/src/command/deploy_renew.rs +++ b/module/move/willbe/src/command/deploy_renew.rs @@ -4,9 +4,7 @@ mod private use wca::VerifiedCommand; use error::{ untyped::Context }; - use tool::TemplateHolder; - //use tool::template::Template; - // use action::deploy_renew::*; + use action::deploy_renew::*; /// /// Create new deploy. @@ -17,7 +15,7 @@ mod private { let current_dir = std::env::current_dir()?; - let mut template = TemplateHolder::default(); + let mut template = DeployTemplate::default(); _ = template.load_existing_params( ¤t_dir ); let parameters = template.parameters(); let mut values = parameters.values_from_props( &o.props ); diff --git a/module/move/willbe/src/command/mod.rs b/module/move/willbe/src/command/mod.rs index f6115c3f10..bae53834e1 100644 --- a/module/move/willbe/src/command/mod.rs +++ b/module/move/willbe/src/command/mod.rs @@ -128,8 +128,8 @@ with_gitpod: If set to 1, a column with a link to Gitpod will be added. Clicking .end() .command( "test" ) - .hint( "execute tests in specific packages" ) - .long_hint( "this command runs tests in designated packages based on the provided path. It allows for inclusion and exclusion of features, testing on different Rust version channels, parallel execution, and feature combination settings." ) + .hint( "List crate features to run tests for each combination, aiming for full test coverage of the crate." ) + .long_hint( "List crate features, different optimization level (Release & Debug) and toolchain (stable & nightly) to run tests for each combination. Π‘an be used for packages as well as workspaces. Supports parallel execution." ) .subject().hint( "A path to directories with packages. If no path is provided, the current directory is used." ).kind( Type::Path ).optional( true ).end() .property( "dry" ).hint( "Enables 'dry run'. Does not run tests, only simulates. Default is `true`." ).kind( Type::Bool ).optional( true ).end() .property( "temp" ).hint( "If flag is `true` all test will be running in temporary directories. Default `true`." ).kind( Type::Bool ).optional( true ).end() @@ -225,7 +225,7 @@ with_gitpod: If set to 1, a column with a link to Gitpod will be added. Clicking .command( "deploy.renew" ) .hint( "Create deploy template" ) - .long_hint( "Creates static files and directories.\nDeployment to different hosts is done via Makefile." ) + .long_hint( "Creates static files and directories.\nDeployment to different hosts is done via Makefile.\n\nUsage example: deploy.renew gcp_project_id:wtools" ) .property( "gcp_project_id" ) .hint( "Google Cloud Platform Project id for image deployment, terraform state bucket, and, if specified, GCE instance deployment." ) .kind( Type::String ) @@ -239,12 +239,12 @@ with_gitpod: If set to 1, a column with a link to Gitpod will be added. Clicking .property( "gcp_artifact_repo_name" ) .hint( "Google Cloud Platform Artifact Repository to store docker image in. Will be generated from current directory name if unspecified." ) .kind( Type::String ) - .optional( false ) + .optional( true ) .end() .property( "docker_image_name" ) .hint( "Docker image name to build and deploy. Will be generated from current directory name if unspecified." ) .kind( Type::String ) - .optional( false ) + .optional( true ) .end() .routine( command::deploy_renew ) .end() diff --git a/module/move/willbe/src/entity/mod.rs b/module/move/willbe/src/entity/mod.rs index 6f26700128..100b331e89 100644 --- a/module/move/willbe/src/entity/mod.rs +++ b/module/move/willbe/src/entity/mod.rs @@ -1,3 +1,5 @@ +mod private {} + crate::mod_interface! { /// Rust toolchain channel: stable/nightly. diff --git a/module/move/willbe/src/tool/mod.rs b/module/move/willbe/src/tool/mod.rs index 060a323c2f..719b616b4b 100644 --- a/module/move/willbe/src/tool/mod.rs +++ b/module/move/willbe/src/tool/mod.rs @@ -1,3 +1,5 @@ +mod private {} + crate::mod_interface! { diff --git a/module/move/willbe/src/tool/path.rs b/module/move/willbe/src/tool/path.rs index c07f0b3d6e..028bbd4189 100644 --- a/module/move/willbe/src/tool/path.rs +++ b/module/move/willbe/src/tool/path.rs @@ -6,7 +6,7 @@ mod private crate::mod_interface! { - use ::proper_path_tools; - own use ::proper_path_tools::own::*; + use ::pth; + own use ::pth::own::*; } diff --git a/module/move/willbe/src/tool/template.rs b/module/move/willbe/src/tool/template.rs index affe4072be..bd90b0b5d7 100644 --- a/module/move/willbe/src/tool/template.rs +++ b/module/move/willbe/src/tool/template.rs @@ -15,15 +15,10 @@ mod private }; use error::untyped::Context; - // qqq : for Nikita : is that trait really necessary? - // Template - remove - // DeployTemplate - move here - // DeployTemplateFiles - remove - - /// Template for creating deploy files. + /// Container for templates. /// - /// Includes terraform deploy options to GCP, and Hetzner, - /// a Makefile for useful commands, and a key directory. + /// Includes files to create, parameters that those templates accept, + /// and values for those parameters. #[ derive( Debug ) ] pub struct TemplateHolder { @@ -33,11 +28,15 @@ mod private pub parameters : TemplateParameters, /// The values associated with the template. pub values : TemplateValues, + /// Path to the parameter storage for recovering values + /// for already generated templated files. + pub parameter_storage : &'static Path, + /// Name of the template to generate + pub template_name : &'static str, } impl TemplateFiles for Vec< TemplateFileDescriptor > {} - // qqq : for Viktor : why DeployTemplate can't be part of template.rs? impl TemplateHolder { @@ -95,27 +94,6 @@ mod private &mut self.values } - /// Returns the path to the parameter storage file. - /// - /// # Returns - /// - /// A reference to a `Path` representing the parameter storage file. - pub fn parameter_storage( &self ) -> &Path - { - "./.deploy_template.toml".as_ref() - // qqq : for Mykyta : hardcode? - } - - /// Returns the name of the template. - /// - /// # Returns - /// - /// A static string slice representing the template name. - pub fn template_name( &self ) -> &'static str - { - "deploy" - } - /// Loads existing parameters from the specified path and updates the template values. /// /// # Parameters @@ -127,10 +105,10 @@ mod private /// An `Option` which is `Some(())` if the parameters are loaded successfully, or `None` otherwise. pub fn load_existing_params( &mut self, path : &Path ) -> Option< () > { - let data = fs::read_to_string( path.join( self.parameter_storage() ) ).ok()?; + let data = fs::read_to_string( path.join( self.parameter_storage ) ).ok()?; let document = data.parse::< toml_edit::Document >().ok()?; let parameters : Vec< _ > = self.parameters().descriptors.iter().map( | d | &d.parameter ).cloned().collect(); - let template_table = document.get( self.template_name() )?; + let template_table = document.get( self.template_name )?; for parameter in parameters { let value = template_table.get( ¶meter ) @@ -164,26 +142,6 @@ mod private } } - impl Default for TemplateHolder - { - fn default() -> Self - { - let parameters = TemplateParameters::former() - .parameter( "gcp_project_id" ).is_mandatory( true ).end() - .parameter( "gcp_region" ).end() - .parameter( "gcp_artifact_repo_name" ).end() - .parameter( "docker_image_name" ).end() - .form(); - - Self - { - files : Default::default(), - parameters, - values : Default::default(), - } - } - } - /// Files stored in a template. /// /// Can be iterated over, consuming the owner of the files. diff --git a/module/move/willbe/src/wtools.rs b/module/move/willbe/src/wtools.rs index 1735805c0b..4fe43d10e9 100644 --- a/module/move/willbe/src/wtools.rs +++ b/module/move/willbe/src/wtools.rs @@ -21,8 +21,8 @@ // /// Collection of function and structures to manipulate paths. // pub mod path_tools // { -// // pub use proper_path_tools::own::*; -// // pub use proper_path_tools::own::path; -// // zzz : make use proper_path_tools::own::path working +// // pub use pth::own::*; +// // pub use pth::own::path; +// // zzz : make use pth::own::path working // pub use proper_path::own as path; // } diff --git a/module/move/willbe/template/deploy/Makefile.hbs b/module/move/willbe/template/deploy/Makefile.hbs index 2f3461aea8..f978b887eb 100644 --- a/module/move/willbe/template/deploy/Makefile.hbs +++ b/module/move/willbe/template/deploy/Makefile.hbs @@ -1,16 +1,5 @@ .PHONY: deploy -# Secrets that can be provided via ENV vars or files in ./key/ directory. - -# Hetzner API token -export SECRET_CSP_HETZNER ?= $(shell cat key/SECRET_CSP_HETZNER 2> /dev/null) -# Cloud Storage file encryption key -export SECRET_STATE_ARCHIVE_KEY ?= $(shell cat key/SECRET_STATE_ARCHIVE_KEY 2> /dev/null) -# AWS Access Key id -export SECRET_AWS_ACCESS_KEY_ID ?= $(shell cat key/SECRET_AWS_ACCESS_KEY_ID 2> /dev/null) -# AWS Access Key -export SECRET_AWS_ACCESS_KEY ?= $(shell cat key/SECRET_AWS_ACCESS_KEY 2> /dev/null) - # Configuration variables for deployment. Can be edited for desired behavior. # Base terraform directory @@ -24,9 +13,9 @@ export TF_VAR_REPO_NAME ?= {{gcp_artifact_repo_name}} # Pushed image name export TF_VAR_IMAGE_NAME ?= {{docker_image_name}} # Path to the service account credentials -export google_sa_creds ?= key/service_account.json +export google_sa_creds ?= key/-service_account.json # Cloud Storage bucket name -export TF_VAR_BUCKET_NAME ?= uaconf_tfstate +export TF_VAR_BUCKET_NAME ?= {{docker_image_name}}_tfstate # Specifies where to deploy the project. Possible values: `hetzner`, `gce`, `aws` export CSP ?= hetzner @@ -43,129 +32,118 @@ export AWS_ACCESS_KEY_ID ?= $(SECRET_AWS_ACCESS_KEY_ID) # AWS Secret Access key for deploying to an EC2 instance export AWS_SECRET_ACCESS_KEY ?= $(SECRET_AWS_ACCESS_KEY) -# Check Hetzner and deployment related keys +# Check Hetzner and deployment related keys check-hetzner-keys: - @[ -f key/SECRET_CSP_HETZNER ] \ - || [ ! -z "${SECRET_CSP_HETZNER}" ] \ - || { echo "ERROR: File key/SECRET_CSP_HETZNER does not exist"; exit 1; } + @[ ! -z "${SECRET_CSP_HETZNER}" ] \ + || { echo "ERROR: Key SECRET_CSP_HETZNER does not exist"; exit 1; } -# Check AWS and deployment related keys +# Check AWS and deployment related keys check-aws-keys: - @[ -f key/SECRET_AWS_ACCESS_KEY_ID ] \ - || [ ! -z "${SECRET_AWS_ACCESS_KEY_ID}" ] \ - || echo "ERROR: File key/SECRET_AWS_ACCESS_KEY_ID does not exist" - @[ -f key/SECRET_AWS_ACCESS_KEY ] \ - || [ ! -z "${SECRET_AWS_ACCESS_KEY}" ] \ - || echo "ERROR: File key/SECRET_AWS_ACCESS_KEY does not exist" - @[ -f key/SECRET_AWS_ACCESS_KEY_ID ] \ - || [ ! -z "${SECRET_AWS_ACCESS_KEY_ID}" ] \ - || exit 1 - @[ -f key/SECRET_AWS_ACCESS_KEY ] \ - || [ ! -z "${SECRET_AWS_ACCESS_KEY}" ] \ - || exit 1 + @[ ! -z "${SECRET_AWS_ACCESS_KEY_ID}" ] \ + || echo "ERROR: Key SECRET_AWS_ACCESS_KEY_ID does not exist" + @[ ! -z "${SECRET_AWS_ACCESS_KEY}" ] \ + || echo "ERROR: Key SECRET_AWS_ACCESS_KEY does not exist" + @[ ! -z "${SECRET_AWS_ACCESS_KEY_ID}" ] || exit 1 + @[ ! -z "${SECRET_AWS_ACCESS_KEY}" ] || exit 1 check-gce-keys: - @echo "All required GCE keys are the same as GCP keys" + @echo "All required GCE keys are the same as GCP keys" # Check if required GCP keys are present check-gcp-keys: - @[ -f key/service_account.json ] \ - || echo "ERROR: File key/service_account.json does not exist" - @[ -f key/SECRET_STATE_ARCHIVE_KEY ] \ - || [ ! -z "${SECRET_STATE_ARCHIVE_KEY}" ] \ - || echo "ERROR: File key/SECRET_STATE_ARCHIVE_KEY does not exist" - @[ -f key/service_account.json ] \ - || exit 1 - @[ -f key/SECRET_STATE_ARCHIVE_KEY ] \ - || [ ! -z "${SECRET_STATE_ARCHIVE_KEY}" ] \ - || exit 1 + @[ -f key/-service_account.json ] \ + || echo "ERROR: Key file key/-service_account.json does not exist" + @[ ! -z "${SECRET_STATE_ARCHIVE_KEY}" ] \ + || echo "ERROR: Key SECRET_STATE_ARCHIVE_KEY does not exist" + @[ -f key/-service_account.json ] || exit 1 + @[ ! -z "${SECRET_STATE_ARCHIVE_KEY}" ] || exit 1 # Start local docker container start: - docker compose up -d + docker compose up -d # Stop local docker container stop: - docker compose down + docker compose down # Remove created docker image clean: stop - docker rmi $(TF_VAR_IMAGE_NAME) - docker buildx prune -af + docker rmi $(TF_VAR_IMAGE_NAME) + docker buildx prune -af # Install gcloud for Debian/Ubuntu install-gcloud: - # GCloud - sudo apt-get update - sudo apt-get install -y apt-transport-https ca-certificates gnupg curl sudo - curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg - echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list - sudo apt-get update && sudo apt-get install -y google-cloud-cli + # GCloud + sudo apt-get update + sudo apt-get install -y apt-transport-https ca-certificates gnupg curl sudo + curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg + echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list + sudo apt-get update && sudo apt-get install -y google-cloud-cli # Install terraform for Debian/Ubuntu install-terraform: - sudo apt-get update && sudo apt-get install -y gnupg software-properties-common - wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg - gpg --no-default-keyring --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg --fingerprint - echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list - sudo apt update && sudo apt-get install terraform + sudo apt-get update && sudo apt-get install -y gnupg software-properties-common + wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg + gpg --no-default-keyring --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg --fingerprint + echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list + sudo apt update && sudo apt-get install terraform # Install gcloud and terraform install: install-gcloud install-terraform - gcloud --version - terraform -version + gcloud --version + terraform -version # Login to GCP with user account gcp-auth: - gcloud auth application-default login + gcloud auth application-default login # Authorize to GCP with service account gcp-service: - gcloud auth activate-service-account --key-file=$(google_sa_creds) + gcloud auth activate-service-account --key-file=$(google_sa_creds) # Add docker repo auth helper gcp-docker: - gcloud auth configure-docker $(TF_VAR_REGION)-docker.pkg.dev --quiet + gcloud auth configure-docker $(TF_VAR_REGION)-docker.pkg.dev --quiet # Initializes all terraform projects # Downloads required modules and validates .tf files tf-init: - terraform -chdir=$(tf_dir)/gar init - terraform -chdir=$(tf_dir)/gce init - terraform -chdir=$(tf_dir)/hetzner init - terraform -chdir=$(tf_dir)/aws init + terraform -chdir=$(tf_dir)/gar init + terraform -chdir=$(tf_dir)/gce init + terraform -chdir=$(tf_dir)/hetzner init + terraform -chdir=$(tf_dir)/aws init # Creates Artifact Registry repository on GCP in specified location create-artifact-repo: tf-init - terraform -chdir=$(tf_dir)/gar apply -auto-approve + terraform -chdir=$(tf_dir)/gar apply -auto-approve # Builds uarust_conf_site image build-image: - docker build . -t name:$(TF_VAR_IMAGE_NAME) -t $(tag) + docker build . -t name:$(TF_VAR_IMAGE_NAME) -t $(tag) # Builds and pushes local docker image to the private repository push-image: gcp-docker create-artifact-repo - docker push $(tag) + docker push $(tag) # Creates GCE instance with the website configured on boot create-gce: check-gce-keys gcp-service state_storage_pull push-image - terraform -chdir=$(tf_dir)/gce apply -auto-approve + terraform -chdir=$(tf_dir)/gce apply -auto-approve # Creates AWS EC2 instance with the website configured on boot create-aws: check-aws-keys gcp-service state_storage_pull push-image - terraform -chdir=$(tf_dir)/aws apply -auto-approve + terraform -chdir=$(tf_dir)/aws apply -auto-approve # Creates Hetzner instance with the website configured on boot create-hetzner: check-hetzner-keys gcp-service state_storage_pull push-image - terraform -chdir=$(tf_dir)/hetzner apply -auto-approve + terraform -chdir=$(tf_dir)/hetzner apply -auto-approve # Deploys everything and updates terraform states deploy-in-container: create-$(CSP) state_storage_push # Deploys using tools from the container deploy: check-gcp-keys build-image - docker build . -t deploy-$(TF_VAR_IMAGE_NAME) -f ./$(tf_dir)/Dockerfile --build-arg google_sa_creds="$(google_sa_creds)" - @docker run -v //var/run/docker.sock:/var/run/docker.sock -v .:/app \ + docker build . -t deploy-$(TF_VAR_IMAGE_NAME) -f ./$(tf_dir)/Dockerfile --build-arg google_sa_creds="$(google_sa_creds)" + @docker run -v //var/run/docker.sock:/var/run/docker.sock -v .:/app \ -e SECRET_STATE_ARCHIVE_KEY=$(SECRET_STATE_ARCHIVE_KEY) \ -e SECRET_CSP_HETZNER=$(SECRET_CSP_HETZNER) \ -e SECRET_AWS_ACCESS_KEY_ID=$(SECRET_AWS_ACCESS_KEY_ID) \ @@ -175,35 +153,39 @@ deploy: check-gcp-keys build-image # Review changes that terraform will do on apply tf-plan: tf-init - terraform -chdir=$(tf_dir)/gar plan - terraform -chdir=$(tf_dir)/gce plan - terraform -chdir=$(tf_dir)/hetzner plan - terraform -chdir=$(tf_dir)/aws plan + terraform -chdir=$(tf_dir)/gar plan + terraform -chdir=$(tf_dir)/gce plan + terraform -chdir=$(tf_dir)/hetzner plan + terraform -chdir=$(tf_dir)/aws plan # Destroy created infrastracture on GCP tf-destroy: tf-init - terraform -chdir=$(tf_dir)/gar destroy - terraform -chdir=$(tf_dir)/gce destroy - terraform -chdir=$(tf_dir)/hetzner destroy - terraform -chdir=$(tf_dir)/aws destroy + terraform -chdir=$(tf_dir)/gar destroy + terraform -chdir=$(tf_dir)/gce destroy + terraform -chdir=$(tf_dir)/hetzner destroy + terraform -chdir=$(tf_dir)/aws destroy # Pushes encrypted terraform state files to the GCS Bucket state_storage_push: - @echo Pushing encrypted terraform state files to the GCS Bucket - @gcloud storage cp $(tf_dir)/gce/terraform.tfstate gs://$(TF_VAR_BUCKET_NAME)/gce.tfstate --encryption-key="$(SECRET_STATE_ARCHIVE_KEY)" - @gcloud storage cp $(tf_dir)/gar/terraform.tfstate gs://$(TF_VAR_BUCKET_NAME)/gar.tfstate --encryption-key="$(SECRET_STATE_ARCHIVE_KEY)" - @gcloud storage cp $(tf_dir)/hetzner/terraform.tfstate gs://$(TF_VAR_BUCKET_NAME)/hetzner.tfstate --encryption-key="$(SECRET_STATE_ARCHIVE_KEY)" - @gcloud storage cp $(tf_dir)/aws/terraform.tfstate gs://$(TF_VAR_BUCKET_NAME)/aws.tfstate --encryption-key="$(SECRET_STATE_ARCHIVE_KEY)" + @echo Pushing encrypted terraform state files to the GCS Bucket + -@gcloud storage cp $(tf_dir)/gce/terraform.tfstate gs://$(TF_VAR_BUCKET_NAME)/gce.tfstate --encryption-key="$(SECRET_STATE_ARCHIVE_KEY)" + -@gcloud storage cp $(tf_dir)/gar/terraform.tfstate gs://$(TF_VAR_BUCKET_NAME)/gar.tfstate --encryption-key="$(SECRET_STATE_ARCHIVE_KEY)" + -@gcloud storage cp $(tf_dir)/hetzner/terraform.tfstate gs://$(TF_VAR_BUCKET_NAME)/hetzner.tfstate --encryption-key="$(SECRET_STATE_ARCHIVE_KEY)" + -@gcloud storage cp $(tf_dir)/aws/terraform.tfstate gs://$(TF_VAR_BUCKET_NAME)/aws.tfstate --encryption-key="$(SECRET_STATE_ARCHIVE_KEY)" # Pulls and decrypts terraform state files to the GCS Bucket state_storage_pull: - @echo Pulling terraform state files to the GCS Bucket - -@gcloud storage cp gs://$(TF_VAR_BUCKET_NAME)/gce.tfstate $(tf_dir)/gce/terraform.tfstate --decryption-keys="$(SECRET_STATE_ARCHIVE_KEY)" - -@gcloud storage cp gs://$(TF_VAR_BUCKET_NAME)/gar.tfstate $(tf_dir)/gar/terraform.tfstate --decryption-keys="$(SECRET_STATE_ARCHIVE_KEY)" - -@gcloud storage cp gs://$(TF_VAR_BUCKET_NAME)/hetzner.tfstate $(tf_dir)/hetzner/terraform.tfstate --decryption-keys="$(SECRET_STATE_ARCHIVE_KEY)" - -@gcloud storage cp gs://$(TF_VAR_BUCKET_NAME)/aws.tfstate $(tf_dir)/aws/terraform.tfstate --decryption-keys="$(SECRET_STATE_ARCHIVE_KEY)" + @echo Pulling terraform state files to the GCS Bucket + -@gcloud storage cp gs://$(TF_VAR_BUCKET_NAME)/gce.tfstate $(tf_dir)/gce/terraform.tfstate --decryption-keys="$(SECRET_STATE_ARCHIVE_KEY)" + -@gcloud storage cp gs://$(TF_VAR_BUCKET_NAME)/gar.tfstate $(tf_dir)/gar/terraform.tfstate --decryption-keys="$(SECRET_STATE_ARCHIVE_KEY)" + -@gcloud storage cp gs://$(TF_VAR_BUCKET_NAME)/hetzner.tfstate $(tf_dir)/hetzner/terraform.tfstate --decryption-keys="$(SECRET_STATE_ARCHIVE_KEY)" + -@gcloud storage cp gs://$(TF_VAR_BUCKET_NAME)/aws.tfstate $(tf_dir)/aws/terraform.tfstate --decryption-keys="$(SECRET_STATE_ARCHIVE_KEY)" # Creates GCS Bucket for terraform states state_storage_init: - terraform -chdir=$(tf_dir)/gcs init - terraform -chdir=$(tf_dir)/gcs apply + terraform -chdir=$(tf_dir)/gcs init + terraform -chdir=$(tf_dir)/gcs apply + +# Destroys GCS Bucket for terraform states +state_storage_destroy: + terraform -chdir=$(tf_dir)/gcs destroy diff --git a/module/move/willbe/template/deploy/deploy/Dockerfile b/module/move/willbe/template/deploy/deploy/Dockerfile index c196de7aff..1fa8f2bf8b 100644 --- a/module/move/willbe/template/deploy/deploy/Dockerfile +++ b/module/move/willbe/template/deploy/deploy/Dockerfile @@ -3,7 +3,7 @@ ENV TF_VERSION=1.7.4 WORKDIR / -# Installation terraform +# Install terraform RUN apt update --allow-releaseinfo-change \ && apt install wget unzip \ && mkdir -p /usr/lib/terraform/${TF_VERSION} \ diff --git a/module/move/willbe/template/deploy/deploy/aws/main.tf b/module/move/willbe/template/deploy/deploy/aws/main.tf index 4e83260aaf..9572193a66 100644 --- a/module/move/willbe/template/deploy/deploy/aws/main.tf +++ b/module/move/willbe/template/deploy/deploy/aws/main.tf @@ -60,17 +60,16 @@ resource "aws_instance" "web" { associate_public_ip_address = true # Startup script for the instance - # Installs docker, gcloud CLI, downloads docker images and starts the container - user_data = templatefile("${path.module}/templates/cloud-init.tpl", { + # Installs docker and gcloud CLI + user_data = templatefile("${path.module}/../cloud-init.tpl", { location = "${var.REGION}" project_id = "${var.PROJECT_ID}" repo_name = "${var.REPO_NAME}" image_name = "${var.IMAGE_NAME}" service_account_creds = "${replace(data.local_sensitive_file.service_account_creds.content, "\n", "")}" - timestamp = "${timestamp()}" }) - user_data_replace_on_change = true + key_name = aws_key_pair.redeploy.key_name } # Static IP address for the instace that will persist on restarts and redeploys @@ -78,3 +77,33 @@ resource "aws_eip" "static" { instance = aws_instance.web.id domain = "vpc" } + +resource "aws_key_pair" "redeploy" { + public_key = data.local_sensitive_file.ssh_public_key.content +} + +resource "terraform_data" "redeploy" { + triggers_replace = timestamp() + + connection { + type = "ssh" + user = "ubuntu" + private_key = data.local_sensitive_file.ssh_private_key.content + host = aws_eip.static.public_ip + } + + provisioner "file" { + source = "${path.module}/../redeploy.sh" + destination = "/tmp/redeploy.sh" + } + + provisioner "remote-exec" { + inline = [ + "#!/bin/bash", + "( tail -f -n1 /var/log/deploy-init.log & ) | grep -q 'Docker configuration file updated.'", + "source /etc/environment", + "chmod +x /tmp/redeploy.sh", + "sudo /tmp/redeploy.sh" + ] + } +} diff --git a/module/move/willbe/template/deploy/deploy/aws/templates/cloud-init.tpl b/module/move/willbe/template/deploy/deploy/aws/templates/cloud-init.tpl deleted file mode 100644 index 7a19732c3a..0000000000 --- a/module/move/willbe/template/deploy/deploy/aws/templates/cloud-init.tpl +++ /dev/null @@ -1,46 +0,0 @@ -#cloud-config - -write_files: -- path: /etc/systemd/system/${image_name}.service - permissions: 0644 - owner: root - content: | - [Unit] - Description=Start ${image_name} docker container. Build: ${timestamp} - Wants=network-online.target - After=network-online.target - - [Service] - Environment="HOME=/root" - ExecStart=/usr/bin/docker run --restart unless-stopped -d -p 80:80 --name=${image_name} ${location}-docker.pkg.dev/${project_id}/${repo_name}/${image_name} -- path: /root/service_account.json - permissions: 0600 - owner: root - content: | - ${service_account_creds} -- path: /root/init.sh - permissions: 0700 - owner: root - content: | - # Install docker - apt update - apt install apt-transport-https ca-certificates curl software-properties-common -y - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - apt update - apt install docker-ce -y - # Install gcloud CLI - curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg - echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list - apt-get update - apt-get install -y google-cloud-cli - # Configure docker with gcloud - gcloud auth activate-service-account --key-file=/root/service_account.json - gcloud auth configure-docker ${location}-docker.pkg.dev --quiet - # Start docker container - systemctl daemon-reload - systemctl start ${image_name}.service - - -runcmd: -- nohup /root/init.sh > /var/log/uaconf-instance-init.log 2>&1 & diff --git a/module/move/willbe/template/deploy/deploy/aws/variables.tf b/module/move/willbe/template/deploy/deploy/aws/variables.tf index ede2b296f3..c536019a13 100644 --- a/module/move/willbe/template/deploy/deploy/aws/variables.tf +++ b/module/move/willbe/template/deploy/deploy/aws/variables.tf @@ -20,5 +20,15 @@ variable "IMAGE_NAME" { # Google Cloud Platform credentials data "local_sensitive_file" "service_account_creds" { - filename = "${path.module}/../../key/service_account.json" + filename = "${path.module}/../../key/-service_account.json" +} + +# Private key for SSH connection +data "local_sensitive_file" "ssh_private_key" { + filename = "${path.module}/../../key/-rsa_ssh_key" +} + +# Public key for SSH connection +data "local_sensitive_file" "ssh_public_key" { + filename = "${path.module}/../../key/-rsa_ssh_key.pub" } diff --git a/module/move/willbe/template/deploy/deploy/hetzner/templates/cloud-init.tpl b/module/move/willbe/template/deploy/deploy/cloud-init.tpl.hbs similarity index 65% rename from module/move/willbe/template/deploy/deploy/hetzner/templates/cloud-init.tpl rename to module/move/willbe/template/deploy/deploy/cloud-init.tpl.hbs index 37cb18d6e9..ce5dcfc9e2 100644 --- a/module/move/willbe/template/deploy/deploy/hetzner/templates/cloud-init.tpl +++ b/module/move/willbe/template/deploy/deploy/cloud-init.tpl.hbs @@ -1,18 +1,6 @@ #cloud-config write_files: -- path: /etc/systemd/system/${image_name}.service - permissions: 0644 - owner: root - content: | - [Unit] - Description=Start ${image_name} docker container. Build: ${timestamp} - Wants=network-online.target - After=network-online.target - - [Service] - Environment="HOME=/root" - ExecStart=/usr/bin/docker run -d -p 80:80 --name=${image_name} ${location}-docker.pkg.dev/${project_id}/${repo_name}/${image_name} - path: /root/service_account.json permissions: 0600 owner: root @@ -22,6 +10,10 @@ write_files: permissions: 0700 owner: root content: | + # Configure env for redeploy script + echo "DOCKER_IMAGE=${location}-docker.pkg.dev/${project_id}/${repo_name}/${image_name}" >> /etc/environment + echo "DOCKER_IMAGE_NAME=${image_name}" >> /etc/environment + # Install docker apt update apt install apt-transport-https ca-certificates curl software-properties-common -y @@ -37,10 +29,7 @@ write_files: # Configure docker with gcloud gcloud auth activate-service-account --key-file=/root/service_account.json gcloud auth configure-docker ${location}-docker.pkg.dev --quiet - # Start docker container - systemctl daemon-reload - systemctl start ${image_name}.service runcmd: -- nohup /root/init.sh > /var/log/uaconf-instance-init.log 2>&1 & +- nohup /root/init.sh > /var/log/deploy-init.log 2>&1 & diff --git a/module/move/willbe/template/deploy/deploy/gar/main.tf b/module/move/willbe/template/deploy/deploy/gar/main.tf.hbs similarity index 82% rename from module/move/willbe/template/deploy/deploy/gar/main.tf rename to module/move/willbe/template/deploy/deploy/gar/main.tf.hbs index 77709d13e6..920cd1db1e 100644 --- a/module/move/willbe/template/deploy/deploy/gar/main.tf +++ b/module/move/willbe/template/deploy/deploy/gar/main.tf.hbs @@ -9,7 +9,7 @@ resource "google_artifact_registry_repository" "container-images-repo" { location = var.REGION project = var.PROJECT_ID repository_id = var.REPO_NAME - description = "Docker image registry for the Learn Together web-site" + description = "Docker image registry for the {{docker_image_name}} deployments" # Format of the repository. We are using Docker. format = "DOCKER" } diff --git a/module/move/willbe/template/deploy/deploy/gce/main.tf b/module/move/willbe/template/deploy/deploy/gce/main.tf.hbs similarity index 62% rename from module/move/willbe/template/deploy/deploy/gce/main.tf rename to module/move/willbe/template/deploy/deploy/gce/main.tf.hbs index 9e74a148e1..f2cb1598d0 100644 --- a/module/move/willbe/template/deploy/deploy/gce/main.tf +++ b/module/move/willbe/template/deploy/deploy/gce/main.tf.hbs @@ -1,9 +1,8 @@ locals { # Helper var for formatting docker image name - image_name = format("%s-docker.pkg.dev/%s/%s/%s", var.REGION, var.PROJECT_ID, var.REPO_NAME, var.IMAGE_NAME) + image_name = format("%s-docker.pkg.dev/%s/%s/%s", var.REGION, var.PROJECT_ID, var.REPO_NAME, var.IMAGE_NAME) # Helper var for formatting subnetwork for our instance - subnetwork = format("projects/%s/regions/%s/subnetworks/default", var.PROJECT_ID, var.REGION) - instance_name = format("ltsite-%s", formatdate("YYYYMMDDhhmmss", timestamp())) + subnetwork = format("projects/%s/regions/%s/subnetworks/default", var.PROJECT_ID, var.REGION) } # Provider for resource creation @@ -18,10 +17,10 @@ resource "google_compute_address" "default" { } # GCE instance block. -resource "google_compute_instance" "lts-container-vm" { - project = var.PROJECT_ID +resource "google_compute_instance" "{{docker_image_name}}" { + project = var.PROJECT_ID # Instance name - name = local.instance_name + name = "{{docker_image_name}}" # Instance size. e2-micro is 0.25-2 vCPU & 1GB RAM machine_type = "e2-micro" zone = var.ZONE @@ -29,12 +28,12 @@ resource "google_compute_instance" "lts-container-vm" { # Main disk options boot_disk { initialize_params { - # Disk image name. We're using Container-optimised OS (COS). - image = "projects/cos-cloud/global/images/cos-stable-109-17800-147-15" + # Disk image name. We're using Ubuntu 24.04 distro. + image = "projects/ubuntu-os-cloud/global/images/ubuntu-2404-noble-amd64-v20241004" # Disk size in GB. 10GB is allowed minimum. - size = 10 + size = 10 # Disk type. Possible values: pd-standard, pd-ssd, or pd-balanced. - type = "pd-balanced" + type = "pd-balanced" } } @@ -52,19 +51,20 @@ resource "google_compute_instance" "lts-container-vm" { metadata = { # Cloud-init startup script for configuring the instance with our docker container. user-data = "${data.cloudinit_config.conf.rendered}" + ssh-keys = "root:${data.local_sensitive_file.ssh_public_key.content}" } allow_stopping_for_update = true scheduling { # Restart on failure. - automatic_restart = true + automatic_restart = true # Describes maintenance behavior for the instance. Possible values: MIGRATE or TERMINATE. on_host_maintenance = "MIGRATE" # Configures whether to allow stopping instance at any moment for reduced cost. - preemptible = false + preemptible = false # Configures spot instance. Possible values: SPOT or STANDARD. - provisioning_model = "STANDARD" + provisioning_model = "STANDARD" } # Configues service account scopes. @@ -86,3 +86,29 @@ resource "google_compute_instance" "lts-container-vm" { # Use `https-server` for https traffic on port 443. tags = ["http-server"] } + +resource "terraform_data" "redeploy" { + triggers_replace = timestamp() + + connection { + type = "ssh" + user = "root" + private_key = data.local_sensitive_file.ssh_private_key.content + host = google_compute_instance.{{docker_image_name}}.network_interface[0].access_config[0].nat_ip + } + + provisioner "file" { + source = "${path.module}/../redeploy.sh" + destination = "/tmp/redeploy.sh" + } + + provisioner "remote-exec" { + inline = [ + "#!/bin/bash", + "( tail -f -n1 /var/log/deploy-init.log & ) | grep -q 'Docker configuration file updated.'", + "source /etc/environment", + "chmod +x /tmp/redeploy.sh", + "/tmp/redeploy.sh" + ] + } +} diff --git a/module/move/willbe/template/deploy/deploy/gce/outputs.tf b/module/move/willbe/template/deploy/deploy/gce/outputs.tf.hbs similarity index 79% rename from module/move/willbe/template/deploy/deploy/gce/outputs.tf rename to module/move/willbe/template/deploy/deploy/gce/outputs.tf.hbs index 9228e2fa83..58b076f05b 100644 --- a/module/move/willbe/template/deploy/deploy/gce/outputs.tf +++ b/module/move/willbe/template/deploy/deploy/gce/outputs.tf.hbs @@ -1,5 +1,5 @@ locals { - ip = google_compute_instance.lts-container-vm.network_interface[0].access_config[0].nat_ip + ip = google_compute_instance.{{docker_image_name}}.network_interface[0].access_config[0].nat_ip } # Output that we get after applying. diff --git a/module/move/willbe/template/deploy/deploy/gce/templates/cloud-init.tpl b/module/move/willbe/template/deploy/deploy/gce/templates/cloud-init.tpl deleted file mode 100644 index 5c465968d9..0000000000 --- a/module/move/willbe/template/deploy/deploy/gce/templates/cloud-init.tpl +++ /dev/null @@ -1,24 +0,0 @@ -#cloud-config - -users: -- name: ${image_name} - uid: 2000 - -write_files: -- path: /etc/systemd/system/${image_name}.service - permissions: 0644 - owner: root - content: | - [Unit] - Description=Start the Learn Together ${image_name} docker container - Wants=gcr-online.target - After=gcr-online.target - - [Service] - Environment="HOME=/home/${image_name}" - ExecStartPre=/usr/bin/docker-credential-gcr configure-docker --registries=${location}-docker.pkg.dev - ExecStart=/usr/bin/docker run -d -p 80:80 --name=${image_name} ${location}-docker.pkg.dev/${project_id}/${repo_name}/${image_name} - -runcmd: -- systemctl daemon-reload -- systemctl start ${image_name}.service \ No newline at end of file diff --git a/module/move/willbe/template/deploy/deploy/hetzner/main.tf b/module/move/willbe/template/deploy/deploy/hetzner/main.tf deleted file mode 100644 index da3118ecef..0000000000 --- a/module/move/willbe/template/deploy/deploy/hetzner/main.tf +++ /dev/null @@ -1,49 +0,0 @@ -terraform { - # Specifies terraform API provider to use for `hcloud` - required_providers { - hcloud = { - source = "hetznercloud/hcloud" - version = "1.45.0" - } - } -} - -# Configures hcloud provider for deploy -provider "hcloud" { - # Hetzner API token - token = var.HCLOUD_TOKEN -} - -# Static IP for the instance -resource "hcloud_primary_ip" "primary_ip" { - name = "uaconf-2024-ip" - datacenter = "hel1-dc2" - type = "ipv4" - assignee_type = "server" - auto_delete = false -} - -# Hetzner instance itself -resource "hcloud_server" "uaconf" { - name = "uaconf-2024" - image = "ubuntu-22.04" - server_type = "cx11" - datacenter = "hel1-dc2" - - public_net { - ipv4_enabled = true - ipv4 = hcloud_primary_ip.primary_ip.id - ipv6_enabled = false - } - - # Startup script for the instance - # Installs docker, gcloud CLI, downloads docker images and starts the container - user_data = templatefile("${path.module}/templates/cloud-init.tpl", { - location = "${var.REGION}" - project_id = "${var.PROJECT_ID}" - repo_name = "${var.REPO_NAME}" - image_name = "${var.IMAGE_NAME}" - service_account_creds = "${replace(data.local_sensitive_file.service_account_creds.content, "\n", "")}" - timestamp = "${timestamp()}" - }) -} diff --git a/module/move/willbe/template/deploy/deploy/hetzner/main.tf.hbs b/module/move/willbe/template/deploy/deploy/hetzner/main.tf.hbs new file mode 100644 index 0000000000..b75e946aab --- /dev/null +++ b/module/move/willbe/template/deploy/deploy/hetzner/main.tf.hbs @@ -0,0 +1,82 @@ +terraform { + # Specifies terraform API provider to use for `hcloud` + required_providers { + hcloud = { + source = "hetznercloud/hcloud" + version = "1.45.0" + } + } +} + +# Configures hcloud provider for deploy +provider "hcloud" { + # Hetzner API token + token = var.HCLOUD_TOKEN +} + +# Creates an SSH key used for redeploy +resource "hcloud_ssh_key" "redeploy" { + name = "{{docker_image_name}} redeploy key" + public_key = data.local_sensitive_file.ssh_public_key.content +} + +# Static IP for the instance +resource "hcloud_primary_ip" "primary_ip" { + name = "{{docker_image_name}}-ip" + datacenter = "hel1-dc2" + type = "ipv4" + assignee_type = "server" + auto_delete = false +} + +# Hetzner instance itself +resource "hcloud_server" "{{docker_image_name}}" { + name = "{{docker_image_name}}" + image = "ubuntu-22.04" + server_type = "cx22" + datacenter = "hel1-dc2" + + public_net { + ipv4_enabled = true + ipv4 = hcloud_primary_ip.primary_ip.id + ipv6_enabled = false + } + + ssh_keys = [ hcloud_ssh_key.redeploy.name ] + + # Startup script for the instance + # Installs docker, gcloud CLI, downloads docker images and starts the container + user_data = templatefile("${path.module}/../cloud-init.tpl", { + location = "${var.REGION}" + project_id = "${var.PROJECT_ID}" + repo_name = "${var.REPO_NAME}" + image_name = "${var.IMAGE_NAME}" + service_account_creds = "${replace(data.local_sensitive_file.service_account_creds.content, "\n", "")}" + }) +} + +resource "terraform_data" "redeploy" { + triggers_replace = timestamp() + + connection { + type = "ssh" + user = "root" + private_key = data.local_sensitive_file.ssh_private_key.content + host = hcloud_primary_ip.primary_ip.ip_address + } + + provisioner "file" { + source = "${path.module}/../redeploy.sh" + destination = "/tmp/redeploy.sh" + } + + provisioner "remote-exec" { + inline = [ + "#!/bin/bash", + "( tail -f -n1 /var/log/deploy-init.log & ) | grep -q 'Docker configuration file updated.'", + "source /etc/environment", + "chmod +x /tmp/redeploy.sh", + "/tmp/redeploy.sh" + ] + } +} diff --git a/module/move/willbe/template/deploy/deploy/hetzner/outputs.tf b/module/move/willbe/template/deploy/deploy/hetzner/outputs.tf.hbs similarity index 86% rename from module/move/willbe/template/deploy/deploy/hetzner/outputs.tf rename to module/move/willbe/template/deploy/deploy/hetzner/outputs.tf.hbs index f6d2ebd5e8..ba994920c7 100644 --- a/module/move/willbe/template/deploy/deploy/hetzner/outputs.tf +++ b/module/move/willbe/template/deploy/deploy/hetzner/outputs.tf.hbs @@ -1,5 +1,5 @@ locals { - ip = hcloud_server.uaconf.ipv4_address + ip = hcloud_server.{{docker_image_name}}.ipv4_address } # Output that we get after applying. diff --git a/module/move/willbe/template/deploy/deploy/hetzner/variables.tf b/module/move/willbe/template/deploy/deploy/hetzner/variables.tf index 92e5e44421..a6c27db413 100644 --- a/module/move/willbe/template/deploy/deploy/hetzner/variables.tf +++ b/module/move/willbe/template/deploy/deploy/hetzner/variables.tf @@ -25,5 +25,15 @@ variable "IMAGE_NAME" { # Google Cloud Platform credentials data "local_sensitive_file" "service_account_creds" { - filename = "${path.module}/../../key/service_account.json" + filename = "${path.module}/../../key/-service_account.json" +} + +# Private key for SSH connection +data "local_sensitive_file" "ssh_private_key" { + filename = "${path.module}/../../key/-rsa_ssh_key" +} + +# Public key for SSH connection +data "local_sensitive_file" "ssh_public_key" { + filename = "${path.module}/../../key/-rsa_ssh_key.pub" } diff --git a/module/move/willbe/template/deploy/deploy/redeploy.sh b/module/move/willbe/template/deploy/deploy/redeploy.sh new file mode 100644 index 0000000000..48695a43e1 --- /dev/null +++ b/module/move/willbe/template/deploy/deploy/redeploy.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +docker rm -f ${DOCKER_IMAGE_NAME} +docker rmi ${DOCKER_IMAGE} +docker pull ${DOCKER_IMAGE} +docker run -d --restart unless-stopped -p 80:80 --name=${DOCKER_IMAGE_NAME} ${DOCKER_IMAGE} diff --git a/module/move/willbe/template/deploy/key/.gitignore b/module/move/willbe/template/deploy/key/.gitignore index 38b7807347..96870e1f6b 100644 --- a/module/move/willbe/template/deploy/key/.gitignore +++ b/module/move/willbe/template/deploy/key/.gitignore @@ -2,3 +2,4 @@ !.gitignore !*.md !pack.sh +-* diff --git a/module/move/willbe/template/deploy/key/Readme.md b/module/move/willbe/template/deploy/key/Readme.md index 53c085c1cd..d46ad6df48 100644 --- a/module/move/willbe/template/deploy/key/Readme.md +++ b/module/move/willbe/template/deploy/key/Readme.md @@ -1,48 +1,82 @@ -# Deploy credentials +# Keys -A list of all keys you'd need to deploy your project on different hosts. +This document provides a concise example of an environment configuration script, used to set up environment variables for a project. +These variables configure application behavior without altering the code. -- [Deploy credentials](#deploy-credentials) - - [Files](#files) - - [Env vars](#env-vars) +- [Keys](#keys) + - [Examples](#examples) + - [`-gcp.sh`](#-gcpsh) + - [`-hetzner.sh`](#-hetznersh) + - [`-aws.sh`](#-awssh) + - [How to Run](#how-to-run) - [Retrieving keys](#retrieving-keys) - [How to get `service_account.json`](#how-to-get-service_accountjson) - [How to get `SECRET_STATE_ARCHIVE_KEY`](#how-to-get-secret_state_archive_key) - [How to get `SECRET_CSP_HETZNER`](#how-to-get-secret_csp_hetzner) - [How to get `SECRET_AWS_ACCESS_KEY_ID` and `SECRET_AWS_ACCESS_KEY`](#how-to-get-secret_aws_access_key_id-and-secret_aws_access_key) -## Files -All secrets can be provided as files in current directory: +## Examples -- [service_account.json](./service_account.json) - default credentials for the service account to use in deployment. -- [`SECRET_STATE_ARCHIVE_KEY`](./SECRET_STATE_ARCHIVE_KEY) - [πŸ“ƒ] base64 encoded AES256 key to encrypt and decrypt .tfstate files. -- [`SECRET_CSP_HETZNER`](./SECRET_CSP_HETZNER) - [πŸ“ƒ] Hetzner token for deploying a server. -- [`SECRET_AWS_ACCESS_KEY_ID`](./SECRET_AWS_ACCESS_KEY_ID) - [πŸ“ƒ] Access Key ID from AWS Credentials. Created at the same time as the Access Key itself. -- [`SECRET_AWS_ACCESS_KEY`](./SECRET_AWS_ACCESS_KEY) - [πŸ“ƒ] Access Key for AWS API. Has to be accompanied with respectful Access Key ID. +### `-gcp.sh` -## Env vars +Contents example for the file `-gcp.sh`. This is a required configuration for all deploy targets. -Some secrets can be presented as an env var: +```bash +#!/bin/bash +CSP=gce +SECRET_STATE_ARCHIVE_KEY=qK1/4m60aZvclYi4bZFeBl8GxpyWcJ2iEevHN+uMy7w= -- [`SECRET_STATE_ARCHIVE_KEY`](./SECRET_STATE_ARCHIVE_KEY) - [πŸ“ƒ] base64 encoded AES256 key to encrypt and decrypt .tfstate files. -- [`SECRET_CSP_HETZNER`](./SECRET_CSP_HETZNER) - [πŸ“ƒ] Hetzner token for deploying a server. -- [`SECRET_AWS_ACCESS_KEY_ID`](./SECRET_AWS_ACCESS_KEY_ID) - [πŸ“ƒ] Access Key ID from AWS Credentials. Created at the same time as the Access Key itself. -- [`SECRET_AWS_ACCESS_KEY`](./SECRET_AWS_ACCESS_KEY) - [πŸ“ƒ] Access Key for AWS API. Has to be accompanied with respectful Access Key ID. +FILE_PATH="$( realpath -qms "${BASH_SOURCE[0]:-$PWD}" )" +DIR_PATH="${FILE_PATH%/*}" +head -c -1 << EOF > ${DIR_PATH}/-service_account.json +{ + // Your service_account information +} +EOF +``` + +- `CSP`: (Optional) Specifies deployment to GCE. +- `SECRET_STATE_ARCHIVE_KEY`: Base64 encoded AES256 key to encrypt and decrypt .tfstate files. +- `-service_account.json`: Default credentials for the service account to use in deployment. + +### `-hetzner.sh` + +Contents example for the file `-hetzner.sh`: + +```bash +CSP=hetzner +SECRET_CSP_HETZNER=your_token_here +``` -Env vars have a higher priority then the files. +- `CSP`: Specifies deployment to Hetzner. +- `SECRET_CSP_HETZNER`: Hetzner token for deploying a server. -For ENV [πŸ“ƒ] secrets values can be placed in files in this directory for automatic exporting to env during deployment. +### `-aws.sh` -Example of a file that will be pulled to env vars: +Contents example for the file `-aws.sh`: -File name: `SECRET_CSP_HETZNER` -File contents: +```bash +CSP=aws +SECRET_AWS_ACCESS_KEY_ID=aws_credentials_here +SECRET_AWS_ACCESS_KEY=aws_credentials_here ``` -hetzner_token_123 + +- `CSP`: Specifies deployment to AWS. +- `SECRET_AWS_ACCESS_KEY_ID`: Access Key ID from AWS Credentials. Created at the same time as the Access Key itself. +- `SECRET_AWS_ACCESS_KEY`: Access Key for AWS API. Has to be accompanied with respectful Access Key ID. + +## How to Run + +To apply these variables to your current shell session, use: + +```bash +. ./key/-gcp.sh +. ./key/-hetzner.sh ``` -Will export a variable to env like so `SECRET_CSP_HETZNER=hetzner_token_123` +This command sources the script, making the variables available in your current session and allowing deployment to Hetzner. +Ensure `-env.sh` is in the `key` directory relative to your current location. ## Retrieving keys diff --git a/module/move/willbe/template/workflow/standard_rust_push.yml b/module/move/willbe/template/workflow/standard_rust_push.yml index 2f6103ebc2..a243d1affe 100644 --- a/module/move/willbe/template/workflow/standard_rust_push.yml +++ b/module/move/willbe/template/workflow/standard_rust_push.yml @@ -64,21 +64,32 @@ jobs : - name: Build module run: cd ${{ steps.rootpath.outputs.path }} && cargo build && cd - - name: Audit the modules + id: audit run: make audit continue-on-error: true - name: Generate documentation for the modules + id: documentation run: make doc open=no manifest_path=${{ inputs.manifest_path }} continue-on-error: true - name: Lint the modules + id: lint run: make lint manifest_path=${{ inputs.manifest_path }} warnings=no continue-on-error: true - name: Check the modules + id: check run: make check manifest_path=${{ inputs.manifest_path }} continue-on-error: true - name: Check the modules dependencies + id: udeps run: cargo +nightly udeps --all-targets --manifest-path ${{ inputs.manifest_path }} - # This part means that all previous steps will be executed and workflow will not stop if they fail, but not this one. - continue-on-error: false + continue-on-error: true + # Added IDs for each step in the test job: This allows referencing the result of each step later. + # + # "Check for errors" step: Now checks the outcome status for each step. + # If any of them have a value of 'failure', this step will fail the job by returning exit 1. + - name: Check for errors + if: steps.audit.outcome != 'success' || steps.documentation.outcome != 'success' || steps.lint.outcome != 'success' || steps.check.outcome != 'success' || steps.udeps.outcome != 'success' + run: exit 1 # release: # if: contains( inputs.commit_message, '+test' ) || contains( inputs.commit_message, 'merge' ) diff --git a/module/move/wplot/License b/module/move/wplot/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/move/wplot/License +++ b/module/move/wplot/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/postponed/_video_experiment/License b/module/postponed/_video_experiment/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/postponed/_video_experiment/License +++ b/module/postponed/_video_experiment/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/postponed/automata_tools/License b/module/postponed/automata_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/postponed/automata_tools/License +++ b/module/postponed/automata_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/postponed/non_std/License b/module/postponed/non_std/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/postponed/non_std/License +++ b/module/postponed/non_std/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/postponed/std_tools/License b/module/postponed/std_tools/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/postponed/std_tools/License +++ b/module/postponed/std_tools/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/postponed/std_x/License b/module/postponed/std_x/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/postponed/std_x/License +++ b/module/postponed/std_x/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/postponed/type_constructor/License b/module/postponed/type_constructor/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/postponed/type_constructor/License +++ b/module/postponed/type_constructor/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/postponed/type_constructor/tests/inc/mod.rs b/module/postponed/type_constructor/tests/inc/mod.rs index 199b42411a..da4554b46e 100644 --- a/module/postponed/type_constructor/tests/inc/mod.rs +++ b/module/postponed/type_constructor/tests/inc/mod.rs @@ -8,8 +8,8 @@ use super::*; // mod type_constructor; #[ cfg( feature = "enabled" ) ] -#[ cfg( any( feature = "prelude", feature = "dt_prelude" ) ) ] -mod prelude_test; +// #[ cfg( any( feature = "prelude", feature = "dt_prelude" ) ) ] +// mod prelude_test; // #[ allow( unused_imports ) ] // use super::*; diff --git a/module/postponed/type_constructor/tests/inc/prelude_test.rs b/module/postponed/type_constructor/tests/inc/prelude_test.rs index 4c6ace0d4b..1699fe6b0e 100644 --- a/module/postponed/type_constructor/tests/inc/prelude_test.rs +++ b/module/postponed/type_constructor/tests/inc/prelude_test.rs @@ -1,68 +1,68 @@ -#[ allow( unused_imports ) ] -use super::*; - -// - -#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] -#[ cfg( feature = "prelude" ) ] -tests_impls! -{ - fn basic() - { - use the_module::prelude::*; - - /* test.case( "Vec" ) */ - let src = Vec::< i32 >::new(); - a_true!( src.is_empty() ); - - /* test.case( "DynList" ) */ - let src = DynList::< i32 >::new(); - a_true!( src.is_empty() ); - - /* test.case( "HashMap" ) */ - let src = HashMap::< i32, i32 >::new(); - a_true!( src.is_empty() ); - - /* test.case( "Map" ) */ - let src = Map::< i32, i32 >::new(); - a_true!( src.is_empty() ); - - /* test.case( "HashSet" ) */ - let src = HashSet::< i32 >::new(); - a_true!( src.is_empty() ); - - /* test.case( "Set" ) */ - let src = Set::< i32 >::new(); - a_true!( src.is_empty() ); - - /* test.case( "BTreeMap" ) */ - let src = BTreeMap::< i32, i32 >::new(); - a_true!( src.is_empty() ); - - /* test.case( "BTreeSet" ) */ - let src = BTreeSet::< i32 >::new(); - a_true!( src.is_empty() ); - - /* test.case( "BinaryHeap" ) */ - let src = BinaryHeap::< i32 >::new(); - a_true!( src.is_empty() ); - - /* test.case( "LinkedList" ) */ - let src = LinkedList::< i32 >::new(); - a_true!( src.is_empty() ); - - /* test.case( "VecDeque" ) */ - let src = VecDeque::< i32 >::new(); - a_true!( src.is_empty() ); - - } -} - -// - -#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] -#[ cfg( feature = "prelude" ) ] -tests_index! -{ - basic, -} +// #[ allow( unused_imports ) ] +// use super::*; +// +// // +// +// #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +// #[ cfg( feature = "prelude" ) ] +// tests_impls! +// { +// fn basic() +// { +// use the_module::prelude::*; +// +// /* test.case( "Vec" ) */ +// let src = Vec::< i32 >::new(); +// a_true!( src.is_empty() ); +// +// /* test.case( "DynList" ) */ +// let src = DynList::< i32 >::new(); +// a_true!( src.is_empty() ); +// +// /* test.case( "HashMap" ) */ +// let src = HashMap::< i32, i32 >::new(); +// a_true!( src.is_empty() ); +// +// /* test.case( "Map" ) */ +// let src = Map::< i32, i32 >::new(); +// a_true!( src.is_empty() ); +// +// /* test.case( "HashSet" ) */ +// let src = HashSet::< i32 >::new(); +// a_true!( src.is_empty() ); +// +// /* test.case( "Set" ) */ +// let src = Set::< i32 >::new(); +// a_true!( src.is_empty() ); +// +// /* test.case( "BTreeMap" ) */ +// let src = BTreeMap::< i32, i32 >::new(); +// a_true!( src.is_empty() ); +// +// /* test.case( "BTreeSet" ) */ +// let src = BTreeSet::< i32 >::new(); +// a_true!( src.is_empty() ); +// +// /* test.case( "BinaryHeap" ) */ +// let src = BinaryHeap::< i32 >::new(); +// a_true!( src.is_empty() ); +// +// /* test.case( "LinkedList" ) */ +// let src = LinkedList::< i32 >::new(); +// a_true!( src.is_empty() ); +// +// /* test.case( "VecDeque" ) */ +// let src = VecDeque::< i32 >::new(); +// a_true!( src.is_empty() ); +// +// } +// } +// +// // +// +// #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +// #[ cfg( feature = "prelude" ) ] +// tests_index! +// { +// basic, +// } diff --git a/module/postponed/wautomata/License b/module/postponed/wautomata/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/postponed/wautomata/License +++ b/module/postponed/wautomata/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/postponed/wpublisher/License b/module/postponed/wpublisher/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/postponed/wpublisher/License +++ b/module/postponed/wpublisher/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/template/template_alias/License b/module/template/template_alias/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/template/template_alias/License +++ b/module/template/template_alias/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/template/template_blank/License b/module/template/template_blank/License index 6d5ef8559f..0804aed8e3 100644 --- a/module/template/template_blank/License +++ b/module/template/template_blank/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/template/template_procedural_macro/License b/module/template/template_procedural_macro/License index e3e9e057cf..c32986cee3 100644 --- a/module/template/template_procedural_macro/License +++ b/module/template/template_procedural_macro/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/template/template_procedural_macro_meta/License b/module/template/template_procedural_macro_meta/License index e3e9e057cf..c32986cee3 100644 --- a/module/template/template_procedural_macro_meta/License +++ b/module/template/template_procedural_macro_meta/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/module/template/template_procedural_macro_runtime/License b/module/template/template_procedural_macro_runtime/License index e3e9e057cf..c32986cee3 100644 --- a/module/template/template_procedural_macro_runtime/License +++ b/module/template/template_procedural_macro_runtime/License @@ -1,4 +1,4 @@ -Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/step/Cargo.toml b/step/Cargo.toml index 70f00c8c96..6e37d39bd0 100644 --- a/step/Cargo.toml +++ b/step/Cargo.toml @@ -21,4 +21,4 @@ all-features = false willbe = { workspace = true, features = [ "full" ] } [dev-dependencies] -test_tools = { workspace = true } +# test_tools = { workspace = true }