diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..5204278 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +rustflags = ["-Z", "next-solver=globally"] diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..7e261b8 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,46 @@ +name: Tests + +on: + push: + pull_request: {} + +env: + CARGO_INCREMENTAL: 0 + CARGO_TERM_COLOR: always + RUST_BACKTRACE: short + CARGO_NET_RETRY: 10 + RUSTUP_MAX_RETRIES: 10 + +# Cancel in-progress runs when a new commit is pushed to the same PR, branch, or tag. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +# To minimize supply-chain exposure this workflow uses only GitHub's own +# first-party actions. Each job runs a command the README's Building section +# lists, on the nightly `rust-toolchain.toml` pins. +jobs: + build: + name: Build + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - name: Install the pinned nightly + run: rustup toolchain install + - name: Build the workspace and its examples + run: cargo build --workspace --all-targets + + test: + name: Test + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - name: Install the pinned nightly + run: rustup toolchain install + - name: Test the workspace + run: cargo test --workspace diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..cb1c1b1 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,42 @@ +# AGENTS.md: Hypershell + +Follow these rules for every change to this repository. Read [README.md](README.md) for what the +project is and how to build it, and the knowledge base's +[sibling-projects.md](https://github.com/contextgeneric/cgp-knowledge-base/blob/main/sibling-projects.md) +for the related repositories. + +## Universal rules + +These rules hold in every CGP repository. The +[knowledge base's AGENTS.md](https://github.com/contextgeneric/cgp-knowledge-base/blob/main/AGENTS.md) +holds their canonical wording: read it first, and change a rule there before updating this block: + +- Learn CGP and its tools from the `/cgp` skill and the knowledge base; never restate them in this + file. +- Prefer the local sibling checkout when reading another project. +- Write a cross-project link as a GitHub URL on `main`. +- Name official release versions only, never a pre-release. +- Commit only when the user explicitly asks, on the current branch. +- Verify a claim against the source before writing it. +- Keep every view of the same truth in sync in the same change. +- Ask the user when a decision is ambiguous. +- Apply point-first writing to internal prose, and natural writing to public-facing documents + such as READMEs, using the optional `/point-first-writing` skill when it is available. + +## Task guides + +The knowledge base documents this project and the website explains it, so a change to what either +describes starts from the document that holds it. Read it before the task: + +- **Changing code the knowledge base describes:** the project's section, + [projects/hypershell/](https://github.com/contextgeneric/cgp-knowledge-base/blob/main/projects/hypershell/README.md), + and the section's [writing guide](https://github.com/contextgeneric/cgp-knowledge-base/blob/main/projects/writing-guide.md). +- **Changing code a website page explains:** the record of the site's section on it, + [website/projects/hypershell.md](https://github.com/contextgeneric/cgp-knowledge-base/blob/main/website/projects/hypershell.md). + +## Checks before committing + +Every commit passes the checks CI runs: + +- Run the build and test commands in [README.md](README.md#building) before committing; + [`.github/workflows/tests.yml`](.github/workflows/tests.yml) runs the same commands. diff --git a/Cargo.lock b/Cargo.lock index 3c76cde..7bcd814 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,26 +2,11 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "addr2line" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler2" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" - [[package]] name = "anyhow" -version = "1.0.98" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" [[package]] name = "atomic-waker" @@ -29,27 +14,6 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" -[[package]] -name = "autocfg" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" - -[[package]] -name = "backtrace" -version = "0.3.75" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" -dependencies = [ - "addr2line", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", - "windows-targets 0.52.6", -] - [[package]] name = "base64" version = "0.22.1" @@ -58,9 +22,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bitflags" -version = "2.9.1" +version = "2.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" [[package]] name = "block-buffer" @@ -73,36 +37,37 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.17.0" +version = "3.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" [[package]] name = "bytes" -version = "1.10.1" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" [[package]] name = "cc" -version = "1.2.24" +version = "1.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16595d3be041c03b09d08d0858631facccee9221e579704070e6e9e4915d3bc7" +checksum = "a3eb0f42d6c360dc3f8a821f6bf2fdea7f72bfd36b3076eb0e6d1e9e0752fff4" dependencies = [ + "find-msvc-tools", "shlex", ] [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "cgp" -version = "0.7.0" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2d437a85e5fff058b478d3ebc21e4eef9732caeea448738e73afa116c1fc30" +checksum = "11a1e522d5703f91b93bed28ea7f32e8fc9cd368009ec79d479d8831057bf486" dependencies = [ "cgp-core", "cgp-extra", @@ -110,28 +75,56 @@ dependencies = [ [[package]] name = "cgp-async-macro" -version = "0.7.0" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03ac81c0b822dfe371bb0ff80206a21170860bbd514fcac0daba962ba34e2e35" +checksum = "a0a558018254879bd258fc792230e02467ce6334bb9bab4da864c607ed8f9b10" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", +] + +[[package]] +name = "cgp-base" +version = "0.8.0-prerelease" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5cf7328bee1840746c07f9c030bd68275d4f6ec40b814a4d261ccfa34ac339" +dependencies = [ + "cgp-base-types", + "cgp-component", + "cgp-macro", +] + +[[package]] +name = "cgp-base-extra" +version = "0.8.0-prerelease" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8d106c6b531a668525417b4872a8857bde536fd995dec3a8528cefd42112a0" +dependencies = [ + "cgp-base", + "cgp-type", ] +[[package]] +name = "cgp-base-types" +version = "0.8.0-prerelease" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32e78e57e7979b594b60060b3c782523bc7a79375530e7208d4a86e071d2a52a" + [[package]] name = "cgp-component" -version = "0.7.0" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39735cd93546a0b4f7183a55172b709c0df893844b41a7117e08583a9da83127" +checksum = "c072c19f4b33b5a022182d01453560c7d85ec022584cae79216d3d71d466f222" [[package]] name = "cgp-core" -version = "0.7.0" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a0ce263d3cbe6b7048c47dcb99f40852e3c8f5639b9e5dd257889868c902a4c" +checksum = "cbc72c412587258a9ff4bef94a56e948b4797e6b5727034974eb42e0a037b758" dependencies = [ "cgp-async-macro", + "cgp-base", "cgp-component", "cgp-error", "cgp-field", @@ -141,9 +134,9 @@ dependencies = [ [[package]] name = "cgp-dispatch" -version = "0.7.0" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d39760b78371f2c1c497961b00e8dce8c1c8f16edff8fea5e0433e9ef9d55ffa" +checksum = "5e0de36fc324e6d92f3faf58c82c904406287dff24bd91f8e437fcdef7a73a99" dependencies = [ "cgp-core", "cgp-handler", @@ -152,20 +145,21 @@ dependencies = [ [[package]] name = "cgp-error" -version = "0.7.0" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d3502be41951b84e3ce40d010cc6ae6bbf24870e46037c459870cccdeffb84" +checksum = "111151912d78e0a4b3ec0ec490649f594fa30460ca5d49f0e1a92b295c4f744f" dependencies = [ - "cgp-component", + "cgp-base-extra", + "cgp-field", "cgp-macro", "cgp-type", ] [[package]] name = "cgp-error-anyhow" -version = "0.7.0" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "627349f2e10a8bd4c2b777ce93fca00cfbfd27ad15b3a186964037dc42634e0e" +checksum = "096dc38a3794991b94a8c43803b002d54d92533bf3ffd2cc727799521e11bb94" dependencies = [ "anyhow", "cgp-core", @@ -173,108 +167,134 @@ dependencies = [ [[package]] name = "cgp-error-extra" -version = "0.7.0" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0b8b5cbf6677a7fb237fd44245222c47f4ee63e7138d84813724a31f0050962" +checksum = "23787fb8544c5703a200ee1dfba9028ed31c9b4401c466301baa4023e643545c" dependencies = [ "cgp-core", ] [[package]] name = "cgp-extra" -version = "0.7.0" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc0a18aaebc9a6afefe95d6e3e07894816c2708bd6722c419c974884aa0a30ec" +checksum = "2ec0b63451a9cda55f20d6609d0bb11f27c404eb0fa1490bca61edda2fffd9e3" dependencies = [ "cgp-core", "cgp-dispatch", "cgp-error-extra", - "cgp-extra-macro", "cgp-field-extra", "cgp-handler", + "cgp-macro-extra", "cgp-monad", "cgp-run", "cgp-runtime", ] [[package]] -name = "cgp-extra-macro" -version = "0.7.0" +name = "cgp-field" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83953618e5a9d39f0fdae7d25799ab5c254fa06531441c2c1a5df6535a740a8c" +checksum = "1b00c9c59793b41ffd708e47bc3502b2acf937e7726479ee4c31f100f344141a" dependencies = [ - "cgp-extra-macro-lib", - "syn", + "cgp-base-types", + "cgp-component", + "cgp-type", ] [[package]] -name = "cgp-extra-macro-lib" -version = "0.7.0" +name = "cgp-field-extra" +version = "0.8.0-prerelease" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dba7b001068522891e57fd888a4445f7a87f21ff59035a6d3ce186afc53bc22" +dependencies = [ + "cgp-field", +] + +[[package]] +name = "cgp-handler" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1800ccf6bd3e3074831b644fc4cdc831d6271d84e68fbd217711c3dfbd85fe42" +checksum = "75ba79f0a6d452c8d82701f0610929968b24106f93af0fa7220185d8e5205f94" +dependencies = [ + "cgp-core", +] + +[[package]] +name = "cgp-macro" +version = "0.8.0-prerelease" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bf9e6e5b7ea90314383d4597b52e01c46608a06d6198c4acb86348965365508" dependencies = [ "cgp-macro-lib", - "proc-macro2", - "quote", - "syn", + "syn 2.0.119", ] [[package]] -name = "cgp-field" -version = "0.7.0" +name = "cgp-macro-core" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2412983a507e370aa5d72b8091f9576cf95e58be06bc3233cd91eeb6b6edead" +checksum = "06f915f1e8ef6ca96d9bec879438fb52591f994c73fdcf312a7414d378a521c0" dependencies = [ - "cgp-component", - "cgp-type", + "itertools", + "proc-macro2", + "quote", + "syn 2.0.119", ] [[package]] -name = "cgp-field-extra" -version = "0.7.0" +name = "cgp-macro-extra" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e6636e484c14fed64533b5f726ca6186493f53218d3975de1437bc76ec72091" +checksum = "e4bd0a65d14ce570db728b5f22e9572d85f677b4294585ccbb4753789a584a6c" dependencies = [ - "cgp-field", + "cgp-macro-extra-lib", + "syn 2.0.119", ] [[package]] -name = "cgp-handler" -version = "0.7.0" +name = "cgp-macro-extra-core" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00a2a8574da65309b8b19ba1268953f7d825748b27a921b4d00baa78b2838a97" +checksum = "a4f3fe84088755d42efa9b70d193329360f0f394c2634a608a733c2ffd0d6d2b" dependencies = [ - "cgp-core", + "cgp-macro-core", + "proc-macro2", + "quote", + "syn 2.0.119", ] [[package]] -name = "cgp-macro" -version = "0.7.0" +name = "cgp-macro-extra-lib" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4f6983bcbc2f08555682f093a56787a4b0b02c63871efc923a0a4f72cda4d68" +checksum = "b8a1129e1ae8ddc4e7d8d3f3e9ec0b05824387906411f257df091f40172e81cb" dependencies = [ - "cgp-macro-lib", - "syn", + "cgp-macro-core", + "cgp-macro-extra-core", + "proc-macro2", + "quote", + "syn 2.0.119", ] [[package]] name = "cgp-macro-lib" -version = "0.7.0" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ec3f9ec29691903cdbf1e82ecc4bb29ab108b306a9826b4d85eaecb6d9d508" +checksum = "373faea91284372b79f2c6a6c514877b66f81479ca3875a4986fb35c38ab59b0" dependencies = [ + "cgp-macro-core", "itertools", - "prettyplease", "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] name = "cgp-monad" -version = "0.7.0" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c313da265af036cefe7307f466c7ae9b26377c4d482172da9d8a1217859482f6" +checksum = "1d5491883b184409e9e29b3605ef4729d151abbf6f369abe95621585e8f6dc39" dependencies = [ "cgp-core", "cgp-handler", @@ -282,28 +302,29 @@ dependencies = [ [[package]] name = "cgp-run" -version = "0.7.0" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b732f6592e4051aa9d43e5ac226c28bb30693c2b92ac1ba7c2a55aa1d757d539" +checksum = "270c86da8a3306720eb0492a77d3ad42e9b924a71927d5baa74b28b430f792e0" dependencies = [ "cgp-core", ] [[package]] name = "cgp-runtime" -version = "0.7.0" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ac97c31acce9ab7d10146c2bd08dbf289c6c533eab1400714dcc9f6c0e85f5" +checksum = "6c31d1735b4cd82a7c4f1f7bda95ea5f2ba992c0693857e837232c8b362d476d" dependencies = [ "cgp-core", ] [[package]] name = "cgp-type" -version = "0.7.0" +version = "0.8.0-prerelease" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e67030447046e58fd34a8c10d6471eaff67b440ca441cbb01e29211ba29e66da" +checksum = "c77b0f7c18d5de701c558793d2ca6d1dea8f6289618e795df073d3237aef70ed" dependencies = [ + "cgp-base", "cgp-component", "cgp-macro", ] @@ -318,12 +339,28 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "core_detect" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" + [[package]] name = "cpufeatures" version = "0.2.17" @@ -335,9 +372,9 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", "typenum", @@ -345,9 +382,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.9.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" +checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06" [[package]] name = "digest" @@ -361,28 +398,34 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.5", ] [[package]] name = "either" -version = "1.15.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34" [[package]] name = "encoding_rs" -version = "0.8.35" +version = "0.8.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +checksum = "7b5ef0006ac9ab233c38522f5ae99cae3625151de8f706cacee1cba4b8e2832a" dependencies = [ "cfg-if", + "core_detect", + "multiversion", + "multiversion_no_op", + "rustversion", + "scopeguard", + "simdutf8", ] [[package]] @@ -393,19 +436,25 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" -version = "0.3.12" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cea14ef9355e3beab063703aa9dab15afd25f0667c341310c1e5274bb1d0da18" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] name = "fastrand" -version = "2.3.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "find-msvc-tools" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e0f1c7c3a72c66fd80abe965175f7523475c0489a87d3ff9d6e8c87d87a9d2d" [[package]] name = "fnv" @@ -430,18 +479,18 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" dependencies = [ "percent-encoding", ] [[package]] name = "futures" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" dependencies = [ "futures-channel", "futures-core", @@ -454,9 +503,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" dependencies = [ "futures-core", "futures-sink", @@ -464,15 +513,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" [[package]] name = "futures-executor" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" dependencies = [ "futures-core", "futures-task", @@ -481,38 +530,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" [[package]] name = "futures-macro" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.5", ] [[package]] name = "futures-sink" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" [[package]] name = "futures-task" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" [[package]] name = "futures-util" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" dependencies = [ "futures-channel", "futures-core", @@ -522,7 +571,6 @@ dependencies = [ "futures-task", "memchr", "pin-project-lite", - "pin-utils", "slab", ] @@ -538,38 +586,43 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] name = "getrandom" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ "cfg-if", "libc", - "r-efi", - "wasi 0.14.2+wasi-0.2.4", + "r-efi 5.3.0", + "wasip2", ] [[package]] -name = "gimli" -version = "0.31.1" +name = "getrandom" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", +] [[package]] name = "h2" -version = "0.4.10" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9421a676d1b147b16b82c9225157dc629087ef8ec4d5e2960f9437a90dac0a5" +checksum = "ef8e5e5a340588f4452631496976cf8636d4a7ecf600239fdc27615d2530bc16" dependencies = [ "atomic-waker", "bytes", @@ -586,9 +639,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.3" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" [[package]] name = "hex" @@ -598,20 +651,19 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "http" -version = "1.3.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" dependencies = [ "bytes", - "fnv", "itoa", ] [[package]] name = "http-body" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c" dependencies = [ "bytes", "http", @@ -619,9 +671,9 @@ dependencies = [ [[package]] name = "http-body-util" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c" dependencies = [ "bytes", "futures-core", @@ -638,13 +690,14 @@ checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" [[package]] name = "hyper" -version = "1.6.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +checksum = "27b501faa50e7a26c3d3560ca625132f4078a17771f4810baf70475ae48cbe43" dependencies = [ + "atomic-waker", "bytes", "futures-channel", - "futures-util", + "futures-core", "h2", "http", "http-body", @@ -658,15 +711,14 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.6" +version = "0.27.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a01595e11bdcec50946522c32dde3fc6914743000a68b93000965f2f02406d" +checksum = "33ca68d021ef39cf6463ab54c1d0f5daf03377b70561305bb89a8f83aab66e0f" dependencies = [ "http", "hyper", "hyper-util", "rustls", - "rustls-pki-types", "tokio", "tokio-rustls", "tower-service", @@ -690,27 +742,32 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.12" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9f1e950e0d9d1d3c47184416723cf29c0d1f93bd8cccf37e4beb6b44f31710" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" dependencies = [ + "base64", "bytes", "futures-channel", "futures-util", "http", "http-body", "hyper", + "ipnet", "libc", + "percent-encoding", "pin-project-lite", "socket2", + "system-configuration", "tokio", "tower-service", "tracing", + "windows-registry", ] [[package]] name = "hypershell" -version = "0.1.0" +version = "0.2.0-prerelease" dependencies = [ "cgp", "cgp-error-anyhow", @@ -721,19 +778,20 @@ dependencies = [ "hypershell-tokio-components", "reqwest", "serde_json", + "tokio", "url", ] [[package]] name = "hypershell-components" -version = "0.1.0" +version = "0.2.0-prerelease" dependencies = [ "cgp", ] [[package]] name = "hypershell-examples" -version = "0.1.0" +version = "0.2.0-prerelease" dependencies = [ "cgp", "cgp-error-anyhow", @@ -754,18 +812,17 @@ dependencies = [ [[package]] name = "hypershell-hash-components" -version = "0.1.0" +version = "0.2.0-prerelease" dependencies = [ "cgp", "futures", "hex", - "hypershell-components", "sha2", ] [[package]] name = "hypershell-json-components" -version = "0.1.0" +version = "0.2.0-prerelease" dependencies = [ "cgp", "hypershell-components", @@ -775,7 +832,7 @@ dependencies = [ [[package]] name = "hypershell-macro" -version = "0.1.0" +version = "0.2.0-prerelease" dependencies = [ "proc-macro2", "quote", @@ -783,7 +840,7 @@ dependencies = [ [[package]] name = "hypershell-reqwest-components" -version = "0.1.0" +version = "0.2.0-prerelease" dependencies = [ "cgp", "futures", @@ -797,7 +854,7 @@ dependencies = [ [[package]] name = "hypershell-tokio-components" -version = "0.1.0" +version = "0.2.0-prerelease" dependencies = [ "cgp", "futures", @@ -809,7 +866,7 @@ dependencies = [ [[package]] name = "hypershell-tungstenite-components" -version = "0.1.0" +version = "0.2.0-prerelease" dependencies = [ "cgp", "futures", @@ -822,12 +879,13 @@ dependencies = [ [[package]] name = "icu_collections" -version = "2.0.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47" +checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513" dependencies = [ "displaydoc", "potential_utf", + "utf8_iter", "yoke", "zerofrom", "zerovec", @@ -835,9 +893,9 @@ dependencies = [ [[package]] name = "icu_locale_core" -version = "2.0.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a" +checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb" dependencies = [ "displaydoc", "litemap", @@ -848,11 +906,10 @@ dependencies = [ [[package]] name = "icu_normalizer" -version = "2.0.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979" +checksum = "12f9cf5f235641ed274641dd81c3f28d870e276763d0797aeeab72317b1c646f" dependencies = [ - "displaydoc", "icu_collections", "icu_normalizer_data", "icu_properties", @@ -863,42 +920,39 @@ dependencies = [ [[package]] name = "icu_normalizer_data" -version = "2.0.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3" +checksum = "1563da1ed3e0b3bf3d74c9b85917ac9c56464d2f57242270c09c9e752f8021a0" [[package]] name = "icu_properties" -version = "2.0.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b" +checksum = "7e7ca276ad3145661a65914e6daf131ca5120cd3dcee8f8f3214b8875184a148" dependencies = [ "displaydoc", "icu_collections", "icu_locale_core", "icu_properties_data", "icu_provider", - "potential_utf", "zerotrie", "zerovec", ] [[package]] name = "icu_properties_data" -version = "2.0.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632" +checksum = "e590f038c1464a96894fd6d10127e90a8be4509f56ff7ecef851b15cee0b7caa" [[package]] name = "icu_provider" -version = "2.0.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af" +checksum = "d27bbb9d3abbefac45d55f647c9de1d44aafcd1186eb91879afef17c396c3e73" dependencies = [ "displaydoc", "icu_locale_core", - "stable_deref_trait", - "tinystr", "writeable", "yoke", "zerofrom", @@ -908,9 +962,9 @@ dependencies = [ [[package]] name = "idna" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" dependencies = [ "idna_adapter", "smallvec", @@ -919,9 +973,9 @@ dependencies = [ [[package]] name = "idna_adapter" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" dependencies = [ "icu_normalizer", "icu_properties", @@ -929,9 +983,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.9.0" +version = "2.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" dependencies = [ "equivalent", "hashbrown", @@ -939,9 +993,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.11.0" +version = "2.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" +checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0" [[package]] name = "itertools" @@ -954,49 +1008,50 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.15" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "js-sys" -version = "0.3.77" +version = "0.3.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +checksum = "ce57d20d1ea864ce2ac172ab472d409214f4fd359f0b2a2775abdf522e2af99e" dependencies = [ - "once_cell", + "cfg-if", + "futures-util", "wasm-bindgen", ] [[package]] name = "libc" -version = "0.2.172" +version = "0.2.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" +checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" [[package]] name = "linux-raw-sys" -version = "0.9.4" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] name = "litemap" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" [[package]] name = "log" -version = "0.4.27" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" [[package]] name = "memchr" -version = "2.7.4" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "mime" @@ -1005,30 +1060,48 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] -name = "miniz_oxide" -version = "0.8.8" +name = "mio" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" +checksum = "4b18443e9c262bfe8fa82f51666e2642c53393f7e5c27b3e1aeab922cff5b9d8" dependencies = [ - "adler2", + "libc", + "wasi", + "windows-sys 0.61.2", ] [[package]] -name = "mio" -version = "1.0.3" +name = "multiversion" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +checksum = "b4ca4bea16ffc3f443cf7d866912118196bfef4c6a1556ca00f9f9b00bb43f7c" dependencies = [ - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.52.0", + "multiversion-macros", +] + +[[package]] +name = "multiversion-macros" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d416831a7317ef4b08bee00b69cbbb9c8763da7959a7026244d6266869f9c83" +dependencies = [ + "proc-macro2", + "quote", + "rustversion", + "syn 3.0.5", ] +[[package]] +name = "multiversion_no_op" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" + [[package]] name = "native-tls" -version = "0.2.14" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" +checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" dependencies = [ "libc", "log", @@ -1041,32 +1114,22 @@ dependencies = [ "tempfile", ] -[[package]] -name = "object" -version = "0.36.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" -version = "1.21.3" +version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "openssl" -version = "0.10.72" +version = "0.10.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fedfea7d58a1f73118430a55da6a286e7b044961736ce96a16a17068ea25e5da" +checksum = "77823a27f0babb03091cb9ed9ef80af3b39dbc82f97e8fa530374b7dafd87a45" dependencies = [ "bitflags", "cfg-if", "foreign-types", "libc", - "once_cell", "openssl-macros", "openssl-sys", ] @@ -1079,20 +1142,20 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] name = "openssl-probe" -version = "0.1.6" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" [[package]] name = "openssl-sys" -version = "0.9.108" +version = "0.9.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e145e1651e858e820e4860f7b9c5e169bc1d8ce1c86043be79fa7b7634821847" +checksum = "b47e7e6bb2c38cd930d25a23b40fa52e068c10e85f3e03a7f5ba5aaca5713695" dependencies = [ "cc", "libc", @@ -1102,33 +1165,27 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.1" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pin-project-lite" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" - -[[package]] -name = "pin-utils" -version = "0.1.0" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] name = "pkg-config" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" [[package]] name = "potential_utf" -version = "0.1.2" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" dependencies = [ "zerovec", ] @@ -1142,45 +1199,41 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "prettyplease" -version = "0.2.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "664ec5419c51e34154eec046ebcba56312d5a2fc3b09a06da188e1ad21afadf6" -dependencies = [ - "proc-macro2", - "syn", -] - [[package]] name = "proc-macro2" -version = "1.0.95" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.40" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" dependencies = [ "proc-macro2", ] [[package]] name = "r-efi" -version = "5.2.0" +version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" [[package]] name = "rand" -version = "0.9.1" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" +checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" dependencies = [ "rand_chacha", "rand_core", @@ -1198,18 +1251,18 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" dependencies = [ - "getrandom 0.3.3", + "getrandom 0.3.4", ] [[package]] name = "reqwest" -version = "0.12.15" +version = "0.12.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d19c46a6fdd48bc4dab94b6103fccc55d34c67cc0ad04653aad4ea2a07cd7bbb" +checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" dependencies = [ "base64", "bytes", @@ -1224,31 +1277,28 @@ dependencies = [ "hyper-rustls", "hyper-tls", "hyper-util", - "ipnet", "js-sys", "log", "mime", "native-tls", - "once_cell", "percent-encoding", "pin-project-lite", - "rustls-pemfile", + "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", - "system-configuration", "tokio", "tokio-native-tls", "tokio-util", "tower", + "tower-http", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "wasm-streams", "web-sys", - "windows-registry", ] [[package]] @@ -1259,36 +1309,30 @@ checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.16", + "getrandom 0.2.17", "libc", "untrusted", "windows-sys 0.52.0", ] -[[package]] -name = "rustc-demangle" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" - [[package]] name = "rustix" -version = "1.0.7" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ "bitflags", "errno", "libc", "linux-raw-sys", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] name = "rustls" -version = "0.23.27" +version = "0.23.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "730944ca083c1c233a75c09f199e973ca499344a2b7ba9e755c457e86fb4a321" +checksum = "6725596c3f2c3a0aef021139e145d4eafe314a6623e4680ca83852b2c67ab2ba" dependencies = [ "once_cell", "rustls-pki-types", @@ -1297,29 +1341,20 @@ dependencies = [ "zeroize", ] -[[package]] -name = "rustls-pemfile" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" -dependencies = [ - "rustls-pki-types", -] - [[package]] name = "rustls-pki-types" -version = "1.12.0" +version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" +checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" dependencies = [ "zeroize", ] [[package]] name = "rustls-webpki" -version = "0.103.3" +version = "0.103.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a72fe2bcf7a6ac6fd7d0b9e5cb68aeb7d4c0a0271730218b3e92d43b4eb435" +checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2" dependencies = [ "ring", "rustls-pki-types", @@ -1328,33 +1363,39 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.21" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" [[package]] name = "ryu" -version = "1.0.20" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" [[package]] name = "schannel" -version = "0.1.27" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + [[package]] name = "security-framework" -version = "2.11.1" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ "bitflags", - "core-foundation", + "core-foundation 0.10.1", "core-foundation-sys", "libc", "security-framework-sys", @@ -1362,9 +1403,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.14.0" +version = "2.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" dependencies = [ "core-foundation-sys", "libc", @@ -1372,34 +1413,45 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.219" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.5", ] [[package]] name = "serde_json" -version = "1.0.140" +version = "1.0.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" dependencies = [ "itoa", "memchr", - "ryu", "serde", + "serde_core", + "zmij", ] [[package]] @@ -1416,9 +1468,9 @@ dependencies = [ [[package]] name = "sha1" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8" dependencies = [ "cfg-if", "cpufeatures", @@ -1438,49 +1490,53 @@ dependencies = [ [[package]] name = "shlex" -version = "1.3.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" [[package]] name = "signal-hook-registry" -version = "1.4.5" +version = "1.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" dependencies = [ + "errno", "libc", ] +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + [[package]] name = "slab" -version = "0.4.9" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "smallvec" -version = "1.15.0" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" +checksum = "ba467056f1b547ed52077911161fc86985becbc60e8e1857c8a144dab0def891" [[package]] name = "socket2" -version = "0.5.10" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] name = "stable_deref_trait" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "subtle" @@ -1490,9 +1546,20 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.101" +version = "2.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12df2e0110f65b775f769bb17ef989067a1d931b2eb822bd4346631eeada89f9" dependencies = [ "proc-macro2", "quote", @@ -1516,17 +1583,17 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] name = "system-configuration" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b" dependencies = [ "bitflags", - "core-foundation", + "core-foundation 0.9.4", "system-configuration-sys", ] @@ -1542,42 +1609,42 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.20.0" +version = "3.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.3.3", + "getrandom 0.4.3", "once_cell", "rustix", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] name = "thiserror" -version = "2.0.12" +version = "2.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.12" +version = "2.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.5", ] [[package]] name = "tinystr" -version = "0.8.1" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b" +checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643" dependencies = [ "displaydoc", "zerovec", @@ -1585,11 +1652,10 @@ dependencies = [ [[package]] name = "tokio" -version = "1.45.0" +version = "1.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2513ca694ef9ede0fb23fe71a4ee4107cb102b9dc1930f6d0fd77aae068ae165" +checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed" dependencies = [ - "backtrace", "bytes", "libc", "mio", @@ -1597,18 +1663,18 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] name = "tokio-macros" -version = "2.5.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.5", ] [[package]] @@ -1623,9 +1689,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.26.2" +version = "0.26.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" +checksum = "b0c85f2c3ef0b1cd58b36682f4b17aaa995f0e5db534d85692b4903abce21f67" dependencies = [ "rustls", "tokio", @@ -1647,23 +1713,24 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.15" +version = "0.7.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" +checksum = "494815d09bf52b5548659851081238f0ca39ff638363907596da739561c62c52" dependencies = [ "bytes", "futures-core", "futures-io", "futures-sink", + "libc", "pin-project-lite", "tokio", ] [[package]] name = "tower" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" dependencies = [ "futures-core", "futures-util", @@ -1674,6 +1741,24 @@ dependencies = [ "tower-service", ] +[[package]] +name = "tower-http" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" +dependencies = [ + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", + "url", +] + [[package]] name = "tower-layer" version = "0.3.3" @@ -1688,9 +1773,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.41" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" dependencies = [ "pin-project-lite", "tracing-core", @@ -1698,9 +1783,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.33" +version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" dependencies = [ "once_cell", ] @@ -1731,15 +1816,15 @@ dependencies = [ [[package]] name = "typenum" -version = "1.18.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "untrusted" @@ -1749,13 +1834,14 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.4" +version = "2.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" dependencies = [ "form_urlencoded", "idna", "percent-encoding", + "serde", ] [[package]] @@ -1793,63 +1879,47 @@ dependencies = [ [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] -name = "wasi" -version = "0.14.2+wasi-0.2.4" +name = "wasip2" +version = "1.0.4+wasi-0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" dependencies = [ - "wit-bindgen-rt", + "wit-bindgen", ] [[package]] name = "wasm-bindgen" -version = "0.2.100" +version = "0.2.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +checksum = "aecb87a33d3b0c5e3b7aa46336eaf486cffafbd281b195e4c8b80d50df2351bf" dependencies = [ "cfg-if", "once_cell", "rustversion", "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" -dependencies = [ - "bumpalo", - "log", - "proc-macro2", - "quote", - "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.50" +version = "0.4.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" +checksum = "6ef4c5d3d2cdf5c54f4231181768f5510842e350db025faf1f7163b1030ed928" dependencies = [ - "cfg-if", "js-sys", - "once_cell", "wasm-bindgen", - "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.100" +version = "0.2.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +checksum = "a690d511e3c1a8b3a55e33511e3c2c00c78415cd23650f32b808627f5696b9ed" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1857,22 +1927,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.100" +version = "0.2.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +checksum = "411e4887f0071ef2d2164a9d5fdf2d20efbef78fccd3a78b0c10a1dc5295e48a" dependencies = [ + "bumpalo", "proc-macro2", "quote", - "syn", - "wasm-bindgen-backend", + "syn 3.0.5", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.100" +version = "0.2.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +checksum = "81941cd78d0c92026c33e5e01312845a4cb1e9af3407f9134b100dd03144103e" dependencies = [ "unicode-ident", ] @@ -1892,9 +1962,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.77" +version = "0.3.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" +checksum = "9fbddc4a036f00ec4f18c83445bd3115cb306a91da554919a099d9222fe4a7f8" dependencies = [ "js-sys", "wasm-bindgen", @@ -1902,35 +1972,35 @@ dependencies = [ [[package]] name = "windows-link" -version = "0.1.1" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] name = "windows-registry" -version = "0.4.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4286ad90ddb45071efd1a66dfa43eb02dd0dfbae1545ad6cc3c51cf34d7e8ba3" +checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" dependencies = [ + "windows-link", "windows-result", "windows-strings", - "windows-targets 0.53.0", ] [[package]] name = "windows-result" -version = "0.3.4" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" dependencies = [ "windows-link", ] [[package]] name = "windows-strings" -version = "0.3.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87fa48cc5d406560701792be122a10132491cff9d0aeb23583cc2dcafc847319" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" dependencies = [ "windows-link", ] @@ -1941,16 +2011,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.6", + "windows-targets", ] [[package]] name = "windows-sys" -version = "0.59.0" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows-targets 0.52.6", + "windows-link", ] [[package]] @@ -1959,30 +2029,14 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm 0.52.6", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1e4c7e8ceaaf9cb7d7507c974735728ab453b67ef8f18febdd7c11fe59dca8b" -dependencies = [ - "windows_aarch64_gnullvm 0.53.0", - "windows_aarch64_msvc 0.53.0", - "windows_i686_gnu 0.53.0", - "windows_i686_gnullvm 0.53.0", - "windows_i686_msvc 0.53.0", - "windows_x86_64_gnu 0.53.0", - "windows_x86_64_gnullvm 0.53.0", - "windows_x86_64_msvc 0.53.0", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] @@ -1991,84 +2045,42 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_aarch64_msvc" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" - [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" -[[package]] -name = "windows_i686_gnu" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" - [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_gnullvm" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_i686_msvc" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnu" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -2076,33 +2088,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] -name = "windows_x86_64_msvc" -version = "0.53.0" +name = "wit-bindgen" +version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" - -[[package]] -name = "wit-bindgen-rt" -version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" -dependencies = [ - "bitflags", -] +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" [[package]] name = "writeable" -version = "0.6.1" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" [[package]] name = "yoke" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" dependencies = [ - "serde", "stable_deref_trait", "yoke-derive", "zerofrom", @@ -2110,68 +2112,68 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" +checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", "synstructure", ] [[package]] name = "zerocopy" -version = "0.8.25" +version = "0.8.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" +checksum = "d35102a9f36d089ccae9e4c6802bc118be4487b80aaffc0ab4e0cf5ce92d2873" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.25" +version = "0.8.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" +checksum = "146c01f5ab44258da43cf276c74a2763db2ff3969c9c652c3f2de07041d0b2bc" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] name = "zerofrom" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", "synstructure", ] [[package]] name = "zeroize" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" [[package]] name = "zerotrie" -version = "0.2.2" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" dependencies = [ "displaydoc", "yoke", @@ -2180,9 +2182,9 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.2" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428" +checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8" dependencies = [ "yoke", "zerofrom", @@ -2191,11 +2193,17 @@ dependencies = [ [[package]] name = "zerovec-derive" -version = "0.11.1" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" +checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.5", ] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/Cargo.toml b/Cargo.toml index c8f117c..8a1e19f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,13 +18,15 @@ members = [ rust-version = "1.90" edition = "2024" license = "MIT" -repository = "https://github.com/contextgeneric/cgp" +repository = "https://github.com/contextgeneric/hypershell" +homepage = "https://contextgeneric.dev/docs/projects/hypershell/" +categories = ["command-line-interface", "rust-patterns"] authors = ["Soares Chen "] -keywords = ["cgp"] +keywords = ["cgp", "dsl", "shell", "type-level"] [workspace.dependencies] -cgp = { version = "0.7.0" } -cgp-error-anyhow = { version = "0.7.0" } +cgp = { version = "0.8.0-prerelease" } +cgp-error-anyhow = { version = "0.8.0-prerelease" } futures = { version = "0.3.31" } hex = { version = "0.4.3" } itertools = { version = "0.14.0" } @@ -39,15 +41,11 @@ tokio-tungstenite = { version = "0.26.2" } tokio-util = { version = "0.7.15" } url = { version = "2.5.4" } -hypershell = { version = "0.1.0", path = "./crates/hypershell" } -hypershell-components = { version = "0.1.0", path = "./crates/hypershell-components" } -hypershell-json-components = { version = "0.1.0", path = "./crates/hypershell-json-components" } -hypershell-reqwest-components = { version = "0.1.0", path = "./crates/hypershell-reqwest-components" } -hypershell-tokio-components = { version = "0.1.0", path = "./crates/hypershell-tokio-components" } -hypershell-tungstenite-components = { version = "0.1.0", path = "./crates/hypershell-tungstenite-components" } -hypershell-hash-components = { version = "0.1.0", path = "./crates/hypershell-hash-components" } -hypershell-macro = { version = "0.1.0", path = "./crates/hypershell-macro" } - -[patch.crates-io] -# cgp = { git = "https://github.com/contextgeneric/cgp.git", branch = "v0.7.0" } -# cgp-error-anyhow = { git = "https://github.com/contextgeneric/cgp.git", branch = "v0.7.0" } +hypershell = { version = "0.2.0-prerelease", path = "./crates/hypershell" } +hypershell-components = { version = "0.2.0-prerelease", path = "./crates/hypershell-components" } +hypershell-json-components = { version = "0.2.0-prerelease", path = "./crates/hypershell-json-components" } +hypershell-reqwest-components = { version = "0.2.0-prerelease", path = "./crates/hypershell-reqwest-components" } +hypershell-tokio-components = { version = "0.2.0-prerelease", path = "./crates/hypershell-tokio-components" } +hypershell-tungstenite-components = { version = "0.2.0-prerelease", path = "./crates/hypershell-tungstenite-components" } +hypershell-hash-components = { version = "0.2.0-prerelease", path = "./crates/hypershell-hash-components" } +hypershell-macro = { version = "0.2.0-prerelease", path = "./crates/hypershell-macro" } diff --git a/README.md b/README.md index 2e5ad80..d22d286 100644 --- a/README.md +++ b/README.md @@ -1,80 +1,192 @@ -![Crates.io](https://img.shields.io/crates/v/hypershell.svg) +[![Crates.io](https://img.shields.io/crates/v/hypershell.svg)](https://crates.io/crates/hypershell) [![Docs.rs](https://docs.rs/hypershell/badge.svg)](https://docs.rs/hypershell) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/contextgeneric/hypershell/blob/main/LICENSE) +[![Tests](https://github.com/contextgeneric/hypershell/actions/workflows/tests.yml/badge.svg)](https://github.com/contextgeneric/hypershell/actions/workflows/tests.yml) # Hypershell -Hypershell is a modular, *type-level* domain-specific language (DSL) for writing shell-script-like programs in Rust. It is powered by [context-generic programming (CGP)](https://contextgeneric.dev/), which makes it possible for users to *extend* or *modify* both the language syntax and semantics. +Hypershell is a small language for writing shell-script-like programs in Rust, built with +[Context-Generic Programming (CGP)](https://contextgeneric.dev/), a language extension for Rust +with pluggable trait implementations at compile-time. A Hypershell program is a Rust *type*, and the +context that runs it is its interpreter: a type whose wiring chooses how each piece of the program +behaves. So both the language's syntax and its meaning can be extended without editing the crates +that define them. -## Learn More +Hypershell is an **experimental** proof of concept. It shows how CGP builds a modular language in +Rust, and it is not meant to replace a shell. -This README provides a brief overview of Hypershell. To learn about the concepts behind Hypershell, Context-Generic Programming, and how to create your own extensions, please read the introductory blog post: +**[Project page](https://contextgeneric.dev/docs/projects/hypershell/) · [Examples](https://contextgeneric.dev/docs/projects/hypershell/examples/) · [CGP quickstart](https://contextgeneric.dev/docs/quickstart) · [Introduction post](https://contextgeneric.dev/blog/hypershell-release/)** -[**Hypershell: A Type-Level DSL for Shell-Scripting in Rust**](https://contextgeneric.dev/blog/hypershell-release/) +## A program that is a type -## What is Hypershell? +This is the smallest Hypershell program. It runs `echo hello world!` and prints the output: -Hypershell allows you to define complex command pipelines, similar to shell scripts, but directly within Rust's type system. This approach provides several key benefits: +```rust +use hypershell::prelude::*; -- **Type Safety**: Your shell-like programs are checked by the Rust compiler. -- **Performance**: DSL programs are interpreted at compile-time into native Rust code with no runtime overhead. -- **Extensibility**: Seamlessly integrate native Rust functions (like HTTP requests or JSON parsing) with external CLI commands in your pipelines. -- **Modularity**: The language itself is designed to be extended. You can add new syntax and handlers without modifying the core library. +pub type Program = hypershell! { + SimpleExec< + StaticArg<"echo">, + WithStaticArgs["hello", "world!"], + > + | StreamToStdout +}; -## Key Features +#[tokio::main] +async fn main() -> Result<(), Error> { + HypershellCli + .handle(PhantomData::, Vec::new()) + .await?; -- **Type-Level DSL**: Define shell scripts as Rust types. -- **Extensible Syntax and Semantics**: Powered by CGP, allowing for deep customization. -- **Mix CLI and Native Handlers**: Combine external commands like `sha256sum` or `cut` with native Rust logic for HTTP requests, JSON processing, and more. -- **Streaming Pipelines**: Efficiently stream I/O between handlers, just like in a traditional shell. -- **Compile-Time Interpretation**: Your DSL programs are resolved at compile-time, resulting in highly performant native code. + Ok(()) +} +``` + +`Program` is a type alias, not a value. Each piece of it, such as `SimpleExec` or `StreamToStdout`, +is an empty struct that says nothing about how it runs, and the `hypershell!` macro only rewrites +the shell-like surface into that type: the `|` becomes a pipeline, the brackets a type-level list, +and each string a type-level string. -## Crate Organization +Running the program is one `handle` call on a context. `HypershellCli` is the context here, and this +is its entire definition: -Hypershell is organized into several crates, each with a specific purpose. This modular structure allows for clear separation of concerns and makes the language easier to extend. +```rust +pub struct HypershellCli; -- [`hypershell`](./crates/hypershell): The main crate that re-exports all the necessary components for using the Hypershell DSL. It defines the default presets and contexts for running Hypershell programs. -- [`hypershell-macro`](./crates/hypershell-macro): Contains the `hypershell!` procedural macro, which provides the shell-like syntax for the DSL. -- [`hypershell-components`](./crates/hypershell-components): Defines the core abstract syntax (e.g., `SimpleExec`, `StreamingExec`) and the fundamental CGP components and traits that form the basis of the DSL. -- [`hypershell-tokio-components`](./crates/hypershell-tokio-components): Provides Tokio-based implementations for executing external CLI commands and handling file I/O. -- [`hypershell-reqwest-components`](./crates/hypershell-reqwest-components): Implements native HTTP handlers (e.g., `SimpleHttpRequest`, `StreamingHttpRequest`) using the `reqwest` crate. -- [`hypershell-json-components`](./crates/hypershell-json-components): Provides handlers for JSON serialization (`EncodeJson`) and deserialization (`DecodeJson`). -- [`hypershell-hash-components`](./crates/hypershell-hash-components): An extension crate that offers native handlers for checksumming (`Checksum`) and hex encoding (`BytesToHex`). -- [`hypershell-tungstenite-components`](./crates/hypershell-tungstenite-components): An extension crate that adds native WebSocket support to Hypershell. -- [`hypershell-examples`](./crates/hypershell-examples): Contains a collection of examples demonstrating various features and use cases of Hypershell. +delegate_components! { + HypershellCli { + namespace HypershellNamespace; + } +} +``` -## Getting Started +The one line joins `HypershellNamespace`, which routes each piece of syntax to the implementation, +or **provider**, that interprets it. The compiler resolves every choice while it type-checks the +program, so the call compiles to direct calls to those providers, with no interpreter running at run +time. A context of your own can join the same namespace, add fields that a program reads, such as a +URL, or join a namespace that extends the language with new syntax. -### Installation +## Installation -Add `hypershell` and `cgp` to your `Cargo.toml`: +Add `hypershell`, `cgp`, and an async runtime to your `Cargo.toml`: ```toml [dependencies] -cgp = { version = "0.4.1" } -hypershell = { version = "0.1.0" } - -# You'll also need tokio for async runtime and reqwest for the example -tokio = { version = "1", features = ["full"] } -reqwest = "0.11" -anyhow = "1.0" +cgp = "0.8.0" +hypershell = "0.2.0" +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } ``` -### Examples - -The `hypershell-examples` crate contains various examples demonstrating different features and use cases of Hypershell. You can find the full source code for these examples in the [`crates/hypershell-examples/examples/`](./crates/hypershell-examples/examples) directory. - -Here are a few hand-picked examples with short descriptions: - -* [`hello.rs`](./crates/hypershell-examples/examples/hello.rs): A basic "hello world" program that executes `echo hello world!` using `SimpleExec`. -* [`hello_name.rs`](./crates/hypershell-examples/examples/hello_name.rs): Demonstrates using variable parameters (`FieldArg`) to pass dynamic values to shell commands. -* [`http_checksum_cli.rs`](./crates/hypershell-examples/examples/http_checksum_cli.rs): Fetches a URL using `curl` and pipes the output to `sha256sum` and `cut` via streaming execution. -* [`http_checksum_client.rs`](./crates/hypershell-examples/examples/http_checksum_client.rs): Fetches a URL using Hypershell's native HTTP client, then pipes the response to `sha256sum` and `cut` via streaming execution. -* [`http_checksum_native.rs`](./crates/hypershell-examples/examples/http_checksum_native.rs): The same checksum functionality, but uses Hypershell's native HTTP client together with an extended version of the DSL that introduces `Checksum` to the language syntax, showcasing the extensibility of the DSL. -* [`rust_playground.rs`](./crates/hypershell-examples/examples/rust_playground.rs): Shows how to encode and decode JSON, sending a Rust code snippet to the Rust Playground API and parsing its response. -* [`bluesky.rs`](./crates/hypershell-examples/examples/bluesky.rs): Connects to the Bluesky social media firehose via `nix-shell` and `websocat`, and then filters the stream using `grep`. -* [`bluesky_websocket.rs`](./crates/hypershell-examples/examples/bluesky_websocket.rs): The same Bluesky firehose example, but extends the DSL with native Websocket handling and using it in the program, showcasing the extensibility of the DSL. - -## Disclaimer +The `hypershell!` macro expects `hypershell::prelude::*` in scope, and its expansion names the `cgp` +crate, so a program's crate depends on both. + +The library crates build on stable Rust, and so does a small program such as the one above. Large +programs can need nightly Rust with the next-generation trait solver. On stable Rust 1.98.1, the +repository's two compare examples, which nest whole programs inside others, grew `rustc` to about +7 GB while type-checking and were stopped; on nightly with `-Z next-solver=globally`, a fresh check +of one of them took about 9 seconds and 460 MB. A crate with programs of that size can copy the +repository's `rust-toolchain.toml` and `.cargo/config.toml`, which select a dated nightly and turn +the solver on. + +## The crates + +Hypershell is split into crates by backend, so a program compiles only the libraries it uses: + +- [`hypershell`](./crates/hypershell): the main crate, with `HypershellNamespace`, the error wiring, + the `HypershellCli` and `HypershellHttp` contexts, and the prelude a program imports. +- [`hypershell-macro`](./crates/hypershell-macro): the `hypershell!` macro, which provides the + shell-like syntax. +- [`hypershell-components`](./crates/hypershell-components): the syntax, such as `SimpleExec` and + `StreamingExec`, and the CGP components and traits the language builds on. +- [`hypershell-tokio-components`](./crates/hypershell-tokio-components): running external commands, + files, and streams, on Tokio. +- [`hypershell-reqwest-components`](./crates/hypershell-reqwest-components): HTTP requests, such as + `SimpleHttpRequest` and `StreamingHttpRequest`, on `reqwest`. +- [`hypershell-json-components`](./crates/hypershell-json-components): JSON encoding with + `EncodeJson` and decoding with `DecodeJson`. +- [`hypershell-hash-components`](./crates/hypershell-hash-components): an extension with native + checksums (`Checksum`) and hex encoding (`BytesToHex`). +- [`hypershell-tungstenite-components`](./crates/hypershell-tungstenite-components): an extension + with native WebSockets. + +The two extensions are not part of `HypershellNamespace`, so a program that uses them joins an +extended namespace or wires them on its context, as the examples show. The unpublished +[`hypershell-examples`](./crates/hypershell-examples) crate holds the examples below. + +## Examples + +Each example is a runnable program, run from the repository's root with +`cargo run -p hypershell-examples --example `. Most need the network and a few common +command-line tools. + +- [`hello.rs`](./crates/hypershell-examples/examples/hello.rs): runs `echo hello world!` through + `SimpleExec`. +- [`hello_name.rs`](./crates/hypershell-examples/examples/hello_name.rs): passes a value from a field + of the context to a shell command with `FieldArg`. +- [`http_checksum_cli.rs`](./crates/hypershell-examples/examples/http_checksum_cli.rs): fetches a URL + with `curl` and pipes the output to `sha256sum` and `cut` as streaming commands. +- [`http_checksum_client.rs`](./crates/hypershell-examples/examples/http_checksum_client.rs): fetches + the URL with the native HTTP client, then pipes the response through the same commands. +- [`http_checksum_native.rs`](./crates/hypershell-examples/examples/http_checksum_native.rs): the same + checksum in native stages, from a language extended with `Checksum`. +- [`nix_manual.rs`](./crates/hypershell-examples/examples/nix_manual.rs): combines a native HTTP + request with external command-line tools. +- [`save_webpage.rs`](./crates/hypershell-examples/examples/save_webpage.rs): downloads a webpage as a + stream and writes it to a file. +- [`github_issues.rs`](./crates/hypershell-examples/examples/github_issues.rs): calls a JSON web API + and decodes the result into a Rust type. +- [`rust_playground.rs`](./crates/hypershell-examples/examples/rust_playground.rs): sends a Rust + snippet to the Rust Playground API as JSON and decodes the response. +- [`bluesky.rs`](./crates/hypershell-examples/examples/bluesky.rs): connects to the Bluesky firehose + through `nix-shell` and `websocat`, then filters the stream with `grep`. +- [`bluesky_websocket.rs`](./crates/hypershell-examples/examples/bluesky_websocket.rs): the same + firehose, with native WebSockets added to the language. +- [`compare_and_branch.rs`](./crates/hypershell-examples/examples/compare_and_branch.rs) and + [`parallel_compare.rs`](./crates/hypershell-examples/examples/parallel_compare.rs): compare the + outputs of pipelines and branch on the result, with syntax the examples crate adds. + +## Status and costs + +Hypershell is a demonstration, and these are the costs to weigh first: + +- **Large programs need nightly.** As [Installation](#installation) describes, the library and small + programs build on stable Rust, and programs that nest others deeply can need nightly with the new + trait solver. +- **Programs are fixed at compile time.** A program is a type, so it cannot be loaded or changed + while the application runs. Values a program needs at run time, such as a URL, come from fields of + its context. +- **Error messages are long.** A mistake in a program is a compile error, and the compiler's raw + message lists every step it took before it failed. Checking the program with `check_components!` + and reading the error with + [`cargo cgp check`](https://contextgeneric.dev/docs/tooling/cargo-cgp/check) helps: + `cargo cgp check` leads with the root cause for the classes it recognizes, and the tool does not + yet reshape every class. +- **It is lightly tested.** Its value is as a worked example rather than a tool for production, and + the [limitations page](https://contextgeneric.dev/docs/projects/hypershell/limitations) describes + where the design stops and when a shell script or plain Rust fits better. + +## Building + +These are the commands CI runs: + +```sh +cargo build --workspace --all-targets +cargo test --workspace +``` -Hypershell is an **experimental** proof of concept designed to showcase the capabilities of Context-Generic Programming (CGP). Its primary purpose is to demonstrate how CGP can be used to build highly modular DSLs in Rust, rather than to be a production-ready shell replacement. +The workspace pins `nightly-2026-11-16` in `rust-toolchain.toml`, because `.cargo/config.toml` turns +on the next-generation trait solver with `-Z next-solver=globally`, so `cargo` selects that nightly +in the repository. Contributors and agents start from [AGENTS.md](AGENTS.md), which names these +checks. + +## Learn more + +The [project page](https://contextgeneric.dev/docs/projects/hypershell/) explains Hypershell: its +examples as short tutorials, the design one idea at a time, and guides to writing and debugging a +program. For CGP itself, start with the [quickstart](https://contextgeneric.dev/docs/quickstart), +then the [tutorials](https://contextgeneric.dev/docs/tutorials/hello) and the +[concepts](https://contextgeneric.dev/docs/concepts/), and the +[type-level DSLs](https://contextgeneric.dev/docs/concepts/type-level-dsls) page explains the +technique behind Hypershell with a smaller language. The +[CGP knowledge base](https://github.com/contextgeneric/cgp-knowledge-base) records the project in +depth for contributors and agents. diff --git a/crates/hypershell-components/Cargo.toml b/crates/hypershell-components/Cargo.toml index 8e4e083..1281447 100644 --- a/crates/hypershell-components/Cargo.toml +++ b/crates/hypershell-components/Cargo.toml @@ -1,13 +1,15 @@ [package] name = "hypershell-components" -version = "0.1.0" +version = "0.2.0-prerelease" edition = { workspace = true } license = { workspace = true } repository = { workspace = true } +homepage = { workspace = true } +categories = { workspace = true } authors = { workspace = true } rust-version = { workspace = true } keywords = { workspace = true } -description = "Modular DSL for shellscripting in Rust" +description = "The core abstract syntax and CGP components of the Hypershell DSL." [dependencies] cgp = { workspace = true } diff --git a/crates/hypershell-components/LICENSE b/crates/hypershell-components/LICENSE new file mode 120000 index 0000000..30cff74 --- /dev/null +++ b/crates/hypershell-components/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/crates/hypershell-components/README.md b/crates/hypershell-components/README.md new file mode 100644 index 0000000..4cf8162 --- /dev/null +++ b/crates/hypershell-components/README.md @@ -0,0 +1,30 @@ +[![Crates.io](https://img.shields.io/crates/v/hypershell-components.svg)](https://crates.io/crates/hypershell-components) +[![Docs.rs](https://docs.rs/hypershell-components/badge.svg)](https://docs.rs/hypershell-components) + +# hypershell-components: the syntax and components of Hypershell + +`hypershell-components` defines the abstract syntax of [Hypershell](https://docs.rs/hypershell), a +small language for shell-script-like programs in Rust built with +[Context-Generic Programming (CGP)](https://contextgeneric.dev/), and the CGP components that its +backend crates implement. Every piece of syntax is an empty struct that names an operation without +saying how it runs, so a backend crate can interpret it without this crate depending on any backend. + +**[hypershell](https://docs.rs/hypershell) · [Project page](https://contextgeneric.dev/docs/projects/hypershell/) · [Repository](https://github.com/contextgeneric/hypershell)** + +The crate is `no_std` and links `alloc`. Its items sit in four modules: + +- **`dsl`:** the syntax a program writes: execution (`SimpleExec`, `StreamingExec`, `WithArgs`, + `WithStaticArgs`, `FieldArgs`), arguments (`StaticArg`, `FieldArg`, `JoinArgs`, `UrlEncodeArg`), + HTTP (`SimpleHttpRequest`, `StreamingHttpRequest`, the method markers, `WithHeaders`, `Header`, + `WebSocket`), streams and files (`StreamToBytes`, `StreamToString`, `StreamToStdout`, + `BytesToStream`, `BytesToString`, `ReadFile`, `WriteFile`), JSON (`EncodeJson`, `DecodeJson`), and + control (`Pipe`, `Use`, `ConvertTo`). +- **`components`:** the components that extract a command, URL, string, or HTTP method from an + argument, and the abstract types they produce. +- **`providers`:** the providers that need no backend, such as `HandlePipe`, `Call`, and the + argument extractors, collected in the `HypershellBaseProvider` bundle. +- **`traits`:** `WrapCall` and `WrapStaticArg`, which map over type-level lists. + +`hypershell::prelude` re-exports the whole `dsl` module. The +[abstract syntax](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax) +page explains how a program becomes a type. diff --git a/crates/hypershell-components/src/components/command_arg.rs b/crates/hypershell-components/src/components/command_arg.rs index f0f692f..dbaf191 100644 --- a/crates/hypershell-components/src/components/command_arg.rs +++ b/crates/hypershell-components/src/components/command_arg.rs @@ -3,15 +3,17 @@ use core::marker::PhantomData; use cgp::core::component::UseDelegate; use cgp::prelude::*; +/// A context's abstract command-argument type. #[cgp_type] +#[prefix(@hypershell.core in DefaultNamespace)] pub trait HasCommandArgType { type CommandArg; } -#[cgp_component { - provider: CommandArgExtractor, - derive_delegate: UseDelegate, -}] +/// Extracts a command argument from the context. +#[cgp_component(CommandArgExtractor)] +#[prefix(@hypershell.core in DefaultNamespace)] +#[derive_delegate(UseDelegate)] pub trait CanExtractCommandArg: HasCommandArgType { fn extract_command_arg(&self, _phantom: PhantomData) -> Self::CommandArg; } diff --git a/crates/hypershell-components/src/components/method_arg.rs b/crates/hypershell-components/src/components/method_arg.rs index 3193a0b..03471c0 100644 --- a/crates/hypershell-components/src/components/method_arg.rs +++ b/crates/hypershell-components/src/components/method_arg.rs @@ -3,15 +3,17 @@ use core::marker::PhantomData; use cgp::core::component::UseDelegate; use cgp::prelude::*; +/// A context's abstract HTTP-method type. #[cgp_type] +#[prefix(@hypershell.core in DefaultNamespace)] pub trait HasHttpMethodType { type HttpMethod; } -#[cgp_component { - provider: MethodArgExtractor, - derive_delegate: UseDelegate, -}] +/// Extracts an HTTP method from the context. +#[cgp_component(MethodArgExtractor)] +#[prefix(@hypershell.core in DefaultNamespace)] +#[derive_delegate(UseDelegate)] pub trait CanExtractMethodArg: HasHttpMethodType { fn extract_method_arg(&self, _phantom: PhantomData) -> Self::HttpMethod; } diff --git a/crates/hypershell-components/src/components/string_arg.rs b/crates/hypershell-components/src/components/string_arg.rs index 449ac64..fdb9400 100644 --- a/crates/hypershell-components/src/components/string_arg.rs +++ b/crates/hypershell-components/src/components/string_arg.rs @@ -4,10 +4,10 @@ use core::marker::PhantomData; use cgp::core::component::UseDelegate; use cgp::prelude::*; -#[cgp_component { - provider: StringArgExtractor, - derive_delegate: UseDelegate, -}] +/// Extracts a string argument from the context. +#[cgp_component(StringArgExtractor)] +#[prefix(@hypershell.core in DefaultNamespace)] +#[derive_delegate(UseDelegate)] pub trait CanExtractStringArg { fn extract_string_arg(&self, _phantom: PhantomData) -> Cow<'_, str>; } diff --git a/crates/hypershell-components/src/components/url_arg.rs b/crates/hypershell-components/src/components/url_arg.rs index 8cb9cee..586b368 100644 --- a/crates/hypershell-components/src/components/url_arg.rs +++ b/crates/hypershell-components/src/components/url_arg.rs @@ -3,15 +3,17 @@ use core::marker::PhantomData; use cgp::core::component::UseDelegate; use cgp::prelude::*; +/// A context's abstract URL type. #[cgp_type] +#[prefix(@hypershell.core in DefaultNamespace)] pub trait HasUrlType { type Url; } -#[cgp_component { - provider: UrlArgExtractor, - derive_delegate: UseDelegate, -}] +/// Extracts a URL from the context. +#[cgp_component(UrlArgExtractor)] +#[prefix(@hypershell.core in DefaultNamespace)] +#[derive_delegate(UseDelegate)] pub trait CanExtractUrlArg: HasUrlType + HasErrorType { fn extract_url_arg(&self, _phantom: PhantomData) -> Result; } diff --git a/crates/hypershell-components/src/lib.rs b/crates/hypershell-components/src/lib.rs index d63f5a9..7e787cd 100644 --- a/crates/hypershell-components/src/lib.rs +++ b/crates/hypershell-components/src/lib.rs @@ -1,9 +1,9 @@ +#![doc = include_str!("../README.md")] #![no_std] extern crate alloc; pub mod components; pub mod dsl; -pub mod presets; pub mod providers; pub mod traits; diff --git a/crates/hypershell-components/src/presets.rs b/crates/hypershell-components/src/presets.rs deleted file mode 100644 index 3c5d71b..0000000 --- a/crates/hypershell-components/src/presets.rs +++ /dev/null @@ -1,65 +0,0 @@ -#[cgp::re_export_imports] -mod preset { - use alloc::boxed::Box; - - use cgp::core::component::UseDelegate; - use cgp::extra::handler::{HandlerComponent, Promote}; - use cgp::prelude::*; - - use crate::components::{StringArgExtractorComponent, UrlArgExtractorComponent}; - use crate::dsl::{BytesToString, ConvertTo, FieldArg, JoinArgs, Pipe, StaticArg, Use}; - use crate::providers::{ - BoxHandler, Call, DecodeUtf8Bytes, ExtractFieldArg, ExtractStaticArg, ExtractStringUrlArg, - HandleConvert, HandlePipe, HandleUseProvider, JoinStringArgs, - }; - - cgp_preset! { - HypershellBasePreset { - HandlerComponent: - BaseHandlerPreset::Provider, - StringArgExtractorComponent: - BaseStringArgExtractorPreset::Provider, - UrlArgExtractorComponent: - UrlArgExtractorPreset::Provider, - } - } - - cgp_preset! { - #[wrap_provider(UseDelegate)] - BaseStringArgExtractorPreset { - StaticArg: - ExtractStaticArg, - FieldArg: - ExtractFieldArg, - JoinArgs: - JoinStringArgs, - } - } - - cgp_preset! { - #[wrap_provider(UseDelegate)] - UrlArgExtractorPreset { - [ - StaticArg, - JoinArgs, - FieldArg, - ]: ExtractStringUrlArg, - } - } - - cgp_preset! { - #[wrap_provider(UseDelegate)] - BaseHandlerPreset { - BytesToString: - DecodeUtf8Bytes, - ConvertTo: - Promote, - Pipe: - HandlePipe, - Use: - HandleUseProvider, - Box: - BoxHandler>, - } - } -} diff --git a/crates/hypershell-components/src/providers/box_async.rs b/crates/hypershell-components/src/providers/box_async.rs index 495ffbb..d549293 100644 --- a/crates/hypershell-components/src/providers/box_async.rs +++ b/crates/hypershell-components/src/providers/box_async.rs @@ -5,8 +5,10 @@ use core::pin::Pin; use cgp::extra::handler::{Handler, HandlerComponent}; use cgp::prelude::*; +/// Runs a handler with its future boxed, erasing the future's type. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new BoxHandler)] -#[use_type(HasErrorType::Error)] +#[use_type(HasErrorType.Error)] #[use_provider(InHandler: Handler)] impl Handler where diff --git a/crates/hypershell-components/src/providers/call.rs b/crates/hypershell-components/src/providers/call.rs index 41c1610..4dde756 100644 --- a/crates/hypershell-components/src/providers/call.rs +++ b/crates/hypershell-components/src/providers/call.rs @@ -3,6 +3,7 @@ use core::marker::PhantomData; use cgp::extra::handler::{CanHandle, Handler, HandlerComponent}; use cgp::prelude::*; +/// Answers for any syntax by handling `InCode` on the context. #[cgp_impl(new Call)] impl Handler where diff --git a/crates/hypershell-components/src/providers/combined.rs b/crates/hypershell-components/src/providers/combined.rs new file mode 100644 index 0000000..7b7cd9b --- /dev/null +++ b/crates/hypershell-components/src/providers/combined.rs @@ -0,0 +1,55 @@ +use alloc::boxed::Box; + +use cgp::extra::handler::{HandlerComponent, Promote, PromoteAsync}; +use cgp::prelude::delegate_components; + +use crate::components::{ + CommandArgExtractorComponent, StringArgExtractorComponent, UrlArgExtractorComponent, +}; +use crate::dsl::{BytesToString, ConvertTo, FieldArg, JoinArgs, Pipe, StaticArg, Use}; +use crate::providers::{ + BoxHandler, Call, DecodeUtf8Bytes, ExtractFieldArg, ExtractStaticArg, ExtractStringCommandArg, + ExtractStringUrlArg, HandleConvert, HandlePipe, HandleUseProvider, JoinStringArgs, +}; + +delegate_components! { + new HypershellBaseProvider { + open { + HandlerComponent, + StringArgExtractorComponent, + CommandArgExtractorComponent, + UrlArgExtractorComponent, + }; + + @HandlerComponent.BytesToString: + DecodeUtf8Bytes, + // `HandleConvert` is a synchronous `Computer`: `PromoteAsync` lifts it to an + // `AsyncComputer`, which `Promote` lifts to a `Handler`. + @HandlerComponent. ConvertTo: + Promote>, + @HandlerComponent. Pipe: + HandlePipe, + @HandlerComponent. Use: + HandleUseProvider, + @HandlerComponent. Box: + BoxHandler>, + + @StringArgExtractorComponent. StaticArg: + ExtractStaticArg, + @StringArgExtractorComponent. FieldArg: + ExtractFieldArg, + @StringArgExtractorComponent. JoinArgs: + JoinStringArgs, + + @CommandArgExtractorComponent.[ + StaticArg, + FieldArg, + ]: ExtractStringCommandArg, + + @UrlArgExtractorComponent.[ + StaticArg, + JoinArgs, + FieldArg, + ]: ExtractStringUrlArg, + } +} diff --git a/crates/hypershell-components/src/providers/convert.rs b/crates/hypershell-components/src/providers/convert.rs index 6a5a104..4b3119f 100644 --- a/crates/hypershell-components/src/providers/convert.rs +++ b/crates/hypershell-components/src/providers/convert.rs @@ -9,6 +9,8 @@ use cgp::prelude::*; use crate::dsl::ConvertTo; +/// Converts its input into the output type with `Into`. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new HandleConvert)] impl Computer, Input> where @@ -21,8 +23,10 @@ where } } +/// Decodes byte input as a UTF-8 string, wrapping the failure with the raw bytes. See +/// [the streams and input dispatch page](https://contextgeneric.dev/docs/projects/hypershell/architecture/streams-and-input-dispatch). #[cgp_impl(new DecodeUtf8Bytes)] -#[use_type(HasErrorType::Error)] +#[use_type(HasErrorType.Error)] impl Handler where Self: CanRaiseError + for<'a> CanWrapError>, @@ -41,6 +45,7 @@ where } } +/// The detail that records the raw bytes of an input that is not valid UTF-8. pub struct DecodeUtf8InputError<'a> { pub raw_input: &'a [u8], } diff --git a/crates/hypershell-components/src/providers/method_arg.rs b/crates/hypershell-components/src/providers/method_arg.rs index bf9c87e..4315bd7 100644 --- a/crates/hypershell-components/src/providers/method_arg.rs +++ b/crates/hypershell-components/src/providers/method_arg.rs @@ -1,10 +1,13 @@ use core::marker::PhantomData; +use cgp::core::field::traits::HasField; use cgp::prelude::*; use crate::components::{HasHttpMethodType, MethodArgExtractor, MethodArgExtractorComponent}; use crate::dsl::FieldArg; +/// Reads the HTTP method from the context field named `Tag`. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new ExtractMethodFieldArg)] impl MethodArgExtractor> for Context where diff --git a/crates/hypershell-components/src/providers/mod.rs b/crates/hypershell-components/src/providers/mod.rs index 497e5de..71b4110 100644 --- a/crates/hypershell-components/src/providers/mod.rs +++ b/crates/hypershell-components/src/providers/mod.rs @@ -1,5 +1,6 @@ mod box_async; mod call; +mod combined; mod convert; mod method_arg; mod pipe; @@ -10,6 +11,7 @@ mod r#use; pub use box_async::*; pub use call::*; +pub use combined::*; pub use convert::*; pub use method_arg::*; pub use pipe::*; diff --git a/crates/hypershell-components/src/providers/return.rs b/crates/hypershell-components/src/providers/return.rs index a384f8f..ade039e 100644 --- a/crates/hypershell-components/src/providers/return.rs +++ b/crates/hypershell-components/src/providers/return.rs @@ -3,6 +3,8 @@ use core::marker::PhantomData; use cgp::extra::handler::{Handler, HandlerComponent}; use cgp::prelude::*; +/// Returns its input unchanged, for a stage that only passes a value on. See +/// [the streams and input dispatch page](https://contextgeneric.dev/docs/projects/hypershell/architecture/streams-and-input-dispatch). #[cgp_impl(new ReturnInput)] impl Handler for Context where diff --git a/crates/hypershell-components/src/providers/string_arg.rs b/crates/hypershell-components/src/providers/string_arg.rs index 5d20361..fc5c53c 100644 --- a/crates/hypershell-components/src/providers/string_arg.rs +++ b/crates/hypershell-components/src/providers/string_arg.rs @@ -4,6 +4,8 @@ use alloc::string::{String, ToString}; use core::fmt::Display; use core::marker::PhantomData; +use cgp::core::field::traits::HasField; +use cgp::core::field::types::{Cons, Nil}; use cgp::prelude::*; use crate::components::{ @@ -12,6 +14,8 @@ use crate::components::{ }; use crate::dsl::{FieldArg, JoinArgs, StaticArg}; +/// Extracts a command argument by converting the argument's string form with `From`. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new ExtractStringCommandArg)] impl CommandArgExtractor for Context where @@ -23,6 +27,8 @@ where } } +/// Extracts a literal argument by formatting its type's default value with `Display`. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new ExtractStaticArg)] impl StringArgExtractor> for Context where @@ -36,6 +42,8 @@ where } } +/// Extracts the context field named `Tag`, formatted with `Display`. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new ExtractFieldArg)] impl StringArgExtractor> for Context where @@ -46,8 +54,11 @@ where } } +/// Concatenates a `JoinArgs` list into one string, with no separator. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). pub struct JoinStringArgs; +/// Extracts the first element of a `JoinArgs` list and appends the rest. #[cgp_impl(JoinStringArgs)] impl StringArgExtractor>> for Context where @@ -69,6 +80,7 @@ where } } +/// Extracts the empty tail of a `JoinArgs` list as an empty string. #[cgp_impl(JoinStringArgs)] impl StringArgExtractor> for Context { fn extract_string_arg( diff --git a/crates/hypershell-components/src/providers/url_arg.rs b/crates/hypershell-components/src/providers/url_arg.rs index 8728290..34d9c69 100644 --- a/crates/hypershell-components/src/providers/url_arg.rs +++ b/crates/hypershell-components/src/providers/url_arg.rs @@ -1,6 +1,7 @@ use core::marker::PhantomData; use core::str::FromStr; +use cgp::core::field::traits::HasField; use cgp::prelude::*; use crate::components::{ @@ -8,6 +9,8 @@ use crate::components::{ }; use crate::dsl::FieldArg; +/// Parses the argument's string form into the context's URL type. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new ExtractStringUrlArg)] impl UrlArgExtractor for Context where @@ -23,6 +26,8 @@ where } } +/// Reads a pre-parsed URL from the context field named `Tag`. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new ExtractUrlFieldArg)] impl UrlArgExtractor> for Context where diff --git a/crates/hypershell-components/src/providers/use.rs b/crates/hypershell-components/src/providers/use.rs index 91b44d2..43e480f 100644 --- a/crates/hypershell-components/src/providers/use.rs +++ b/crates/hypershell-components/src/providers/use.rs @@ -5,6 +5,8 @@ use cgp::prelude::*; use crate::dsl::Use; +/// Runs the named provider inline instead of the context's wiring for the stage. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new HandleUseProvider)] impl Handler, Input> for Context where diff --git a/crates/hypershell-components/src/traits/wrap_call.rs b/crates/hypershell-components/src/traits/wrap_call.rs index 1e8a756..dd13bcd 100644 --- a/crates/hypershell-components/src/traits/wrap_call.rs +++ b/crates/hypershell-components/src/traits/wrap_call.rs @@ -1,4 +1,4 @@ -use cgp::prelude::*; +use cgp::core::field::types::{Cons, Nil}; use crate::providers::Call; diff --git a/crates/hypershell-components/src/traits/wrap_static_arg.rs b/crates/hypershell-components/src/traits/wrap_static_arg.rs index 8746e86..f4871ec 100644 --- a/crates/hypershell-components/src/traits/wrap_static_arg.rs +++ b/crates/hypershell-components/src/traits/wrap_static_arg.rs @@ -1,4 +1,4 @@ -use cgp::prelude::*; +use cgp::core::field::types::{Cons, Nil}; use crate::dsl::StaticArg; diff --git a/crates/hypershell-examples/Cargo.toml b/crates/hypershell-examples/Cargo.toml index 5e59b9e..09bc1dc 100644 --- a/crates/hypershell-examples/Cargo.toml +++ b/crates/hypershell-examples/Cargo.toml @@ -1,20 +1,22 @@ [package] name = "hypershell-examples" -version = "0.1.0" +version = "0.2.0-prerelease" edition = { workspace = true } license = { workspace = true } repository = { workspace = true } +homepage = { workspace = true } +categories = { workspace = true } authors = { workspace = true } rust-version = { workspace = true } keywords = { workspace = true } -description = "Modular DSL for shellscripting in Rust" +description = "Runnable examples of the Hypershell DSL." +publish = false [dependencies] hypershell = { workspace = true } hypershell-components = { workspace = true } hypershell-tokio-components = { workspace = true } hypershell-hash-components = { workspace = true } -hypershell-tungstenite-components = { workspace = true } cgp = { workspace = true } cgp-error-anyhow = { workspace = true } @@ -25,4 +27,7 @@ sha2 = { workspace = true } serde = { workspace = true, features = [ "derive" ] } tokio = { workspace = true, features = [ "macros", "rt", "io-std", "rt-multi-thread" ] } tokio-util = { workspace = true, features = [ "compat" ] } -tokio-tungstenite = { workspace = true } + +[dev-dependencies] +hypershell-tungstenite-components = { workspace = true } +tokio-tungstenite = { workspace = true } diff --git a/crates/hypershell-examples/examples/bluesky.rs b/crates/hypershell-examples/examples/bluesky.rs index cd4c2dc..5f2a93f 100644 --- a/crates/hypershell-examples/examples/bluesky.rs +++ b/crates/hypershell-examples/examples/bluesky.rs @@ -19,16 +19,16 @@ // on the console. // // The `MyApp` struct defines the context for the program, providing the -// `keyword` for `grep`. It inherits from `HypershellPreset` to get the -// necessary components for running CLI commands. +// `keyword` for `grep`. Its wiring joins `HypershellNamespace` to get the +// providers for running CLI commands. // // The `main` function initializes the `MyApp` context with a keyword and // runs the program. #![recursion_limit = "256"] +use hypershell::namespaces::HypershellNamespace; use hypershell::prelude::*; -use hypershell::presets::HypershellPreset; pub type Program = hypershell! { StreamingExec< @@ -47,12 +47,17 @@ pub type Program = hypershell! { | StreamToStdout }; -#[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct MyApp { pub keyword: String, } +delegate_components! { + MyApp { + namespace HypershellNamespace; + } +} + #[tokio::main] async fn main() -> Result<(), Error> { let app = MyApp { diff --git a/crates/hypershell-examples/examples/bluesky_websocket.rs b/crates/hypershell-examples/examples/bluesky_websocket.rs index b0180fe..08b5195 100644 --- a/crates/hypershell-examples/examples/bluesky_websocket.rs +++ b/crates/hypershell-examples/examples/bluesky_websocket.rs @@ -15,24 +15,25 @@ // 3. The final filtered output is piped to `StreamToStdout` to be printed // on the console. // -// Since the `WebSocket` handler is not part of the default `HypershellPreset`, -// a custom `MyAppPreset` is defined to extend Hypershell's functionality. -// -// The `MyAppPreset` inherits from `HypershellPreset` and overrides the -// `HandlerComponent` to include handlers from `TungsteniteHandlerPreset`, -// which provides the `WebSocket` handler implementation. It also overrides -// `ErrorRaiserComponent` to handle potential `TungsteniteError`s. -// -// The `MyApp` context is configured to use this custom `MyAppPreset`, -// enabling it to execute the program with the extended capabilities. +// `HypershellNamespace` does not route the `WebSocket` syntax, so the `MyApp` +// context adds two entries beside joining it. One routes `WebSocket` to +// `HypershellTungsteniteProvider`, the bundle from the +// `hypershell-tungstenite-components` extension crate that implements it. The +// other routes `TungsteniteError` to an error raiser, which the WebSocket +// provider requires. // // The `main` function initializes `MyApp` with a keyword and runs the program. // An empty input stream is provided to `app.handle` as required by the // handler signature, although it is not used by the `WebSocket` handler. +use cgp::core::error::ErrorRaiserComponent; +use cgp_error_anyhow::RaiseAnyhowError; +use hypershell::namespaces::HypershellNamespace; use hypershell::prelude::*; use hypershell_tokio_components::types::TokioAsyncReadStream; +use hypershell_tungstenite_components::providers::HypershellTungsteniteProvider; use tokio::io::simplex; +use tokio_tungstenite::tungstenite::Error as TungsteniteError; pub type Program = hypershell! { WebSocket< @@ -46,43 +47,20 @@ pub type Program = hypershell! { | StreamToStdout }; -#[cgp_inherit(MyAppPreset)] #[derive(HasField)] pub struct MyApp { pub keyword: String, } -#[cgp::re_export_imports] -mod preset { - use cgp::prelude::*; - use cgp_error_anyhow::RaiseAnyhowError; - use hypershell::presets::{HypershellErrorHandlers, HypershellHandlerPreset, HypershellPreset}; - use hypershell_tungstenite_components::presets::TungsteniteHandlerPreset; - use tokio_tungstenite::tungstenite::Error as TungsteniteError; +delegate_components! { + MyApp { + namespace HypershellNamespace; - cgp_preset! { - MyAppPreset: HypershellPreset { - override ErrorRaiserComponent: - MyErrorHandlers::Provider, - override HandlerComponent: - MyHandlerPreset::Provider, - } - } - - cgp_preset! { - #[wrap_provider(UseDelegate)] - MyErrorHandlers: HypershellErrorHandlers { - TungsteniteError: RaiseAnyhowError, - } - } + @cgp.core.error.ErrorRaiserComponent.TungsteniteError: + RaiseAnyhowError, - cgp_preset! { - #[wrap_provider(UseDelegate)] - MyHandlerPreset: - HypershellHandlerPreset - + TungsteniteHandlerPreset - { - } + @cgp.extra.handler.HandlerComponent. WebSocket: + HypershellTungsteniteProvider, } } diff --git a/crates/hypershell-examples/examples/compare_and_branch.rs b/crates/hypershell-examples/examples/compare_and_branch.rs index 6acc571..6beeb90 100644 --- a/crates/hypershell-examples/examples/compare_and_branch.rs +++ b/crates/hypershell-examples/examples/compare_and_branch.rs @@ -2,7 +2,7 @@ use hypershell::prelude::*; use hypershell_examples::dsl::{Compare, If}; -use hypershell_examples::presets::HypershellComparePreset; +use hypershell_examples::namespaces::HypershellCompareNamespace; use hypershell_hash_components::dsl::{BytesToHex, Checksum}; use reqwest::Client; use sha2::Sha256; @@ -39,7 +39,6 @@ pub type Program = hypershell! { | StreamToStdout }; -#[cgp_inherit(HypershellComparePreset)] #[derive(HasField)] pub struct MyApp { pub http_client: Client, @@ -47,6 +46,12 @@ pub struct MyApp { pub url_b: String, } +delegate_components! { + MyApp { + namespace HypershellCompareNamespace; + } +} + #[tokio::main] async fn main() -> Result<(), Error> { let app = MyApp { diff --git a/crates/hypershell-examples/examples/github_issues.rs b/crates/hypershell-examples/examples/github_issues.rs index 6198f63..ea0c795 100644 --- a/crates/hypershell-examples/examples/github_issues.rs +++ b/crates/hypershell-examples/examples/github_issues.rs @@ -18,15 +18,15 @@ // the JSON byte stream into a `Vec`. // // The `MyApp` struct defines the context for running the Hypershell program. -// It uses `#[cgp_inherit]` to inherit the necessary components from -// `HypershellPreset` for executing the program. It also uses `#[derive(HasField)]` -// to expose its fields to be used by `FieldArg` within the program definition. +// Its wiring joins `HypershellNamespace`, which routes the HTTP and JSON syntax +// the program uses. It also uses `#[derive(HasField)]` to expose its fields to be +// used by `FieldArg` within the program definition. // // The `main` function sets up the `MyApp` context with the required values, // executes the `Program` using `app.handle`, and prints the fetched issues. +use hypershell::namespaces::HypershellNamespace; use hypershell::prelude::*; -use hypershell::presets::HypershellPreset; use reqwest::Client; use serde::Deserialize; @@ -44,14 +44,13 @@ pub type Program = hypershell! { WithHeaders [ Header< StaticArg<"User-Agent">, - StaticArg<"hypershell">, + StaticArg<"hypershells">, > ], > | DecodeJson> }; -#[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct MyApp { pub http_client: Client, @@ -60,6 +59,12 @@ pub struct MyApp { pub github_repo: String, } +delegate_components! { + MyApp { + namespace HypershellNamespace; + } +} + #[derive(Debug, Deserialize)] #[allow(dead_code)] pub struct Issue { diff --git a/crates/hypershell-examples/examples/hello_name.rs b/crates/hypershell-examples/examples/hello_name.rs index 4d68abe..2674f92 100644 --- a/crates/hypershell-examples/examples/hello_name.rs +++ b/crates/hypershell-examples/examples/hello_name.rs @@ -18,13 +18,14 @@ // 5. The output is piped to `StreamToStdout`. // // To provide the dynamic `name` argument, a custom `MyApp` context is defined -// with a `name` field. The `#[cgp_inherit]` macro wires it up with the -// `HypershellPreset`, and `#[derive(HasField)]` makes its fields accessible +// with a `name` field. Its wiring joins `HypershellNamespace`, which routes +// every built-in syntax, and `#[derive(HasField)]` makes its fields accessible // to `FieldArg`. // // The `main` function creates an instance of `MyApp`, sets the `name`, and // executes the program. +use hypershell::namespaces::HypershellNamespace; use hypershell::prelude::*; pub type Program = hypershell! { @@ -38,12 +39,17 @@ pub type Program = hypershell! { | StreamToStdout }; -#[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct MyApp { pub name: String, } +delegate_components! { + MyApp { + namespace HypershellNamespace; + } +} + #[tokio::main] async fn main() -> Result<(), Error> { let app = MyApp { diff --git a/crates/hypershell-examples/examples/http_checksum_cli.rs b/crates/hypershell-examples/examples/http_checksum_cli.rs index 0b2a568..90e6db2 100644 --- a/crates/hypershell-examples/examples/http_checksum_cli.rs +++ b/crates/hypershell-examples/examples/http_checksum_cli.rs @@ -26,6 +26,7 @@ // // The `main` function initializes `MyApp` with a URL and executes the program. +use hypershell::namespaces::HypershellNamespace; use hypershell::prelude::*; pub type Program = hypershell! { @@ -51,12 +52,17 @@ pub type Program = hypershell! { | StreamToStdout }; -#[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct MyApp { pub url: String, } +delegate_components! { + MyApp { + namespace HypershellNamespace; + } +} + #[tokio::main] async fn main() -> Result<(), Error> { let app = MyApp { diff --git a/crates/hypershell-examples/examples/http_checksum_client.rs b/crates/hypershell-examples/examples/http_checksum_client.rs index de23b81..aeea489 100644 --- a/crates/hypershell-examples/examples/http_checksum_client.rs +++ b/crates/hypershell-examples/examples/http_checksum_client.rs @@ -26,6 +26,7 @@ // // The `main` function initializes the `MyApp` context and executes the program. +use hypershell::namespaces::HypershellNamespace; use hypershell::prelude::*; use reqwest::Client; @@ -51,13 +52,18 @@ pub type Program = hypershell! { | StreamToStdout }; -#[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct MyApp { pub http_client: Client, pub url: String, } +delegate_components! { + MyApp { + namespace HypershellNamespace; + } +} + #[tokio::main] async fn main() -> Result<(), Error> { let app = MyApp { diff --git a/crates/hypershell-examples/examples/http_checksum_native.rs b/crates/hypershell-examples/examples/http_checksum_native.rs index 5a78768..2a8ac1a 100644 --- a/crates/hypershell-examples/examples/http_checksum_native.rs +++ b/crates/hypershell-examples/examples/http_checksum_native.rs @@ -18,20 +18,17 @@ // // 4. The final hex string is piped to `StreamToStdout`. // -// Since `Checksum` and `BytesToHex` are not part of the default preset, a -// custom `MyAppPreset` is defined to extend `HypershellPreset`. This new -// preset overrides the `HandlerComponent` to include the providers for the -// new handlers (`HandleStreamChecksum` and `HandleBytesToHex`). -// -// The `MyApp` context is configured to use `MyAppPreset`, enabling it to -// execute the program with the new native handlers. +// `HypershellNamespace` does not route `Checksum` and `BytesToHex`, so the +// `MyApp` context joins `HypershellChecksumNamespace` instead. That namespace +// inherits `HypershellNamespace` and routes the two new syntaxes to +// `HypershellChecksumProvider`, the bundle holding their providers. // // The `main` function initializes the `MyApp` context and executes the program. #![recursion_limit = "256"] use hypershell::prelude::*; -use hypershell_examples::presets::HypershellChecksumPreset; +use hypershell_examples::namespaces::HypershellChecksumNamespace; use hypershell_hash_components::dsl::{BytesToHex, Checksum}; use reqwest::Client; use sha2::Sha256; @@ -47,13 +44,18 @@ pub type Program = hypershell! { | StreamToStdout }; -#[cgp_inherit(HypershellChecksumPreset)] #[derive(HasField)] pub struct MyApp { pub http_client: Client, pub url: String, } +delegate_components! { + MyApp { + namespace HypershellChecksumNamespace; + } +} + #[tokio::main] async fn main() -> Result<(), Error> { let app = MyApp { diff --git a/crates/hypershell-examples/examples/nix_manual.rs b/crates/hypershell-examples/examples/nix_manual.rs index ff7f472..f2fa0c3 100644 --- a/crates/hypershell-examples/examples/nix_manual.rs +++ b/crates/hypershell-examples/examples/nix_manual.rs @@ -24,8 +24,9 @@ // // The `main` function initializes the `MyApp` context and runs the program. +use cgp::core::field::types::Nil; +use hypershell::namespaces::HypershellNamespace; use hypershell::prelude::*; -use hypershell::presets::HypershellPreset; use reqwest::Client; pub type Program = hypershell! { @@ -51,13 +52,18 @@ pub type Program = hypershell! { | StreamToStdout }; -#[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct MyApp { pub http_client: Client, pub keyword: String, } +delegate_components! { + MyApp { + namespace HypershellNamespace; + } +} + #[tokio::main] async fn main() -> Result<(), Error> { let app = MyApp { diff --git a/crates/hypershell-examples/examples/parallel_compare.rs b/crates/hypershell-examples/examples/parallel_compare.rs index 4f9ccef..1d843e3 100644 --- a/crates/hypershell-examples/examples/parallel_compare.rs +++ b/crates/hypershell-examples/examples/parallel_compare.rs @@ -2,7 +2,7 @@ use hypershell::prelude::*; use hypershell_examples::dsl::Compare; -use hypershell_examples::presets::HypershellComparePreset; +use hypershell_examples::namespaces::HypershellCompareNamespace; use hypershell_hash_components::dsl::{BytesToHex, Checksum}; use reqwest::Client; use sha2::Sha256; @@ -24,7 +24,6 @@ pub type Program = hypershell! { > }; -#[cgp_inherit(HypershellComparePreset)] #[derive(HasField)] pub struct MyApp { pub http_client: Client, @@ -32,6 +31,12 @@ pub struct MyApp { pub url_b: String, } +delegate_components! { + MyApp { + namespace HypershellCompareNamespace; + } +} + #[tokio::main] async fn main() -> Result<(), Error> { let app = MyApp { diff --git a/crates/hypershell-examples/examples/save_webpage.rs b/crates/hypershell-examples/examples/save_webpage.rs index 4c0d0b5..d28ea88 100644 --- a/crates/hypershell-examples/examples/save_webpage.rs +++ b/crates/hypershell-examples/examples/save_webpage.rs @@ -19,6 +19,7 @@ // runs the program. A confirmation message is printed to the console upon // completion. +use hypershell::namespaces::HypershellNamespace; use hypershell::prelude::*; use reqwest::Client; @@ -31,7 +32,6 @@ pub type Program = hypershell! { | WriteFile> }; -#[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct MyApp { pub http_client: Client, @@ -39,6 +39,12 @@ pub struct MyApp { pub file_path: String, } +delegate_components! { + MyApp { + namespace HypershellNamespace; + } +} + #[tokio::main] async fn main() -> Result<(), Error> { let app = MyApp { diff --git a/crates/hypershell-examples/src/lib.rs b/crates/hypershell-examples/src/lib.rs index 3efa9e5..746e6ac 100644 --- a/crates/hypershell-examples/src/lib.rs +++ b/crates/hypershell-examples/src/lib.rs @@ -1,3 +1,3 @@ pub mod dsl; -pub mod presets; +pub mod namespaces; pub mod providers; diff --git a/crates/hypershell-examples/src/namespaces/checksum.rs b/crates/hypershell-examples/src/namespaces/checksum.rs new file mode 100644 index 0000000..564be58 --- /dev/null +++ b/crates/hypershell-examples/src/namespaces/checksum.rs @@ -0,0 +1,16 @@ +use cgp::extra::handler::HandlerComponent; +use cgp::prelude::cgp_namespace; +use hypershell::namespaces::HypershellNamespace; +use hypershell_hash_components::dsl::{BytesToHex, Checksum}; + +use crate::providers::HypershellChecksumProvider; + +cgp_namespace! { + new HypershellChecksumNamespace: HypershellNamespace { + @cgp.extra.handler.HandlerComponent.[ + Checksum, + BytesToHex, + ]: + HypershellChecksumProvider, + } +} diff --git a/crates/hypershell-examples/src/namespaces/compare.rs b/crates/hypershell-examples/src/namespaces/compare.rs new file mode 100644 index 0000000..207129e --- /dev/null +++ b/crates/hypershell-examples/src/namespaces/compare.rs @@ -0,0 +1,18 @@ +use cgp::extra::handler::HandlerComponent; +use cgp::prelude::cgp_namespace; +use hypershell_components::providers::BoxHandler; + +use crate::dsl::{Compare, If}; +use crate::namespaces::HypershellChecksumNamespace; +use crate::providers::{HandleCompare, HandleIf}; + +cgp_namespace! { + new HypershellCompareNamespace: HypershellChecksumNamespace { + // Note: The compare handler is somehow much slower when the future is not boxed + @cgp.extra.handler.HandlerComponent. Compare: + BoxHandler, + + @cgp.extra.handler.HandlerComponent. If: + HandleIf, + } +} diff --git a/crates/hypershell-examples/src/presets/mod.rs b/crates/hypershell-examples/src/namespaces/mod.rs similarity index 100% rename from crates/hypershell-examples/src/presets/mod.rs rename to crates/hypershell-examples/src/namespaces/mod.rs diff --git a/crates/hypershell-examples/src/presets/checksum.rs b/crates/hypershell-examples/src/presets/checksum.rs deleted file mode 100644 index 0175a1c..0000000 --- a/crates/hypershell-examples/src/presets/checksum.rs +++ /dev/null @@ -1,29 +0,0 @@ -#[cgp::re_export_imports] -mod preset { - use cgp::extra::handler::PipeHandlers; - use hypershell::prelude::*; - use hypershell::presets::HypershellHandlerPreset; - use hypershell_hash_components::dsl::{BytesToHex, Checksum}; - use hypershell_hash_components::providers::{HandleBytesToHex, HandleStreamChecksum}; - use hypershell_tokio_components::presets::ToFuturesStreamHandlers; - - cgp_preset! { - HypershellChecksumPreset: HypershellPreset { - override HandlerComponent: - ChecksumHandlerPreset::Provider, - } - } - - cgp_preset! { - #[wrap_provider(UseDelegate)] - ChecksumHandlerPreset: HypershellHandlerPreset { - Checksum: - PipeHandlers, - BytesToHex: - HandleBytesToHex, - } - } -} diff --git a/crates/hypershell-examples/src/presets/compare.rs b/crates/hypershell-examples/src/presets/compare.rs deleted file mode 100644 index a475a7a..0000000 --- a/crates/hypershell-examples/src/presets/compare.rs +++ /dev/null @@ -1,28 +0,0 @@ -#[cgp::re_export_imports] -mod preset { - use cgp::extra::handler::HandlerComponent; - use hypershell::prelude::*; - use hypershell_components::providers::BoxHandler; - - use crate::dsl::{Compare, If}; - use crate::presets::ChecksumHandlerPreset; - use crate::providers::{HandleCompare, HandleIf}; - - cgp_preset! { - HypershellComparePreset: HypershellPreset { - override HandlerComponent: - CompareHandlerPreset::Provider, - } - } - - cgp_preset! { - #[wrap_provider(UseDelegate)] - CompareHandlerPreset: ChecksumHandlerPreset { - // Note: The compare handler is somehow much slower when the future is not boxed - Compare: - BoxHandler, - If: - HandleIf, - } - } -} diff --git a/crates/hypershell-examples/src/providers/checksum.rs b/crates/hypershell-examples/src/providers/checksum.rs new file mode 100644 index 0000000..de9bb94 --- /dev/null +++ b/crates/hypershell-examples/src/providers/checksum.rs @@ -0,0 +1,20 @@ +use cgp::extra::handler::{HandlerComponent, PipeHandlers}; +use cgp::prelude::*; +use hypershell_hash_components::dsl::{BytesToHex, Checksum}; +use hypershell_hash_components::providers::{HandleBytesToHex, HandleStreamChecksum}; +use hypershell_tokio_components::providers::HandleToFuturesStream; + +delegate_components! { + new HypershellChecksumProvider { + open {HandlerComponent}; + + @HandlerComponent. Checksum: + PipeHandlers, + + @HandlerComponent.BytesToHex: + HandleBytesToHex, + } +} diff --git a/crates/hypershell-examples/src/providers/compare.rs b/crates/hypershell-examples/src/providers/compare.rs index 752e946..0adff23 100644 --- a/crates/hypershell-examples/src/providers/compare.rs +++ b/crates/hypershell-examples/src/providers/compare.rs @@ -6,6 +6,7 @@ use hypershell::prelude::CanHandle; use crate::dsl::Compare; +/// Runs two sub-programs on their inputs and reports whether their outputs are equal. #[cgp_impl(new HandleCompare)] impl Handler, (InputA, InputB)> for Context diff --git a/crates/hypershell-examples/src/providers/if.rs b/crates/hypershell-examples/src/providers/if.rs index f4d939b..9f8b70b 100644 --- a/crates/hypershell-examples/src/providers/if.rs +++ b/crates/hypershell-examples/src/providers/if.rs @@ -6,6 +6,7 @@ use hypershell::prelude::CanHandle; use crate::dsl::If; +/// Runs one of two sub-programs on the branch input, chosen by a condition sub-program. #[cgp_impl(new HandleIf)] impl Handler, (InputCond, InputBranch)> for Context diff --git a/crates/hypershell-examples/src/providers/mod.rs b/crates/hypershell-examples/src/providers/mod.rs index 2c8b3f3..44e8568 100644 --- a/crates/hypershell-examples/src/providers/mod.rs +++ b/crates/hypershell-examples/src/providers/mod.rs @@ -1,5 +1,7 @@ +mod checksum; mod compare; mod r#if; +pub use checksum::*; pub use compare::*; pub use r#if::*; diff --git a/crates/hypershell-examples/tests/tests/field.rs b/crates/hypershell-examples/tests/tests/field.rs index dd10c1b..25d30c9 100644 --- a/crates/hypershell-examples/tests/tests/field.rs +++ b/crates/hypershell-examples/tests/tests/field.rs @@ -1,14 +1,19 @@ +use hypershell::namespaces::HypershellNamespace; use hypershell::prelude::*; -use hypershell::presets::HypershellPreset; #[tokio::test] async fn test_join_fields() -> Result<(), Error> { - #[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct TestApp { pub base_dir: String, } + delegate_components! { + TestApp { + namespace HypershellNamespace; + } + } + pub type Program = hypershell! { SimpleExec< StaticArg<"ls">, @@ -36,12 +41,17 @@ async fn test_join_fields() -> Result<(), Error> { #[tokio::test] async fn test_field_args() -> Result<(), Error> { - #[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct TestApp<'a> { pub args: Vec<&'a str>, } + delegate_components! { + <'a> TestApp<'a> { + namespace HypershellNamespace; + } + } + pub type Program = SimpleExec, FieldArgs>; let app = TestApp { diff --git a/crates/hypershell-examples/tests/tests/pipe.rs b/crates/hypershell-examples/tests/tests/pipe.rs index 60a6fa3..5d3d82c 100644 --- a/crates/hypershell-examples/tests/tests/pipe.rs +++ b/crates/hypershell-examples/tests/tests/pipe.rs @@ -1,14 +1,19 @@ +use hypershell::namespaces::HypershellNamespace; use hypershell::prelude::*; -use hypershell::presets::HypershellPreset; #[tokio::test] async fn test_simple_pipe() -> Result<(), Error> { - #[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct TestApp { pub base_dir: String, } + delegate_components! { + TestApp { + namespace HypershellNamespace; + } + } + pub type Program = Pipe< Product![ ReadFile< diff --git a/crates/hypershell-hash-components/Cargo.toml b/crates/hypershell-hash-components/Cargo.toml index 7cdafc7..91b11dc 100644 --- a/crates/hypershell-hash-components/Cargo.toml +++ b/crates/hypershell-hash-components/Cargo.toml @@ -1,17 +1,17 @@ [package] name = "hypershell-hash-components" -version = "0.1.0" +version = "0.2.0-prerelease" edition = { workspace = true } license = { workspace = true } repository = { workspace = true } +homepage = { workspace = true } +categories = { workspace = true } authors = { workspace = true } rust-version = { workspace = true } keywords = { workspace = true } -description = "Modular DSL for shellscripting in Rust" +description = "Checksum and hex-encoding handlers for Hypershell." [dependencies] -hypershell-components = { workspace = true } - cgp = { workspace = true } futures = { workspace = true } sha2 = { workspace = true } diff --git a/crates/hypershell-hash-components/LICENSE b/crates/hypershell-hash-components/LICENSE new file mode 120000 index 0000000..30cff74 --- /dev/null +++ b/crates/hypershell-hash-components/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/crates/hypershell-hash-components/README.md b/crates/hypershell-hash-components/README.md new file mode 100644 index 0000000..7e65cb1 --- /dev/null +++ b/crates/hypershell-hash-components/README.md @@ -0,0 +1,19 @@ +[![Crates.io](https://img.shields.io/crates/v/hypershell-hash-components.svg)](https://crates.io/crates/hypershell-hash-components) +[![Docs.rs](https://docs.rs/hypershell-hash-components/badge.svg)](https://docs.rs/hypershell-hash-components) + +# hypershell-hash-components: checksums as a Hypershell extension + +`hypershell-hash-components` extends [Hypershell](https://docs.rs/hypershell), a small language for +shell-script-like programs in Rust built with +[Context-Generic Programming (CGP)](https://contextgeneric.dev/), with two pieces of syntax and +their providers, in a crate the core language does not depend on. `Checksum` hashes a stream +of bytes with any `Digest` hasher, such as `sha2::Sha256`, through `HandleStreamChecksum`, and +`BytesToHex` writes bytes as hexadecimal, through `HandleBytesToHex`. + +**[hypershell](https://docs.rs/hypershell) · [Project page](https://contextgeneric.dev/docs/projects/hypershell/) · [Repository](https://github.com/contextgeneric/hypershell)** + +`HypershellNamespace` does not route this syntax, so a program that uses it runs on a context that +joins an extended namespace or wires the providers itself. The repository's +[`http_checksum_native`](https://contextgeneric.dev/docs/projects/hypershell/examples/http-checksum-native) +example joins a namespace that inherits the base language and adds `Checksum`, changing one line of +its context. diff --git a/crates/hypershell-hash-components/src/lib.rs b/crates/hypershell-hash-components/src/lib.rs index bfb4758..327051f 100644 --- a/crates/hypershell-hash-components/src/lib.rs +++ b/crates/hypershell-hash-components/src/lib.rs @@ -1,2 +1,3 @@ +#![doc = include_str!("../README.md")] pub mod dsl; pub mod providers; diff --git a/crates/hypershell-hash-components/src/providers/bytes_to_hex.rs b/crates/hypershell-hash-components/src/providers/bytes_to_hex.rs index 097d43a..8cf541a 100644 --- a/crates/hypershell-hash-components/src/providers/bytes_to_hex.rs +++ b/crates/hypershell-hash-components/src/providers/bytes_to_hex.rs @@ -3,6 +3,8 @@ use core::marker::PhantomData; use cgp::extra::handler::{Handler, HandlerComponent}; use cgp::prelude::*; +/// Encodes byte-like input as a lowercase hexadecimal string. See +/// [the native checksum example](https://contextgeneric.dev/docs/projects/hypershell/examples/http-checksum-native). #[cgp_impl(new HandleBytesToHex)] impl Handler for Context where diff --git a/crates/hypershell-hash-components/src/providers/stream_checksum.rs b/crates/hypershell-hash-components/src/providers/stream_checksum.rs index 9b9b5fe..195eaff 100644 --- a/crates/hypershell-hash-components/src/providers/stream_checksum.rs +++ b/crates/hypershell-hash-components/src/providers/stream_checksum.rs @@ -8,6 +8,8 @@ use sha2::digest::generic_array::GenericArray; use crate::dsl::Checksum; +/// Folds a stream of byte chunks into a digest with the chosen `sha2` hasher. See +/// [the native checksum example](https://contextgeneric.dev/docs/projects/hypershell/examples/http-checksum-native). #[cgp_impl(new HandleStreamChecksum)] impl Handler, Input> for Context where diff --git a/crates/hypershell-json-components/Cargo.toml b/crates/hypershell-json-components/Cargo.toml index 1b8dafa..b1ba4a0 100644 --- a/crates/hypershell-json-components/Cargo.toml +++ b/crates/hypershell-json-components/Cargo.toml @@ -1,13 +1,15 @@ [package] name = "hypershell-json-components" -version = "0.1.0" +version = "0.2.0-prerelease" edition = { workspace = true } license = { workspace = true } repository = { workspace = true } +homepage = { workspace = true } +categories = { workspace = true } authors = { workspace = true } rust-version = { workspace = true } keywords = { workspace = true } -description = "Modular DSL for shellscripting in Rust" +description = "JSON encoding and decoding handlers for Hypershell." [dependencies] hypershell-components = { workspace = true } diff --git a/crates/hypershell-json-components/LICENSE b/crates/hypershell-json-components/LICENSE new file mode 120000 index 0000000..30cff74 --- /dev/null +++ b/crates/hypershell-json-components/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/crates/hypershell-json-components/README.md b/crates/hypershell-json-components/README.md new file mode 100644 index 0000000..0db874c --- /dev/null +++ b/crates/hypershell-json-components/README.md @@ -0,0 +1,16 @@ +[![Crates.io](https://img.shields.io/crates/v/hypershell-json-components.svg)](https://crates.io/crates/hypershell-json-components) +[![Docs.rs](https://docs.rs/hypershell-json-components/badge.svg)](https://docs.rs/hypershell-json-components) + +# hypershell-json-components: JSON stages for Hypershell + +`hypershell-json-components` interprets the JSON syntax of [Hypershell](https://docs.rs/hypershell), +a small language for shell-script-like programs in Rust built with +[Context-Generic Programming (CGP)](https://contextgeneric.dev/), on +[`serde_json`](https://docs.rs/serde_json). `HandleEncodeJson` interprets `EncodeJson`, which writes +a Rust value as JSON bytes, and `HandleDecodeJson` interprets `DecodeJson`, which reads JSON +bytes into a `T`. Both are collected in the `HypershellJsonProvider` bundle. + +**[hypershell](https://docs.rs/hypershell) · [Project page](https://contextgeneric.dev/docs/projects/hypershell/) · [Repository](https://github.com/contextgeneric/hypershell)** + +The crate is `no_std` and links `alloc`, and `HypershellNamespace` routes both stages for every +context that joins it. diff --git a/crates/hypershell-json-components/src/lib.rs b/crates/hypershell-json-components/src/lib.rs index bf902c4..2c42535 100644 --- a/crates/hypershell-json-components/src/lib.rs +++ b/crates/hypershell-json-components/src/lib.rs @@ -1,6 +1,6 @@ +#![doc = include_str!("../README.md")] #![no_std] extern crate alloc; -pub mod presets; pub mod providers; diff --git a/crates/hypershell-json-components/src/presets.rs b/crates/hypershell-json-components/src/presets.rs deleted file mode 100644 index 140bd06..0000000 --- a/crates/hypershell-json-components/src/presets.rs +++ /dev/null @@ -1,26 +0,0 @@ -#[cgp::re_export_imports] -mod preset { - use cgp::core::component::UseDelegate; - use cgp::extra::handler::HandlerComponent; - use cgp::prelude::*; - use hypershell_components::dsl::{DecodeJson, EncodeJson}; - - use crate::providers::{HandleDecodeJson, HandleEncodeJson}; - - cgp_preset! { - HypershellJsonPreset { - HandlerComponent: - JsonHandlerPreset::Provider, - } - } - - cgp_preset! { - #[wrap_provider(UseDelegate)] - JsonHandlerPreset { - DecodeJson: - HandleDecodeJson, - EncodeJson: - HandleEncodeJson, - } - } -} diff --git a/crates/hypershell-json-components/src/providers/combined.rs b/crates/hypershell-json-components/src/providers/combined.rs new file mode 100644 index 0000000..a72e551 --- /dev/null +++ b/crates/hypershell-json-components/src/providers/combined.rs @@ -0,0 +1,17 @@ +use cgp::extra::handler::HandlerComponent; +use cgp::prelude::delegate_components; +use hypershell_components::dsl::{DecodeJson, EncodeJson}; + +use crate::providers::{HandleDecodeJson, HandleEncodeJson}; + +delegate_components! { + new HypershellJsonProvider { + open {HandlerComponent}; + + @HandlerComponent.EncodeJson: + HandleEncodeJson, + + @HandlerComponent. DecodeJson: + HandleDecodeJson, + } +} diff --git a/crates/hypershell-json-components/src/providers/handler.rs b/crates/hypershell-json-components/src/providers/handler.rs index 2b25b0a..93e51c1 100644 --- a/crates/hypershell-json-components/src/providers/handler.rs +++ b/crates/hypershell-json-components/src/providers/handler.rs @@ -7,6 +7,8 @@ use hypershell_components::dsl::DecodeJson; use serde::Serialize; use serde::de::DeserializeOwned; +/// Deserializes byte input into `Output` with `serde_json`. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new HandleDecodeJson)] impl Handler, Input> for Context where @@ -26,6 +28,8 @@ where } } +/// Serializes its input to JSON bytes with `serde_json`. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new HandleEncodeJson)] impl Handler for Context where diff --git a/crates/hypershell-json-components/src/providers/mod.rs b/crates/hypershell-json-components/src/providers/mod.rs index 7298495..1d84097 100644 --- a/crates/hypershell-json-components/src/providers/mod.rs +++ b/crates/hypershell-json-components/src/providers/mod.rs @@ -1,3 +1,5 @@ +mod combined; mod handler; +pub use combined::*; pub use handler::*; diff --git a/crates/hypershell-macro/Cargo.toml b/crates/hypershell-macro/Cargo.toml index 87a65bd..1fe0a6c 100644 --- a/crates/hypershell-macro/Cargo.toml +++ b/crates/hypershell-macro/Cargo.toml @@ -1,13 +1,15 @@ [package] name = "hypershell-macro" -version = "0.1.0" +version = "0.2.0-prerelease" edition = { workspace = true } license = { workspace = true } repository = { workspace = true } +homepage = { workspace = true } +categories = { workspace = true } authors = { workspace = true } rust-version = { workspace = true } keywords = { workspace = true } -description = "Modular DSL for shellscripting in Rust" +description = "The hypershell! procedural macro for the Hypershell DSL." [lib] proc-macro = true diff --git a/crates/hypershell-macro/LICENSE b/crates/hypershell-macro/LICENSE new file mode 120000 index 0000000..30cff74 --- /dev/null +++ b/crates/hypershell-macro/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/crates/hypershell-macro/README.md b/crates/hypershell-macro/README.md new file mode 100644 index 0000000..157e6b3 --- /dev/null +++ b/crates/hypershell-macro/README.md @@ -0,0 +1,16 @@ +[![Crates.io](https://img.shields.io/crates/v/hypershell-macro.svg)](https://crates.io/crates/hypershell-macro) +[![Docs.rs](https://docs.rs/hypershell-macro/badge.svg)](https://docs.rs/hypershell-macro) + +# hypershell-macro: the hypershell! macro + +`hypershell-macro` provides the `hypershell!` procedural macro of +[Hypershell](https://docs.rs/hypershell), a small language for shell-script-like programs in Rust +built with [Context-Generic Programming (CGP)](https://contextgeneric.dev/). The macro rewrites a +shell-like surface into the Rust type that is the program: `|` becomes a `Pipe` of the stages, a +bracketed list becomes a type-level list, and each string literal becomes a type-level string. + +**[hypershell](https://docs.rs/hypershell) · [Project page](https://contextgeneric.dev/docs/projects/hypershell/) · [Repository](https://github.com/contextgeneric/hypershell)** + +A program reaches the macro through `hypershell::prelude`, so it has no reason to depend on this +crate directly. The macro only rewrites tokens and resolves no names, so its expansion expects the +prelude in scope and names the `cgp` crate. diff --git a/crates/hypershell-macro/src/lib.rs b/crates/hypershell-macro/src/lib.rs index 8fea4cd..ffb202c 100644 --- a/crates/hypershell-macro/src/lib.rs +++ b/crates/hypershell-macro/src/lib.rs @@ -1,3 +1,4 @@ +#![doc = include_str!("../README.md")] use proc_macro::TokenStream; use proc_macro2::TokenStream as TokenStream2; diff --git a/crates/hypershell-reqwest-components/Cargo.toml b/crates/hypershell-reqwest-components/Cargo.toml index dae3d53..23cecda 100644 --- a/crates/hypershell-reqwest-components/Cargo.toml +++ b/crates/hypershell-reqwest-components/Cargo.toml @@ -1,13 +1,15 @@ [package] name = "hypershell-reqwest-components" -version = "0.1.0" +version = "0.2.0-prerelease" edition = { workspace = true } license = { workspace = true } repository = { workspace = true } +homepage = { workspace = true } +categories = { workspace = true } authors = { workspace = true } rust-version = { workspace = true } keywords = { workspace = true } -description = "Modular DSL for shellscripting in Rust" +description = "Native HTTP handlers for Hypershell, built on reqwest." [dependencies] hypershell-components = { workspace = true } diff --git a/crates/hypershell-reqwest-components/LICENSE b/crates/hypershell-reqwest-components/LICENSE new file mode 120000 index 0000000..30cff74 --- /dev/null +++ b/crates/hypershell-reqwest-components/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/crates/hypershell-reqwest-components/README.md b/crates/hypershell-reqwest-components/README.md new file mode 100644 index 0000000..70c8e8c --- /dev/null +++ b/crates/hypershell-reqwest-components/README.md @@ -0,0 +1,25 @@ +[![Crates.io](https://img.shields.io/crates/v/hypershell-reqwest-components.svg)](https://crates.io/crates/hypershell-reqwest-components) +[![Docs.rs](https://docs.rs/hypershell-reqwest-components/badge.svg)](https://docs.rs/hypershell-reqwest-components) + +# hypershell-reqwest-components: HTTP requests on reqwest + +`hypershell-reqwest-components` interprets the HTTP syntax of +[Hypershell](https://docs.rs/hypershell), a small language for shell-script-like programs in Rust +built with [Context-Generic Programming (CGP)](https://contextgeneric.dev/), on +[`reqwest`](https://docs.rs/reqwest). It sends simple and streaming requests with the method, URL, +and headers a program names, and reports a failed response as an error. + +**[hypershell](https://docs.rs/hypershell) · [Project page](https://contextgeneric.dev/docs/projects/hypershell/) · [Repository](https://github.com/contextgeneric/hypershell)** + +Its items sit in three modules: + +- **`dsl`:** the core request syntax `CoreHttpRequest`. +- **`components`:** `CanUpdateRequestBuilder`, which adds a program's headers to a request, and + `HasReqwestClient`, which reads the HTTP client from the context. +- **`providers`:** the request providers, the method extractor and header updaters, `StreamToBody` + for a streamed request body, and the `ErrorResponse` error, collected in the + `HypershellReqwestProvider` bundle. + +The crate builds on [`hypershell-tokio-components`](https://docs.rs/hypershell-tokio-components) for +its stream types. `HypershellNamespace` routes its syntax, and the `HypershellHttp` context supplies +the client. diff --git a/crates/hypershell-reqwest-components/src/components/client.rs b/crates/hypershell-reqwest-components/src/components/client.rs index 5f8f16e..36fc594 100644 --- a/crates/hypershell-reqwest-components/src/components/client.rs +++ b/crates/hypershell-reqwest-components/src/components/client.rs @@ -1,7 +1,9 @@ use cgp::prelude::*; use reqwest::Client; +/// Gets the `reqwest` client an HTTP handler sends its requests with. #[cgp_getter] +#[prefix(@hypershell.reqwest in DefaultNamespace)] pub trait HasReqwestClient { fn request_client(&self) -> &Client; } diff --git a/crates/hypershell-reqwest-components/src/components/update_builder.rs b/crates/hypershell-reqwest-components/src/components/update_builder.rs index 5e6e097..a07fbf0 100644 --- a/crates/hypershell-reqwest-components/src/components/update_builder.rs +++ b/crates/hypershell-reqwest-components/src/components/update_builder.rs @@ -4,10 +4,10 @@ use cgp::core::component::UseDelegate; use cgp::prelude::*; use reqwest::RequestBuilder; -#[cgp_component { - provider: RequestBuilderUpdater, - derive_delegate: UseDelegate, -}] +/// Applies a request-parameter syntax to a `reqwest::RequestBuilder`. +#[cgp_component(RequestBuilderUpdater)] +#[derive_delegate(UseDelegate)] +#[prefix(@hypershell.reqwest in DefaultNamespace)] pub trait CanUpdateRequestBuilder: HasErrorType { fn update_request_builder( &self, diff --git a/crates/hypershell-reqwest-components/src/lib.rs b/crates/hypershell-reqwest-components/src/lib.rs index e8d91fa..5bd643f 100644 --- a/crates/hypershell-reqwest-components/src/lib.rs +++ b/crates/hypershell-reqwest-components/src/lib.rs @@ -1,4 +1,4 @@ +#![doc = include_str!("../README.md")] pub mod components; pub mod dsl; -pub mod presets; pub mod providers; diff --git a/crates/hypershell-reqwest-components/src/presets.rs b/crates/hypershell-reqwest-components/src/presets.rs deleted file mode 100644 index 8e7740e..0000000 --- a/crates/hypershell-reqwest-components/src/presets.rs +++ /dev/null @@ -1,88 +0,0 @@ -#[cgp::re_export_imports] -mod preset { - use cgp::core::component::UseDelegate; - use cgp::extra::handler::{HandlerComponent, PipeHandlers}; - use cgp::prelude::{cgp_preset, *}; - use hypershell_components::components::{ - HttpMethodTypeProviderComponent, MethodArgExtractorComponent, StringArgExtractorComponent, - UrlTypeProviderComponent, - }; - use hypershell_components::dsl::{ - GetMethod, Header, PostMethod, SimpleHttpRequest, StreamingHttpRequest, UrlEncodeArg, - WithHeaders, - }; - use hypershell_tokio_components::presets::ToTokioAsyncReadHandlers; - use hypershell_tokio_components::providers::WrapFuturesAsyncRead; - use reqwest::{Method, Url}; - - use crate::components::RequestBuilderUpdaterComponent; - use crate::dsl::CoreHttpRequest; - use crate::providers::{ - ExtractReqwestMethod, HandleCoreHttpRequest, HandleSimpleHttpRequest, - HandleStreamingHttpRequest, StreamToBody, UpdateRequestHeader, UpdateRequestHeaders, - UrlEncodeStringArg, - }; - - cgp_preset! { - HypershellReqwestPreset { - HandlerComponent: - ReqwestHandlerPreset::Provider, - HttpMethodTypeProviderComponent: - UseType, - UrlTypeProviderComponent: - UseType, - StringArgExtractorComponent: - ReqwestStringArgExtractorPreset::Provider, - MethodArgExtractorComponent: - MethodArgExtractorPreset::Provider, - RequestBuilderUpdaterComponent: - RequestBuilderUpdaterPreset::Provider, - } - } - - cgp_preset! { - #[wrap_provider(UseDelegate)] - ReqwestHandlerPreset { - SimpleHttpRequest: - HandleSimpleHttpRequest, - StreamingHttpRequest: - PipeHandlers, - CoreHttpRequest: - HandleCoreHttpRequest, - } - } - - cgp_preset! { - #[wrap_provider(UseDelegate)] - MethodArgExtractorPreset { - [ - GetMethod, - PostMethod, - ]: - ExtractReqwestMethod, - } - } - - cgp_preset! { - #[wrap_provider(UseDelegate)] - ReqwestStringArgExtractorPreset { - UrlEncodeArg: - UrlEncodeStringArg, - } - } - - cgp_preset! { - #[wrap_provider(UseDelegate)] - RequestBuilderUpdaterPreset { - WithHeaders: - UpdateRequestHeaders, - Header: - UpdateRequestHeader, - } - } -} diff --git a/crates/hypershell-reqwest-components/src/providers/combined.rs b/crates/hypershell-reqwest-components/src/providers/combined.rs new file mode 100644 index 0000000..be7c164 --- /dev/null +++ b/crates/hypershell-reqwest-components/src/providers/combined.rs @@ -0,0 +1,84 @@ +use cgp::extra::handler::{HandlerComponent, PipeHandlers}; +use cgp::prelude::*; +use hypershell_components::components::{ + CommandArgExtractorComponent, HttpMethodTypeProviderComponent, MethodArgExtractorComponent, + StringArgExtractorComponent, UrlArgExtractorComponent, UrlTypeProviderComponent, +}; +use hypershell_components::dsl::{ + DeleteMethod, GetMethod, Header, PostMethod, PutMethod, SimpleHttpRequest, + StreamingHttpRequest, UrlEncodeArg, WithHeaders, +}; +use hypershell_tokio_components::providers::{HandleToTokioAsyncRead, WrapFuturesAsyncRead}; +use hypershell_tokio_components::types::{FuturesAsyncReadStream, TokioAsyncReadStream}; +use reqwest::Method; +use url::Url; + +use crate::components::RequestBuilderUpdaterComponent; +use crate::dsl::CoreHttpRequest; +use crate::providers::{ + ExtractReqwestMethod, HandleCoreHttpRequest, HandleSimpleHttpRequest, + HandleStreamingHttpRequest, StreamToBody, UpdateRequestHeader, UpdateRequestHeaders, + UrlEncodeStringArg, +}; + +delegate_components! { + new HypershellReqwestProvider { + open { + HandlerComponent, + StringArgExtractorComponent, + CommandArgExtractorComponent, + UrlArgExtractorComponent, + MethodArgExtractorComponent, + RequestBuilderUpdaterComponent, + }; + + HttpMethodTypeProviderComponent: + UseType, + + UrlTypeProviderComponent: + UseType, + + @HandlerComponent. SimpleHttpRequest: + HandleSimpleHttpRequest, + + // A byte buffer is sent as a buffered body, which `reqwest` can resend when it follows a + // redirect. A streamed body cannot be resent, so a reader input does not follow one. + @HandlerComponent + . StreamingHttpRequest + .[Vec, String]: + PipeHandlers, + + @HandlerComponent + . StreamingHttpRequest + .[ TokioAsyncReadStream, FuturesAsyncReadStream]: + PipeHandlers, + + @HandlerComponent. CoreHttpRequest: + HandleCoreHttpRequest, + + @MethodArgExtractorComponent.[ + GetMethod, + PostMethod, + PutMethod, + DeleteMethod, + ]: + ExtractReqwestMethod, + + @StringArgExtractorComponent. UrlEncodeArg: + UrlEncodeStringArg, + + @RequestBuilderUpdaterComponent. WithHeaders: + UpdateRequestHeaders, + + @RequestBuilderUpdaterComponent. Header: + UpdateRequestHeader, + } +} diff --git a/crates/hypershell-reqwest-components/src/providers/convert.rs b/crates/hypershell-reqwest-components/src/providers/convert.rs index 7fdcb47..b84b69e 100644 --- a/crates/hypershell-reqwest-components/src/providers/convert.rs +++ b/crates/hypershell-reqwest-components/src/providers/convert.rs @@ -6,6 +6,7 @@ use reqwest::Body; use tokio::io::AsyncRead; use tokio_util::io::ReaderStream; +/// Converts an async reader into a `reqwest::Body` streamed as it is read. #[cgp_impl(new StreamToBody)] impl Handler for Context where diff --git a/crates/hypershell-reqwest-components/src/providers/core_request.rs b/crates/hypershell-reqwest-components/src/providers/core_request.rs index bbbd5c7..e81c9e5 100644 --- a/crates/hypershell-reqwest-components/src/providers/core_request.rs +++ b/crates/hypershell-reqwest-components/src/providers/core_request.rs @@ -8,6 +8,8 @@ use reqwest::{Body, Method, Response, Url}; use crate::components::{CanUpdateRequestBuilder, HasReqwestClient}; use crate::dsl::CoreHttpRequest; +/// Builds a request from the method, URL, and header syntax, attaches the body, and sends it. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new HandleCoreHttpRequest)] impl Handler, Input> for Context diff --git a/crates/hypershell-reqwest-components/src/providers/headers.rs b/crates/hypershell-reqwest-components/src/providers/headers.rs index 4978cc2..27fbe8b 100644 --- a/crates/hypershell-reqwest-components/src/providers/headers.rs +++ b/crates/hypershell-reqwest-components/src/providers/headers.rs @@ -1,5 +1,6 @@ use core::marker::PhantomData; +use cgp::core::field::types::{Cons, Nil}; use cgp::prelude::*; use hypershell_components::components::CanExtractStringArg; use hypershell_components::dsl::{Header, WithHeaders}; @@ -10,6 +11,8 @@ use crate::components::{ CanUpdateRequestBuilder, RequestBuilderUpdater, RequestBuilderUpdaterComponent, }; +/// Sets one header on the request builder from the extracted key and value. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new UpdateRequestHeader)] impl RequestBuilderUpdater> for Context where @@ -34,6 +37,8 @@ where } } +/// Applies each `Header` of a `WithHeaders` list to the request builder in turn. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). pub struct UpdateRequestHeaders; #[cgp_impl(UpdateRequestHeaders)] diff --git a/crates/hypershell-reqwest-components/src/providers/method_arg.rs b/crates/hypershell-reqwest-components/src/providers/method_arg.rs index c746f64..249da48 100644 --- a/crates/hypershell-reqwest-components/src/providers/method_arg.rs +++ b/crates/hypershell-reqwest-components/src/providers/method_arg.rs @@ -7,6 +7,8 @@ use hypershell_components::components::{ use hypershell_components::dsl::{DeleteMethod, GetMethod, PostMethod, PutMethod}; use reqwest::Method; +/// Maps an HTTP method marker to the matching `reqwest::Method` constant. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). pub struct ExtractReqwestMethod; #[cgp_impl(ExtractReqwestMethod)] diff --git a/crates/hypershell-reqwest-components/src/providers/mod.rs b/crates/hypershell-reqwest-components/src/providers/mod.rs index 4330ab5..75a8466 100644 --- a/crates/hypershell-reqwest-components/src/providers/mod.rs +++ b/crates/hypershell-reqwest-components/src/providers/mod.rs @@ -1,3 +1,4 @@ +mod combined; mod convert; mod core_request; mod headers; @@ -6,6 +7,7 @@ mod simple_request; mod streaming_request; mod url_encode; +pub use combined::*; pub use convert::*; pub use core_request::*; pub use headers::*; diff --git a/crates/hypershell-reqwest-components/src/providers/simple_request.rs b/crates/hypershell-reqwest-components/src/providers/simple_request.rs index 0bac57a..b79c799 100644 --- a/crates/hypershell-reqwest-components/src/providers/simple_request.rs +++ b/crates/hypershell-reqwest-components/src/providers/simple_request.rs @@ -7,11 +7,14 @@ use reqwest::Response; use crate::dsl::CoreHttpRequest; +/// The error raised for a response whose status is not a success. #[derive(Debug)] pub struct ErrorResponse { pub response: Response, } +/// Sends one request with the input as its body and returns the whole response body. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new HandleSimpleHttpRequest)] impl Handler, Input> for Context diff --git a/crates/hypershell-reqwest-components/src/providers/streaming_request.rs b/crates/hypershell-reqwest-components/src/providers/streaming_request.rs index 4c2df6e..4d720b7 100644 --- a/crates/hypershell-reqwest-components/src/providers/streaming_request.rs +++ b/crates/hypershell-reqwest-components/src/providers/streaming_request.rs @@ -10,6 +10,8 @@ use reqwest::Response; use crate::dsl::CoreHttpRequest; use crate::providers::ErrorResponse; +/// Sends one request with the input as its body and returns the response body as a stream. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new HandleStreamingHttpRequest)] impl Handler, Input> for Context diff --git a/crates/hypershell-reqwest-components/src/providers/url_encode.rs b/crates/hypershell-reqwest-components/src/providers/url_encode.rs index 204e988..1df5a21 100644 --- a/crates/hypershell-reqwest-components/src/providers/url_encode.rs +++ b/crates/hypershell-reqwest-components/src/providers/url_encode.rs @@ -8,6 +8,8 @@ use hypershell_components::components::{ use hypershell_components::dsl::UrlEncodeArg; use url::form_urlencoded; +/// Percent-encodes the argument's string form for use in a URL query. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new UrlEncodeStringArg)] impl StringArgExtractor> for Context where diff --git a/crates/hypershell-tokio-components/Cargo.toml b/crates/hypershell-tokio-components/Cargo.toml index 0bc4fad..010b0fc 100644 --- a/crates/hypershell-tokio-components/Cargo.toml +++ b/crates/hypershell-tokio-components/Cargo.toml @@ -1,13 +1,15 @@ [package] name = "hypershell-tokio-components" -version = "0.1.0" +version = "0.2.0-prerelease" edition = { workspace = true } license = { workspace = true } repository = { workspace = true } +homepage = { workspace = true } +categories = { workspace = true } authors = { workspace = true } rust-version = { workspace = true } keywords = { workspace = true } -description = "Modular DSL for shellscripting in Rust" +description = "Tokio-based handlers for executing commands and handling file I/O in Hypershell." [dependencies] hypershell-components = { workspace = true } diff --git a/crates/hypershell-tokio-components/LICENSE b/crates/hypershell-tokio-components/LICENSE new file mode 120000 index 0000000..30cff74 --- /dev/null +++ b/crates/hypershell-tokio-components/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/crates/hypershell-tokio-components/README.md b/crates/hypershell-tokio-components/README.md new file mode 100644 index 0000000..5f5d8e6 --- /dev/null +++ b/crates/hypershell-tokio-components/README.md @@ -0,0 +1,28 @@ +[![Crates.io](https://img.shields.io/crates/v/hypershell-tokio-components.svg)](https://crates.io/crates/hypershell-tokio-components) +[![Docs.rs](https://docs.rs/hypershell-tokio-components/badge.svg)](https://docs.rs/hypershell-tokio-components) + +# hypershell-tokio-components: commands, files, and streams on Tokio + +`hypershell-tokio-components` interprets the process, file, and stream syntax of +[Hypershell](https://docs.rs/hypershell), a small language for shell-script-like programs in Rust +built with [Context-Generic Programming (CGP)](https://contextgeneric.dev/), on +[Tokio](https://tokio.rs/). It runs external commands, simple and streaming, reads and writes files, +writes to standard output, and converts between bytes and the stream types that stages exchange. + +**[hypershell](https://docs.rs/hypershell) · [Project page](https://contextgeneric.dev/docs/projects/hypershell/) · [Repository](https://github.com/contextgeneric/hypershell)** + +Its items sit in four modules: + +- **`dsl`:** the core execution syntax `CoreExec`, and `ToTokioAsyncRead`, which turns a stage's + input into a Tokio reader. +- **`components`:** `CanUpdateCommand`, which adds a program's arguments to a + `tokio::process::Command`. +- **`providers`:** the providers for commands, files, standard output, and the stream adapters, the + input dispatchers that pick an adapter by the type a stage receives, and the execution error + types, collected in the `HypershellTokioProvider` bundle. +- **`types`:** the stream wrappers `TokioAsyncReadStream`, `FuturesAsyncReadStream`, and + `FuturesStream`, and `ChildOutputStream`, a streamed command's output. + +`HypershellNamespace` routes this crate's syntax for every context that joins it. The +[streams and input dispatch](https://contextgeneric.dev/docs/projects/hypershell/architecture/streams-and-input-dispatch) +page explains how stages exchange streams. diff --git a/crates/hypershell-tokio-components/src/components/update_command.rs b/crates/hypershell-tokio-components/src/components/update_command.rs index 701d59b..2b3c2b9 100644 --- a/crates/hypershell-tokio-components/src/components/update_command.rs +++ b/crates/hypershell-tokio-components/src/components/update_command.rs @@ -4,10 +4,10 @@ use cgp::core::component::UseDelegate; use cgp::prelude::*; use tokio::process::Command; -#[cgp_component { - provider: CommandUpdater, - derive_delegate: UseDelegate, -}] +/// Applies an argument-list syntax to a Tokio `Command`. +#[cgp_component(CommandUpdater)] +#[prefix(@hypershell.tokio in DefaultNamespace)] +#[derive_delegate(UseDelegate)] pub trait CanUpdateCommand { fn update_command(&self, _phantom: PhantomData, command: &mut Command); } diff --git a/crates/hypershell-tokio-components/src/lib.rs b/crates/hypershell-tokio-components/src/lib.rs index 8950c34..2e28c12 100644 --- a/crates/hypershell-tokio-components/src/lib.rs +++ b/crates/hypershell-tokio-components/src/lib.rs @@ -1,5 +1,5 @@ +#![doc = include_str!("../README.md")] pub mod components; pub mod dsl; -pub mod presets; pub mod providers; pub mod types; diff --git a/crates/hypershell-tokio-components/src/presets.rs b/crates/hypershell-tokio-components/src/presets.rs deleted file mode 100644 index 88d088b..0000000 --- a/crates/hypershell-tokio-components/src/presets.rs +++ /dev/null @@ -1,133 +0,0 @@ -#[cgp::re_export_imports] -mod preset { - use std::path::PathBuf; - use std::string::String; - use std::vec::Vec; - - use cgp::core::component::UseDelegate; - use cgp::extra::handler::{HandlerComponent, PipeHandlers, UseInputDelegate}; - use cgp::prelude::{cgp_preset, *}; - use hypershell_components::components::{ - CommandArgExtractorComponent, CommandArgTypeProviderComponent, - }; - use hypershell_components::dsl::{ - BytesToStream, FieldArg, FieldArgs, JoinArgs, ReadFile, SimpleExec, StaticArg, - StreamToBytes, StreamToStdout, StreamToString, StreamingExec, WithArgs, WriteFile, - }; - use hypershell_components::providers::{ExtractStringCommandArg, ReturnInput}; - - use crate::components::CommandUpdaterComponent; - use crate::dsl::{CoreExec, ToTokioAsyncRead}; - use crate::providers::{ - AsyncReadToStream, ExtractArgs, ExtractFieldArgs, FuturesToTokioAsyncRead, - HandleBytesToStream, HandleBytesToTokioAsyncRead, HandleCoreExec, HandleReadFile, - HandleSimpleExec, HandleStreamToStdout, HandleStreamingExec, HandleTokioAsyncReadToBytes, - HandleTokioAsyncReadToString, HandleWriteFile, JoinExtractArgs, WrapTokioAsyncRead, - }; - use crate::types::{FuturesAsyncReadStream, TokioAsyncReadStream}; - - cgp_preset! { - HypershellTokioPreset { - CommandArgTypeProviderComponent: - UseType, - HandlerComponent: - TokioHandlerPreset::Provider, - CommandArgExtractorComponent: - CommandArgExtractorPreset::Provider, - CommandUpdaterComponent: - CommandUpdaterPreset::Provider, - } - } - - cgp_preset! { - #[wrap_provider(UseDelegate)] - TokioHandlerPreset { - SimpleExec: - HandleSimpleExec, - StreamingExec: - PipeHandlers, - CoreExec: - HandleCoreExec, - ReadFile: - PipeHandlers, - WriteFile: - PipeHandlers, - StreamToBytes: - HandleTokioAsyncReadToBytes, - StreamToString: - HandleTokioAsyncReadToString, - BytesToStream: - HandleBytesToTokioAsyncRead, - StreamToStdout: - PipeHandlers, - ToTokioAsyncRead: - ToTokioAsyncReadHandlers::Provider, - } - } - - cgp_preset! { - #[wrap_provider(UseDelegate)] - CommandArgExtractorPreset { - [ - StaticArg, - FieldArg, - ]: ExtractStringCommandArg, - JoinArgs: - JoinExtractArgs, - } - } - - cgp_preset! { - #[wrap_provider(UseDelegate)] - CommandUpdaterPreset { - WithArgs: ExtractArgs, - FieldArgs: ExtractFieldArgs, - } - } - - cgp_preset! { - #[wrap_provider(UseInputDelegate)] - ToTokioAsyncReadHandlers { - FuturesAsyncReadStream: - FuturesToTokioAsyncRead, - TokioAsyncReadStream: - ReturnInput, - [ - Vec, - String, - ]: - HandleBytesToTokioAsyncRead, - } - } - - cgp_preset! { - #[wrap_provider(UseInputDelegate)] - ToFuturesStreamHandlers { - FuturesAsyncReadStream: - PipeHandlers, - TokioAsyncReadStream: - AsyncReadToStream, - [ - Vec, - String, - ]: - HandleBytesToStream, - } - } -} diff --git a/crates/hypershell-tokio-components/src/providers/async_read.rs b/crates/hypershell-tokio-components/src/providers/async_read.rs new file mode 100644 index 0000000..18cb284 --- /dev/null +++ b/crates/hypershell-tokio-components/src/providers/async_read.rs @@ -0,0 +1,27 @@ +use cgp::extra::handler::HandlerComponent; +use cgp::prelude::delegate_components; +use hypershell_components::providers::ReturnInput; + +use crate::providers::{FuturesToTokioAsyncRead, HandleBytesToTokioAsyncRead}; +use crate::types::{FuturesAsyncReadStream, TokioAsyncReadStream}; + +delegate_components! { + new HandleToTokioAsyncRead { + open HandlerComponent; + + @HandlerComponent + . Code + . FuturesAsyncReadStream: + FuturesToTokioAsyncRead, + @HandlerComponent + . Code + . TokioAsyncReadStream: + ReturnInput, + @HandlerComponent + . Code.[ + Vec, + String, + ]: + HandleBytesToTokioAsyncRead, + } +} diff --git a/crates/hypershell-tokio-components/src/providers/combined.rs b/crates/hypershell-tokio-components/src/providers/combined.rs new file mode 100644 index 0000000..1767bbd --- /dev/null +++ b/crates/hypershell-tokio-components/src/providers/combined.rs @@ -0,0 +1,88 @@ +use std::path::PathBuf; + +use cgp::extra::handler::{HandlerComponent, PipeHandlers}; +use cgp::prelude::*; +use hypershell_components::components::{ + CommandArgExtractorComponent, CommandArgTypeProviderComponent, StringArgExtractorComponent, + UrlArgExtractorComponent, +}; +use hypershell_components::dsl::{ + BytesToStream, FieldArgs, JoinArgs, ReadFile, SimpleExec, StreamToBytes, StreamToStdout, + StreamToString, StreamingExec, WithArgs, WriteFile, +}; + +use crate::components::CommandUpdaterComponent; +use crate::dsl::{CoreExec, ToTokioAsyncRead}; +use crate::providers::{ + ExtractArgs, ExtractFieldArgs, HandleBytesToTokioAsyncRead, HandleCoreExec, HandleReadFile, + HandleSimpleExec, HandleStreamToStdout, HandleStreamingExec, HandleToTokioAsyncRead, + HandleTokioAsyncReadToBytes, HandleTokioAsyncReadToString, HandleWriteFile, JoinExtractArgs, + WrapTokioAsyncRead, +}; + +delegate_components! { + new HypershellTokioProvider { + open { + HandlerComponent, + StringArgExtractorComponent, + CommandArgExtractorComponent, + UrlArgExtractorComponent, + CommandUpdaterComponent, + }; + + CommandArgTypeProviderComponent: + UseType, + + @HandlerComponent. SimpleExec: + HandleSimpleExec, + + @HandlerComponent. StreamingExec: + PipeHandlers, + + @HandlerComponent. CoreExec: + HandleCoreExec, + + @HandlerComponent. ReadFile: + PipeHandlers, + + @HandlerComponent. WriteFile: + PipeHandlers, + + @HandlerComponent.StreamToBytes: + HandleTokioAsyncReadToBytes, + + @HandlerComponent.StreamToString: + HandleTokioAsyncReadToString, + + @HandlerComponent.BytesToStream: + HandleBytesToTokioAsyncRead, + + @HandlerComponent.StreamToStdout: + PipeHandlers, + + @HandlerComponent.ToTokioAsyncRead: + HandleToTokioAsyncRead, + + @CommandArgExtractorComponent. JoinArgs: + JoinExtractArgs, + + @CommandUpdaterComponent. WithArgs: + ExtractArgs, + + @CommandUpdaterComponent. FieldArgs: + ExtractFieldArgs, + } +} diff --git a/crates/hypershell-tokio-components/src/providers/core_exec.rs b/crates/hypershell-tokio-components/src/providers/core_exec.rs index b6c79a7..01f8240 100644 --- a/crates/hypershell-tokio-components/src/providers/core_exec.rs +++ b/crates/hypershell-tokio-components/src/providers/core_exec.rs @@ -13,6 +13,8 @@ use tokio::process::{Child, Command}; use crate::components::CanUpdateCommand; use crate::dsl::CoreExec; +/// Builds a Tokio `Command` from the path and arguments and spawns it with all three streams piped. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new HandleCoreExec)] impl Handler, ()> for Context where @@ -59,10 +61,12 @@ where } } +/// The detail that formats a failed spawn with the command's program and arguments. pub struct SpawnCommandFailure<'a> { pub command: &'a Command, } +/// The detail that names the program a failed spawn could not find. pub struct CommandNotFound<'a> { pub command: &'a Command, } diff --git a/crates/hypershell-tokio-components/src/providers/file.rs b/crates/hypershell-tokio-components/src/providers/file.rs index e209594..3b3815a 100644 --- a/crates/hypershell-tokio-components/src/providers/file.rs +++ b/crates/hypershell-tokio-components/src/providers/file.rs @@ -8,6 +8,8 @@ use hypershell_components::dsl::{ReadFile, WriteFile}; use tokio::fs::File; use tokio::io::AsyncRead; +/// Opens a file as a Tokio reader. See +/// [the streams and input dispatch page](https://contextgeneric.dev/docs/projects/hypershell/architecture/streams-and-input-dispatch). #[cgp_impl(new HandleReadFile)] impl Handler, ()> for Context where @@ -31,6 +33,8 @@ where } } +/// Creates or truncates a file and copies its input into it. See +/// [the streams and input dispatch page](https://contextgeneric.dev/docs/projects/hypershell/architecture/streams-and-input-dispatch). #[cgp_impl(new HandleWriteFile)] impl Handler, Input> for Context where diff --git a/crates/hypershell-tokio-components/src/providers/futures_stream.rs b/crates/hypershell-tokio-components/src/providers/futures_stream.rs new file mode 100644 index 0000000..83ca875 --- /dev/null +++ b/crates/hypershell-tokio-components/src/providers/futures_stream.rs @@ -0,0 +1,30 @@ +use cgp::extra::handler::{HandlerComponent, PipeHandlers}; +use cgp::prelude::*; + +use crate::providers::{AsyncReadToStream, FuturesToTokioAsyncRead, HandleBytesToStream}; +use crate::types::{FuturesAsyncReadStream, TokioAsyncReadStream}; + +delegate_components! { + new HandleToFuturesStream { + open HandlerComponent; + + @HandlerComponent + . Code + . FuturesAsyncReadStream: + PipeHandlers, + @HandlerComponent + . Code + . TokioAsyncReadStream: + AsyncReadToStream, + @HandlerComponent + . Code + .[ + Vec, + String, + ]: + HandleBytesToStream, + } +} diff --git a/crates/hypershell-tokio-components/src/providers/join_args.rs b/crates/hypershell-tokio-components/src/providers/join_args.rs index 0f1d438..0dd93fc 100644 --- a/crates/hypershell-tokio-components/src/providers/join_args.rs +++ b/crates/hypershell-tokio-components/src/providers/join_args.rs @@ -1,12 +1,15 @@ use core::marker::PhantomData; use std::path::PathBuf; +use cgp::core::field::types::{Cons, Nil}; use cgp::prelude::*; use hypershell_components::components::{ CanExtractCommandArg, CommandArgExtractor, CommandArgExtractorComponent, HasCommandArgType, }; use hypershell_components::dsl::JoinArgs; +/// Joins a `JoinArgs` list into one path with `PathBuf::join`, skipping an empty tail. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). pub struct JoinExtractArgs; #[cgp_impl(JoinExtractArgs)] diff --git a/crates/hypershell-tokio-components/src/providers/line.rs b/crates/hypershell-tokio-components/src/providers/line.rs index 70ae723..6d0f4f7 100644 --- a/crates/hypershell-tokio-components/src/providers/line.rs +++ b/crates/hypershell-tokio-components/src/providers/line.rs @@ -7,6 +7,8 @@ use hypershell_components::dsl::StreamToLines; use tokio::io::AsyncRead; use tokio_util::codec::{FramedRead, LinesCodec, LinesCodecError}; +/// Reads an async reader as a stream of lines. See +/// [the streams and input dispatch page](https://contextgeneric.dev/docs/projects/hypershell/architecture/streams-and-input-dispatch). #[cgp_impl(new HandleStreamToLines)] impl Handler for Context where diff --git a/crates/hypershell-tokio-components/src/providers/mod.rs b/crates/hypershell-tokio-components/src/providers/mod.rs index b7df3ee..08d9cb8 100644 --- a/crates/hypershell-tokio-components/src/providers/mod.rs +++ b/crates/hypershell-tokio-components/src/providers/mod.rs @@ -1,5 +1,8 @@ +mod async_read; +mod combined; mod core_exec; mod file; +mod futures_stream; mod join_args; mod line; mod out; @@ -8,8 +11,11 @@ mod stream; mod streaming_exec; mod update_command; +pub use async_read::*; +pub use combined::*; pub use core_exec::*; pub use file::*; +pub use futures_stream::*; pub use join_args::*; pub use line::*; pub use out::*; diff --git a/crates/hypershell-tokio-components/src/providers/out.rs b/crates/hypershell-tokio-components/src/providers/out.rs index 457facd..4222606 100644 --- a/crates/hypershell-tokio-components/src/providers/out.rs +++ b/crates/hypershell-tokio-components/src/providers/out.rs @@ -5,6 +5,8 @@ use cgp::prelude::*; use hypershell_components::dsl::StreamToStdout; use tokio::io::{AsyncRead, copy}; +/// Copies its input to the program's standard output. See +/// [the streams and input dispatch page](https://contextgeneric.dev/docs/projects/hypershell/architecture/streams-and-input-dispatch). #[cgp_impl(new HandleStreamToStdout)] impl Handler for Context where diff --git a/crates/hypershell-tokio-components/src/providers/simple_exec.rs b/crates/hypershell-tokio-components/src/providers/simple_exec.rs index 899a8a5..90146cc 100644 --- a/crates/hypershell-tokio-components/src/providers/simple_exec.rs +++ b/crates/hypershell-tokio-components/src/providers/simple_exec.rs @@ -10,10 +10,13 @@ use tokio::process::Child; use crate::dsl::CoreExec; +/// The error raised for a command that exits with a non-success status. pub struct ExecOutputError { pub output: Output, } +/// Runs a command to completion, writing its input to standard input and returning standard output. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new HandleSimpleExec)] impl Handler, Input> for Context where @@ -59,6 +62,7 @@ where } } +/// The detail that marks a failed write to a child's standard input. pub struct StdinPipeError; impl Debug for StdinPipeError { @@ -67,6 +71,7 @@ impl Debug for StdinPipeError { } } +/// The detail that marks a failed wait for a child's output. pub struct WaitWithOutputError; impl Debug for WaitWithOutputError { diff --git a/crates/hypershell-tokio-components/src/providers/stream.rs b/crates/hypershell-tokio-components/src/providers/stream.rs index c74b9c5..f243538 100644 --- a/crates/hypershell-tokio-components/src/providers/stream.rs +++ b/crates/hypershell-tokio-components/src/providers/stream.rs @@ -13,6 +13,8 @@ use tokio_util::io::ReaderStream; use crate::types::{FuturesAsyncReadStream, FuturesStream, TokioAsyncReadStream}; +/// Reads a Tokio reader to the end as bytes. See +/// [the streams and input dispatch page](https://contextgeneric.dev/docs/projects/hypershell/architecture/streams-and-input-dispatch). #[cgp_impl(new HandleTokioAsyncReadToBytes)] impl Handler for Context where @@ -37,6 +39,8 @@ where } } +/// Reads a Tokio reader to the end as a UTF-8 string. See +/// [the streams and input dispatch page](https://contextgeneric.dev/docs/projects/hypershell/architecture/streams-and-input-dispatch). #[cgp_impl(new HandleTokioAsyncReadToString)] impl Handler for Context where @@ -61,6 +65,8 @@ where } } +/// Wraps byte input as a Tokio reader. See +/// [the streams and input dispatch page](https://contextgeneric.dev/docs/projects/hypershell/architecture/streams-and-input-dispatch). #[cgp_impl(new HandleBytesToTokioAsyncRead)] impl Handler for Context where @@ -78,6 +84,8 @@ where } } +/// Wraps byte input as a futures stream of one chunk. See +/// [the streams and input dispatch page](https://contextgeneric.dev/docs/projects/hypershell/architecture/streams-and-input-dispatch). #[cgp_impl(new HandleBytesToStream)] impl Handler for Context where @@ -95,6 +103,8 @@ where } } +/// Adapts a futures reader to a Tokio reader. See +/// [the streams and input dispatch page](https://contextgeneric.dev/docs/projects/hypershell/architecture/streams-and-input-dispatch). #[cgp_impl(new FuturesToTokioAsyncRead)] impl Handler for Context where @@ -112,6 +122,8 @@ where } } +/// Adapts a Tokio reader to a futures reader. See +/// [the streams and input dispatch page](https://contextgeneric.dev/docs/projects/hypershell/architecture/streams-and-input-dispatch). #[cgp_impl(new TokioToFuturesAsyncRead)] impl Handler for Context where @@ -129,6 +141,8 @@ where } } +/// Tags a Tokio reader with its wrapper type. See +/// [the streams and input dispatch page](https://contextgeneric.dev/docs/projects/hypershell/architecture/streams-and-input-dispatch). #[cgp_impl(new WrapTokioAsyncRead)] impl Handler for Context where @@ -146,6 +160,8 @@ where } } +/// Tags a futures reader with its wrapper type. See +/// [the streams and input dispatch page](https://contextgeneric.dev/docs/projects/hypershell/architecture/streams-and-input-dispatch). #[cgp_impl(new WrapFuturesAsyncRead)] impl Handler for Context where @@ -163,6 +179,8 @@ where } } +/// Reads a Tokio reader as a futures stream of chunks. See +/// [the streams and input dispatch page](https://contextgeneric.dev/docs/projects/hypershell/architecture/streams-and-input-dispatch). #[cgp_impl(new AsyncReadToStream)] impl Handler for Context where diff --git a/crates/hypershell-tokio-components/src/providers/streaming_exec.rs b/crates/hypershell-tokio-components/src/providers/streaming_exec.rs index 373c392..4d9ca41 100644 --- a/crates/hypershell-tokio-components/src/providers/streaming_exec.rs +++ b/crates/hypershell-tokio-components/src/providers/streaming_exec.rs @@ -3,13 +3,14 @@ use core::marker::PhantomData; use cgp::extra::handler::{CanHandle, Handler, HandlerComponent}; use cgp::prelude::*; use hypershell_components::dsl::StreamingExec; -use tokio::io::{AsyncRead, Empty, copy, empty}; -use tokio::process::{Child, ChildStdout}; -use tokio::spawn; -use tokio_util::either::Either; +use tokio::io::AsyncRead; +use tokio::process::Child; use crate::dsl::CoreExec; +use crate::types::ChildOutputStream; +/// Spawns a command and returns its standard output as a stream while its input is copied in. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new HandleStreamingExec)] impl Handler, Input> for Context where @@ -17,26 +18,17 @@ where CanHandle, (), Output = Child> + CanRaiseError, Input: Send + Unpin + AsyncRead + 'static, { - type Output = Either; + type Output = ChildOutputStream; async fn handle( context: &Context, _tag: PhantomData>, - mut input: Input, - ) -> Result, Context::Error> { - let mut child = context.handle(PhantomData, ()).await?; + input: Input, + ) -> Result { + let child = context.handle(PhantomData, ()).await?; - if let Some(mut stdin) = child.stdin.take() { - spawn(async move { - let _ = copy(&mut input, &mut stdin).await; - }); - } - - let output = match child.stdout.take() { - Some(stdout) => Either::Left(stdout), - None => Either::Right(empty()), - }; - - Ok(output) + // The stream ends with an error when reading the input failed or the child exits with a + // non-success status, carrying the child's stderr. + Ok(ChildOutputStream::new(child, input)) } } diff --git a/crates/hypershell-tokio-components/src/providers/update_command.rs b/crates/hypershell-tokio-components/src/providers/update_command.rs index 93a9a71..fde924d 100644 --- a/crates/hypershell-tokio-components/src/providers/update_command.rs +++ b/crates/hypershell-tokio-components/src/providers/update_command.rs @@ -1,6 +1,8 @@ use core::marker::PhantomData; use std::ffi::OsStr; +use cgp::core::field::traits::HasField; +use cgp::core::field::types::{Cons, Nil}; use cgp::prelude::*; use hypershell_components::components::CanExtractCommandArg; use hypershell_components::dsl::{FieldArgs, WithArgs}; @@ -8,6 +10,8 @@ use tokio::process::Command; use crate::components::{CommandUpdater, CommandUpdaterComponent}; +/// Appends each argument of a `WithArgs` list to the command, in order. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). pub struct ExtractArgs; #[cgp_impl(ExtractArgs)] @@ -39,6 +43,8 @@ impl CommandUpdater> for Context { } } +/// Appends every item of the context field named `Tag` to the command. See +/// [the abstract syntax page](https://contextgeneric.dev/docs/projects/hypershell/architecture/abstract-syntax). #[cgp_impl(new ExtractFieldArgs)] impl CommandUpdater> for Context where diff --git a/crates/hypershell-tokio-components/src/types/child_output.rs b/crates/hypershell-tokio-components/src/types/child_output.rs new file mode 100644 index 0000000..f8306d4 --- /dev/null +++ b/crates/hypershell-tokio-components/src/types/child_output.rs @@ -0,0 +1,165 @@ +use core::fmt::{self, Debug, Display}; +use core::future::Future; +use core::pin::Pin; +use core::task::{Context, Poll, ready}; +use std::io::{self, ErrorKind}; +use std::process::ExitStatus; +use std::sync::{Arc, Mutex}; + +use tokio::io::{AsyncRead, AsyncReadExt, ReadBuf, copy}; +use tokio::process::{Child, ChildStdout}; +use tokio::spawn; +use tokio::task::JoinHandle; + +/// The standard output of a streamed child process, which reports the child's failure when it ends. +/// +/// Reading passes the child's stdout through, while background tasks feed the input to the child's +/// stdin and drain its stderr, so a child writing a lot to stderr cannot block. At end of file the +/// reader waits for the child to exit. An error reading the input, such as a failure the previous +/// stage reports, ends this stream with that error; otherwise a non-success exit is returned as an +/// [`io::Error`] carrying a [`ChildExitError`]. Either way the stage that reads the stream fails +/// instead of treating truncated output as complete. +pub struct ChildOutputStream { + stdout: Option, + feed: Option>, + input_error: Arc>>, + exit: Option>>, +} + +struct ChildExit { + status: ExitStatus, + stderr: Vec, +} + +/// A streamed child process that exited with a non-success status, with what it wrote to standard +/// error. +pub struct ChildExitError { + pub status: ExitStatus, + pub stderr: Vec, +} + +impl ChildOutputStream { + /// Take the child's pipes, and start the task that copies `input` to its stdin and the task that + /// drains its stderr and waits for it to exit. + pub fn new(mut child: Child, mut input: Input) -> Self + where + Input: AsyncRead + Send + Unpin + 'static, + { + let stdout = child.stdout.take(); + let mut stderr = child.stderr.take(); + let input_error = Arc::new(Mutex::new(None)); + + let feed = child.stdin.take().map(|mut stdin| { + let input_error = input_error.clone(); + spawn(async move { + match copy(&mut input, &mut stdin).await { + // A child that exits before reading all of its input closes the pipe, which is + // not a failure of the input. + Err(e) if e.kind() != ErrorKind::BrokenPipe => { + if let Ok(mut slot) = input_error.lock() { + *slot = Some(e); + } + } + _ => {} + } + // Closing stdin only after recording the error means that a child which exits + // because its input ended can never be observed before the error is. + drop(stdin); + }) + }); + + let exit = spawn(async move { + let mut stderr_bytes = Vec::new(); + if let Some(stderr) = &mut stderr { + stderr.read_to_end(&mut stderr_bytes).await?; + } + + let status = child.wait().await?; + + Ok(ChildExit { + status, + stderr: stderr_bytes, + }) + }); + + Self { + stdout, + feed, + input_error, + exit: Some(exit), + } + } +} + +impl AsyncRead for ChildOutputStream { + fn poll_read( + mut self: Pin<&mut Self>, + cx: &mut Context<'_>, + buf: &mut ReadBuf<'_>, + ) -> Poll> { + if buf.remaining() == 0 { + return Poll::Ready(Ok(())); + } + + if let Some(stdout) = &mut self.stdout { + let filled = buf.filled().len(); + ready!(Pin::new(stdout).poll_read(cx, buf))?; + + if buf.filled().len() > filled { + return Poll::Ready(Ok(())); + } + + // End of file on stdout: the input and the child's exit decide how the stream ends. + self.stdout = None; + } + + if let Some(exit) = &mut self.exit { + let result = ready!(Pin::new(exit).poll(cx)); + self.exit = None; + + let exit = result.map_err(io::Error::other)?; + + // The child has exited, so a feed still running is blocked on input nobody will read. + if let Some(feed) = self.feed.take() { + feed.abort(); + } + + // A failed input is the root cause of whatever the child did with it. + let input_error = self + .input_error + .lock() + .ok() + .and_then(|mut slot| slot.take()); + if let Some(error) = input_error { + return Poll::Ready(Err(error)); + } + + let ChildExit { status, stderr } = exit?; + + if !status.success() { + return Poll::Ready(Err(io::Error::other(ChildExitError { status, stderr }))); + } + } + + Poll::Ready(Ok(())) + } +} + +impl Display for ChildExitError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "child process exited with non-success code {:?}, stderr: {}", + self.status.code(), + String::from_utf8_lossy(&self.stderr), + ) + } +} + +impl Debug for ChildExitError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + Display::fmt(self, f) + } +} + +impl std::error::Error for ChildExitError {} diff --git a/crates/hypershell-tokio-components/src/types/mod.rs b/crates/hypershell-tokio-components/src/types/mod.rs index 276f3ed..c52c1c8 100644 --- a/crates/hypershell-tokio-components/src/types/mod.rs +++ b/crates/hypershell-tokio-components/src/types/mod.rs @@ -1,7 +1,9 @@ +mod child_output; mod futures_async_read; mod futures_stream; mod tokio_async_read; +pub use child_output::*; pub use futures_async_read::*; pub use futures_stream::*; pub use tokio_async_read::*; diff --git a/crates/hypershell-tungstenite-components/Cargo.toml b/crates/hypershell-tungstenite-components/Cargo.toml index 89bf0f7..007b786 100644 --- a/crates/hypershell-tungstenite-components/Cargo.toml +++ b/crates/hypershell-tungstenite-components/Cargo.toml @@ -1,13 +1,15 @@ [package] name = "hypershell-tungstenite-components" -version = "0.1.0" +version = "0.2.0-prerelease" edition = { workspace = true } license = { workspace = true } repository = { workspace = true } +homepage = { workspace = true } +categories = { workspace = true } authors = { workspace = true } rust-version = { workspace = true } keywords = { workspace = true } -description = "Modular DSL for shellscripting in Rust" +description = "Native WebSocket handlers for Hypershell, built on tokio-tungstenite." [dependencies] hypershell-components = { workspace = true } diff --git a/crates/hypershell-tungstenite-components/LICENSE b/crates/hypershell-tungstenite-components/LICENSE new file mode 120000 index 0000000..30cff74 --- /dev/null +++ b/crates/hypershell-tungstenite-components/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/crates/hypershell-tungstenite-components/README.md b/crates/hypershell-tungstenite-components/README.md new file mode 100644 index 0000000..23de14d --- /dev/null +++ b/crates/hypershell-tungstenite-components/README.md @@ -0,0 +1,19 @@ +[![Crates.io](https://img.shields.io/crates/v/hypershell-tungstenite-components.svg)](https://crates.io/crates/hypershell-tungstenite-components) +[![Docs.rs](https://docs.rs/hypershell-tungstenite-components/badge.svg)](https://docs.rs/hypershell-tungstenite-components) + +# hypershell-tungstenite-components: WebSockets as a Hypershell extension + +`hypershell-tungstenite-components` interprets the `WebSocket` syntax of +[Hypershell](https://docs.rs/hypershell), a small language for shell-script-like programs in Rust +built with [Context-Generic Programming (CGP)](https://contextgeneric.dev/), on +[`tokio-tungstenite`](https://docs.rs/tokio-tungstenite). `HandleWebsocket` connects to the URL a +program names, sends the stage's input to the server as binary messages, and passes the replies on +to the next stage as a stream, each text message ending in a newline. The +`HypershellTungsteniteProvider` bundle collects its wiring. + +**[hypershell](https://docs.rs/hypershell) · [Project page](https://contextgeneric.dev/docs/projects/hypershell/) · [Repository](https://github.com/contextgeneric/hypershell)** + +`HypershellNamespace` does not route `WebSocket`, so a program that uses it runs on a context that +wires the bundle. The repository's +[`bluesky_websocket`](https://contextgeneric.dev/docs/projects/hypershell/examples/bluesky-websocket) +example wires it onto a single context. diff --git a/crates/hypershell-tungstenite-components/src/lib.rs b/crates/hypershell-tungstenite-components/src/lib.rs index 95fa82c..ddfc2ea 100644 --- a/crates/hypershell-tungstenite-components/src/lib.rs +++ b/crates/hypershell-tungstenite-components/src/lib.rs @@ -1,2 +1,2 @@ -pub mod presets; +#![doc = include_str!("../README.md")] pub mod providers; diff --git a/crates/hypershell-tungstenite-components/src/presets.rs b/crates/hypershell-tungstenite-components/src/presets.rs deleted file mode 100644 index 10f78ed..0000000 --- a/crates/hypershell-tungstenite-components/src/presets.rs +++ /dev/null @@ -1,44 +0,0 @@ -#[cgp::re_export_imports] -mod preset { - use std::vec::Vec; - - use cgp::extra::handler::{PipeHandlers, UseInputDelegate}; - use cgp::prelude::*; - use hypershell_components::dsl::{BytesToStream, WebSocket}; - use hypershell_components::providers::Call; - use hypershell_tokio_components::providers::{FuturesToTokioAsyncRead, WrapFuturesAsyncRead}; - use hypershell_tokio_components::types::{FuturesAsyncReadStream, TokioAsyncReadStream}; - - use crate::providers::HandleWebsocket; - - cgp_preset! { - #[wrap_provider(UseDelegate)] - TungsteniteHandlerPreset { - WebSocket: - WebSocketHandlers::Provider, - } - } - - cgp_preset! { - #[wrap_provider(UseInputDelegate)] - WebSocketHandlers { - FuturesAsyncReadStream: - PipeHandlers, - TokioAsyncReadStream: - PipeHandlers, - Vec: - PipeHandlers, - HandleWebsocket, - WrapFuturesAsyncRead, - ]>, - } - } -} diff --git a/crates/hypershell-tungstenite-components/src/providers/combined.rs b/crates/hypershell-tungstenite-components/src/providers/combined.rs new file mode 100644 index 0000000..6bd2664 --- /dev/null +++ b/crates/hypershell-tungstenite-components/src/providers/combined.rs @@ -0,0 +1,40 @@ +use cgp::extra::handler::{HandlerComponent, PipeHandlers}; +use cgp::prelude::*; +use hypershell_components::dsl::{BytesToStream, WebSocket}; +use hypershell_components::providers::Call; +use hypershell_tokio_components::providers::{FuturesToTokioAsyncRead, WrapFuturesAsyncRead}; +use hypershell_tokio_components::types::{FuturesAsyncReadStream, TokioAsyncReadStream}; + +use crate::providers::HandleWebsocket; + +delegate_components! { + new HypershellTungsteniteProvider { + open {HandlerComponent}; + + @HandlerComponent + . WebSocket + . FuturesAsyncReadStream: + PipeHandlers, + + @HandlerComponent + . WebSocket + . TokioAsyncReadStream: + PipeHandlers, + + @HandlerComponent + . WebSocket + .Vec: + PipeHandlers, + HandleWebsocket, + WrapFuturesAsyncRead, + ]>, + } +} diff --git a/crates/hypershell-tungstenite-components/src/providers/mod.rs b/crates/hypershell-tungstenite-components/src/providers/mod.rs index 187b841..52d6026 100644 --- a/crates/hypershell-tungstenite-components/src/providers/mod.rs +++ b/crates/hypershell-tungstenite-components/src/providers/mod.rs @@ -1,3 +1,5 @@ +mod combined; mod websocket; +pub use combined::*; pub use websocket::*; diff --git a/crates/hypershell-tungstenite-components/src/providers/websocket.rs b/crates/hypershell-tungstenite-components/src/providers/websocket.rs index b0b0f96..e669bca 100644 --- a/crates/hypershell-tungstenite-components/src/providers/websocket.rs +++ b/crates/hypershell-tungstenite-components/src/providers/websocket.rs @@ -14,6 +14,8 @@ use tokio_tungstenite::{connect_async, tungstenite}; use tokio_util::bytes::Bytes; use tokio_util::io::ReaderStream; +/// Connects to a WebSocket server, sends its input as binary messages, and returns the replies. See +/// [the WebSocket example](https://contextgeneric.dev/docs/projects/hypershell/examples/bluesky-websocket). #[cgp_impl(new HandleWebsocket)] impl Handler, Input> for Context where @@ -34,7 +36,7 @@ where .into_client_request() .map_err(Context::raise_error)?; - let (websocket, _) = connect_async(url).await.unwrap(); + let (websocket, _) = connect_async(url).await.map_err(Context::raise_error)?; let (writer, reader) = websocket.split(); spawn(async move { diff --git a/crates/hypershell/Cargo.toml b/crates/hypershell/Cargo.toml index 0c75c21..f69c4a9 100644 --- a/crates/hypershell/Cargo.toml +++ b/crates/hypershell/Cargo.toml @@ -1,13 +1,15 @@ [package] name = "hypershell" -version = "0.1.0" +version = "0.2.0-prerelease" edition = { workspace = true } license = { workspace = true } repository = { workspace = true } +homepage = { workspace = true } +categories = { workspace = true } authors = { workspace = true } rust-version = { workspace = true } keywords = { workspace = true } -description = "Modular DSL for shellscripting in Rust" +description = "A modular, type-level DSL for shell-script-like programs in Rust." [dependencies] hypershell-components = { workspace = true } @@ -21,3 +23,6 @@ cgp-error-anyhow = { workspace = true } reqwest = { workspace = true } serde_json = { workspace = true } url = { workspace = true } + +[dev-dependencies] +tokio = { workspace = true, features = [ "macros", "rt-multi-thread" ] } diff --git a/crates/hypershell/LICENSE b/crates/hypershell/LICENSE new file mode 120000 index 0000000..30cff74 --- /dev/null +++ b/crates/hypershell/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/crates/hypershell/README.md b/crates/hypershell/README.md new file mode 100644 index 0000000..55f1208 --- /dev/null +++ b/crates/hypershell/README.md @@ -0,0 +1,60 @@ +[![Crates.io](https://img.shields.io/crates/v/hypershell.svg)](https://crates.io/crates/hypershell) +[![Docs.rs](https://docs.rs/hypershell/badge.svg)](https://docs.rs/hypershell) + +# Hypershell: shell-script-like programs as Rust types + +Hypershell is a small language for writing shell-script-like programs in Rust, built with +[Context-Generic Programming (CGP)](https://contextgeneric.dev/), a language extension for Rust with +pluggable trait implementations at compile-time. A program is a Rust type, and the context that runs +it is its interpreter, so both the language's syntax and its meaning can be extended without editing +its crates. Hypershell is an experimental proof of concept, not a replacement for a shell. + +**[Project page](https://contextgeneric.dev/docs/projects/hypershell/) · [Examples](https://contextgeneric.dev/docs/projects/hypershell/examples/) · [Repository](https://github.com/contextgeneric/hypershell)** + +This crate is the one a program depends on, beside `cgp` and an async runtime. This program runs +`echo hello world!` and prints the output: + +```rust +use hypershell::prelude::*; + +pub type Program = hypershell! { + SimpleExec< + StaticArg<"echo">, + WithStaticArgs["hello", "world!"], + > + | StreamToStdout +}; + +#[tokio::main] +async fn main() -> Result<(), Error> { + HypershellCli + .handle(PhantomData::, Vec::new()) + .await?; + + Ok(()) +} +``` + +`Program` is a type alias, and `HypershellCli` is a context whose whole wiring is one line that +joins `HypershellNamespace`. The namespace routes each piece of syntax to the provider that +interprets it, and the compiler resolves those choices while it type-checks the program. + +## What the crate holds + +- **`prelude`:** what a program file imports: `cgp::prelude`, `PhantomData`, the handler traits and + keys, the anyhow `Error`, every syntax type of + [`hypershell-components`](https://docs.rs/hypershell-components), the `hypershell!` macro, and the + two contexts. +- **`contexts`:** `HypershellCli`, a context with no fields for programs that run commands and + handle files and streams, and `HypershellHttp`, whose `http_client` field supplies the client that + HTTP requests use. +- **`namespaces`:** `HypershellNamespace`, which assembles the language from the backend crates and + which a context of your own joins. +- **`providers`:** `HypershellErrorHandler`, the error wiring that raises each library's errors into + the context's `anyhow::Error`. + +The `hypershell!` macro expects the prelude in scope, and its expansion names the `cgp` crate, so a +program's crate depends on `cgp` as well. The library and small programs such as this one build on +stable Rust, and programs that nest others deeply can need nightly with the next-generation trait +solver, as the [repository README](https://github.com/contextgeneric/hypershell#installation) +describes. diff --git a/crates/hypershell/src/contexts/cli.rs b/crates/hypershell/src/contexts/cli.rs index f4f33f7..3367bca 100644 --- a/crates/hypershell/src/contexts/cli.rs +++ b/crates/hypershell/src/contexts/cli.rs @@ -1,6 +1,11 @@ use cgp::prelude::*; -use crate::presets::HypershellPreset; +use crate::namespaces::HypershellNamespace; -#[cgp_inherit(HypershellPreset)] pub struct HypershellCli; + +delegate_components! { + HypershellCli { + namespace HypershellNamespace; + } +} diff --git a/crates/hypershell/src/contexts/http.rs b/crates/hypershell/src/contexts/http.rs index 6ac5404..f0a3bbb 100644 --- a/crates/hypershell/src/contexts/http.rs +++ b/crates/hypershell/src/contexts/http.rs @@ -1,10 +1,15 @@ use cgp::prelude::*; use reqwest::Client; -use crate::presets::HypershellPreset; +use crate::namespaces::HypershellNamespace; -#[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct HypershellHttp { pub http_client: Client, } + +delegate_components! { + HypershellHttp { + namespace HypershellNamespace; + } +} diff --git a/crates/hypershell/src/lib.rs b/crates/hypershell/src/lib.rs index f6afd29..3a95bd0 100644 --- a/crates/hypershell/src/lib.rs +++ b/crates/hypershell/src/lib.rs @@ -1,3 +1,5 @@ +#![doc = include_str!("../README.md")] pub mod contexts; +pub mod namespaces; pub mod prelude; -pub mod presets; +pub mod providers; diff --git a/crates/hypershell/src/namespaces/handlers.rs b/crates/hypershell/src/namespaces/handlers.rs new file mode 100644 index 0000000..ebb915b --- /dev/null +++ b/crates/hypershell/src/namespaces/handlers.rs @@ -0,0 +1,150 @@ +use core::convert::Infallible; +use core::str::Utf8Error; + +use cgp::core::error::{ErrorRaiserComponent, ErrorTypeProviderComponent, ErrorWrapperComponent}; +use cgp::core::field::impls::UseField; +use cgp::extra::handler::HandlerComponent; +use cgp::prelude::*; +use cgp_error_anyhow::{DebugAnyhowError, Error, UseAnyhowError}; +use hypershell_components::components::{ + CommandArgExtractorComponent, CommandArgTypeProviderComponent, HttpMethodTypeProviderComponent, + MethodArgExtractorComponent, StringArgExtractorComponent, UrlArgExtractorComponent, + UrlTypeProviderComponent, +}; +use hypershell_components::dsl::{ + BytesToStream, BytesToString, ConvertTo, DecodeJson, DeleteMethod, EncodeJson, FieldArg, + FieldArgs, GetMethod, Header, JoinArgs, Pipe, PostMethod, PutMethod, ReadFile, SimpleExec, + SimpleHttpRequest, StaticArg, StreamToBytes, StreamToStdout, StreamToString, StreamingExec, + StreamingHttpRequest, UrlEncodeArg, Use, WithArgs, WithHeaders, WriteFile, +}; +use hypershell_components::providers::HypershellBaseProvider; +use hypershell_json_components::providers::HypershellJsonProvider; +use hypershell_reqwest_components::components::{ + RequestBuilderUpdaterComponent, ReqwestClientGetterComponent, +}; +use hypershell_reqwest_components::dsl::CoreHttpRequest; +use hypershell_reqwest_components::providers::{ErrorResponse, HypershellReqwestProvider}; +use hypershell_tokio_components::components::CommandUpdaterComponent; +use hypershell_tokio_components::dsl::{CoreExec, ToTokioAsyncRead}; +use hypershell_tokio_components::providers::{ExecOutputError, HypershellTokioProvider}; +use reqwest::header::{InvalidHeaderName, InvalidHeaderValue}; +use url::ParseError; + +use crate::providers::HypershellErrorHandler; + +cgp_namespace! { + new HypershellNamespace: DefaultNamespace { + @cgp.core.error.ErrorTypeProviderComponent: + UseAnyhowError, + + @cgp.core.error.ErrorRaiserComponent.[ + Error, + Infallible, + std::io::Error, + Utf8Error, + reqwest::Error, + ParseError, + InvalidHeaderName, + InvalidHeaderValue, + serde_json::Error, + ExecOutputError, + ErrorResponse, + ]: + HypershellErrorHandler, + + @cgp.core.error.ErrorWrapperComponent: + DebugAnyhowError, + + @hypershell.core.CommandArgTypeProviderComponent: + HypershellTokioProvider, + + @hypershell.reqwest.ReqwestClientGetterComponent: + UseField, + + @cgp.extra.handler.HandlerComponent.[ + BytesToString, + ConvertTo, + Pipe, + Use, + Box, + ]: + HypershellBaseProvider, + + @cgp.extra.handler.HandlerComponent.[ + SimpleExec, + StreamingExec, + CoreExec, + ReadFile, + WriteFile, + StreamToBytes, + StreamToString, + BytesToStream, + StreamToStdout, + ToTokioAsyncRead, + ]: + HypershellTokioProvider, + + @cgp.extra.handler.HandlerComponent.[ + SimpleHttpRequest, + StreamingHttpRequest, + CoreHttpRequest, + ]: + HypershellReqwestProvider, + + @cgp.extra.handler.HandlerComponent.[ + EncodeJson, + DecodeJson, + ]: + HypershellJsonProvider, + + @hypershell.core.{ + StringArgExtractorComponent.[ + StaticArg, + FieldArg, + JoinArgs, + ], + CommandArgExtractorComponent.[ + StaticArg, + FieldArg, + ], + UrlArgExtractorComponent.[ + StaticArg, + JoinArgs, + FieldArg, + ], + }: + HypershellBaseProvider, + + @hypershell.{ + core.CommandArgExtractorComponent.[ + JoinArgs, + ], + tokio.CommandUpdaterComponent.[ + WithArgs, + FieldArgs, + ], + }: + HypershellTokioProvider, + + @hypershell.{ + core.{ + HttpMethodTypeProviderComponent, + UrlTypeProviderComponent, + StringArgExtractorComponent.[ + UrlEncodeArg, + ], + MethodArgExtractorComponent.[ + GetMethod, + PostMethod, + PutMethod, + DeleteMethod, + ], + }, + reqwest.RequestBuilderUpdaterComponent.[ + WithHeaders, + Header, + ], + }: + HypershellReqwestProvider, + } +} diff --git a/crates/hypershell/src/namespaces/mod.rs b/crates/hypershell/src/namespaces/mod.rs new file mode 100644 index 0000000..2ed7b74 --- /dev/null +++ b/crates/hypershell/src/namespaces/mod.rs @@ -0,0 +1,3 @@ +mod handlers; + +pub use handlers::*; diff --git a/crates/hypershell/src/prelude.rs b/crates/hypershell/src/prelude.rs index 3cda5ea..af13fdc 100644 --- a/crates/hypershell/src/prelude.rs +++ b/crates/hypershell/src/prelude.rs @@ -1,10 +1,13 @@ pub use core::marker::PhantomData; -pub use cgp::extra::handler::CanHandle; +pub use cgp::extra::handler::{ + AsyncComputer, AsyncComputerComponent, CanHandle, Computer, ComputerComponent, + ComputerRefComponent, Handler, HandlerComponent, Producer, ProducerComponent, TryComputer, + TryComputerComponent, +}; pub use cgp::prelude::*; pub use cgp_error_anyhow::Error; pub use hypershell_components::dsl::*; pub use hypershell_macro::hypershell; pub use crate::contexts::{HypershellCli, HypershellHttp}; -pub use crate::presets::HypershellPreset; diff --git a/crates/hypershell/src/presets.rs b/crates/hypershell/src/presets.rs deleted file mode 100644 index d23d592..0000000 --- a/crates/hypershell/src/presets.rs +++ /dev/null @@ -1,93 +0,0 @@ -#[cgp::re_export_imports] -mod preset { - use core::convert::Infallible; - use core::str::Utf8Error; - use std::io::Error as StdIoError; - - use cgp::core::component::UseDelegate; - use cgp::core::error::{ - ErrorRaiserComponent, ErrorTypeProviderComponent, ErrorWrapperComponent, - }; - use cgp::extra::error::{RaiseInfallible, ReturnError}; - use cgp::prelude::*; - use cgp_error_anyhow::{DebugAnyhowError, Error, RaiseAnyhowError, UseAnyhowError}; - use hypershell_components::presets::{ - BaseHandlerPreset, BaseStringArgExtractorPreset, HypershellBasePreset, - }; - use hypershell_json_components::presets::{HypershellJsonPreset, JsonHandlerPreset}; - use hypershell_reqwest_components::components::ReqwestClientGetterComponent; - use hypershell_reqwest_components::presets::{ - HypershellReqwestPreset, ReqwestHandlerPreset, ReqwestStringArgExtractorPreset, - }; - use hypershell_reqwest_components::providers::ErrorResponse; - use hypershell_tokio_components::presets::{HypershellTokioPreset, TokioHandlerPreset}; - use hypershell_tokio_components::providers::ExecOutputError; - use reqwest::Error as ReqwestError; - use reqwest::header::{InvalidHeaderName, InvalidHeaderValue}; - use serde_json::Error as JsonError; - use url::ParseError; - - cgp_preset! { - HypershellPreset: - HypershellBasePreset - + HypershellTokioPreset - + HypershellReqwestPreset - + HypershellJsonPreset - { - ErrorTypeProviderComponent: - UseAnyhowError, - ErrorRaiserComponent: - HypershellErrorHandlers::Provider, - ErrorWrapperComponent: - DebugAnyhowError, - ReqwestClientGetterComponent: - UseField, - override StringArgExtractorComponent: - HypershellStringArgExtractorPreset::Provider, - override HandlerComponent: - HypershellHandlerPreset::Provider, - } - } - - cgp_preset! { - #[wrap_provider(UseDelegate)] - HypershellErrorHandlers { - Error: ReturnError, - Infallible: RaiseInfallible, - [ - StdIoError, - Utf8Error, - ReqwestError, - ParseError, - InvalidHeaderName, - InvalidHeaderValue, - JsonError, - ]: - RaiseAnyhowError, - [ - ExecOutputError, - ErrorResponse, - ]: - DebugAnyhowError, - } - } - - cgp_preset! { - #[wrap_provider(UseDelegate)] - HypershellHandlerPreset: - BaseHandlerPreset - + TokioHandlerPreset - + ReqwestHandlerPreset - + JsonHandlerPreset - { - } - } - - cgp_preset! { - #[wrap_provider(UseDelegate)] - HypershellStringArgExtractorPreset: - BaseStringArgExtractorPreset - + ReqwestStringArgExtractorPreset - { } - } -} diff --git a/crates/hypershell/src/providers/error.rs b/crates/hypershell/src/providers/error.rs new file mode 100644 index 0000000..e41ef37 --- /dev/null +++ b/crates/hypershell/src/providers/error.rs @@ -0,0 +1,38 @@ +use core::convert::Infallible; +use core::str::Utf8Error; + +use cgp::core::error::ErrorRaiserComponent; +use cgp::extra::error::{RaiseInfallible, ReturnError}; +use cgp::prelude::delegate_components; +use cgp_error_anyhow::{DebugAnyhowError, Error, RaiseAnyhowError}; +use hypershell_reqwest_components::providers::ErrorResponse; +use hypershell_tokio_components::providers::ExecOutputError; +use reqwest::header::{InvalidHeaderName, InvalidHeaderValue}; +use url::ParseError; + +delegate_components! { + new HypershellErrorHandler { + open {ErrorRaiserComponent}; + + @ErrorRaiserComponent.Error: ReturnError, + + @ErrorRaiserComponent.Infallible: RaiseInfallible, + + @ErrorRaiserComponent.[ + std::io::Error, + Utf8Error, + reqwest::Error, + ParseError, + InvalidHeaderName, + InvalidHeaderValue, + serde_json::Error, + ]: + RaiseAnyhowError, + + @ErrorRaiserComponent.[ + ExecOutputError, + ErrorResponse, + ]: + DebugAnyhowError, + } +} diff --git a/crates/hypershell/src/providers/mod.rs b/crates/hypershell/src/providers/mod.rs new file mode 100644 index 0000000..3925f93 --- /dev/null +++ b/crates/hypershell/src/providers/mod.rs @@ -0,0 +1,3 @@ +mod error; + +pub use error::*; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 71223b6..d5f8e82 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,5 @@ +# Pinned to a dated nightly because `.cargo/config.toml` turns on the next-generation +# trait solver with `-Z next-solver=globally`, which only a nightly accepts. Bump this +# deliberately, and run the suite afterwards. [toolchain] -channel = "1.93.1" -profile = "default" +channel = "nightly-2026-11-16"