From 8dde8d0aeded715666dab875f0fd496b13d89c00 Mon Sep 17 00:00:00 2001 From: Nikolay Arhipov Date: Sat, 7 Oct 2023 21:53:41 +0300 Subject: [PATCH] Initial --- .github/workflows/release.yml | 56 + .gitignore | 7 + .vscode/settings.json | 3 + Cargo.lock | 1327 +++++++++++++++++++++++ Cargo.toml | 17 + LICENSE-APACHE | 176 +++ LICENSE-MIT | 19 + README.md | 63 ++ crates/0-std-tests/Cargo.toml | 19 + crates/0-std-tests/src/lib.rs | 6 + crates/0-std-tests/src/tests_fs.rs | 86 ++ crates/0-std-tests/src/tests_pthread.rs | 159 +++ crates/0-std-tests/src/tests_tcp.rs | 115 ++ crates/0-std-tests/src/tests_unwind.rs | 16 + crates/1-cross-isa/Cargo.toml | 14 + crates/1-cross-isa/src/main.rs | 15 + crates/2-http-client/Cargo.toml | 30 + crates/2-http-client/src/main.rs | 39 + rust-toolchain.toml | 2 + 19 files changed, 2169 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .gitignore create mode 100644 .vscode/settings.json create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 LICENSE-APACHE create mode 100644 LICENSE-MIT create mode 100644 README.md create mode 100644 crates/0-std-tests/Cargo.toml create mode 100644 crates/0-std-tests/src/lib.rs create mode 100644 crates/0-std-tests/src/tests_fs.rs create mode 100644 crates/0-std-tests/src/tests_pthread.rs create mode 100644 crates/0-std-tests/src/tests_tcp.rs create mode 100644 crates/0-std-tests/src/tests_unwind.rs create mode 100644 crates/1-cross-isa/Cargo.toml create mode 100644 crates/1-cross-isa/src/main.rs create mode 100644 crates/2-http-client/Cargo.toml create mode 100644 crates/2-http-client/src/main.rs create mode 100644 rust-toolchain.toml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..00812e7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +name: Build examples + +on: + push: + branches: + - main + +concurrency: + group: ${{ github.head_ref || github.ref_name }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + container: + image: ghcr.io/vita-rust/vitasdk-rs + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Build + run: | + cargo vita build vpk --release --package vita-std-tests --tests + cargo vita build vpk --release + mv target/armv7-sony-vita-newlibeabihf/release/deps/*.vpk target/armv7-sony-vita-newlibeabihf/release/ + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: examples + path: target/armv7-sony-vita-newlibeabihf/release/*.vpk + release: + needs: build + runs-on: ubuntu-latest + + steps: + - name: Download Artifacts + uses: actions/download-artifact@v2 + with: + name: examples + - name: Delete old release assets + uses: mknejp/delete-release-assets@v1 + with: + token: ${{ github.token }} + tag: latest + assets: '*' + fail-if-no-release: false + fail-if-no-assets: false + - name: Release + uses: softprops/action-gh-release@v1 + with: + name: Latest + body: > + This release is automatically updated by a Github Action on every push to the main branch. + tag_name: latest + generate_release_notes: false + files: | + *.vpk diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..23d0cf9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.vscode/* +!.vscode/settings.json + +target/ +.DS_Store +.tmp +.envrc \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..64cb31d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "rust-analyzer.cargo.target": "armv7-sony-vita-newlibeabihf" +} diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..fd60e0a --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1327 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "anyhow" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "encoding_rs" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "errno" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "add4f07d43996f76ef320709726a556a9d4f965d9410d8d0271132d2f8293480" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fastrand" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + +[[package]] +name = "flate2" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" + +[[package]] +name = "futures-macro" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" + +[[package]] +name = "futures-task" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" + +[[package]] +name = "futures-util" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +dependencies = [ + "futures-core", + "futures-macro", + "futures-task", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" + +[[package]] +name = "h2" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "http" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2 0.4.9", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +dependencies = [ + "futures-util", + "http", + "hyper", + "rustls", + "tokio", + "tokio-rustls", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "ipnet" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" + +[[package]] +name = "itoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" + +[[package]] +name = "js-sys" +version = "0.3.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" + +[[package]] +name = "linux-raw-sys" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3852614a3bd9ca9804678ba6be5e3b8ce76dfc902cae004e3e0c44051b6e88db" + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.8" +source = "git+https://github.com/vita-rust/mio?branch=vita#df7a1c3cbfd9aa952fa619f61d806603a2be9e8f" +dependencies = [ + "libc", + "wasi", + "windows-sys", +] + +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "object" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "openssl" +version = "0.10.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" +dependencies = [ + "bitflags 2.4.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "oxhttp" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64f8f4b616372a7e657a05100d1389325fc2f7d3fee5c9de05166d979cb2b729" +dependencies = [ + "httparse", + "lazy_static", + "rustls", + "rustls-native-certs", + "url", +] + +[[package]] +name = "percent-encoding" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro2" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b1106fec09662ec6dd98ccac0f81cef56984d0b49f75c92d8cbad76e20c005c" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "reqwest" +version = "0.11.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-rustls", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "system-configuration", + "tokio", + "tokio-native-tls", + "tokio-rustls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots", + "winreg", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "git+https://github.com/vita-rust/ring?branch=v0.16.20-vita#c2201b2280108b884eb14308b59d08c7f55a9933" +dependencies = [ + "cc", + "getrandom", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustix" +version = "0.38.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f25469e9ae0f3d0047ca8b93fc56843f38e6774f0914a107ff8b41be8be8e0b7" +dependencies = [ + "bitflags 2.4.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rustls" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-native-certs" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +dependencies = [ + "base64", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "ryu" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" + +[[package]] +name = "schannel" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "security-framework" +version = "2.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.188" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.188" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "socket2" +version = "0.4.9" +source = "git+https://github.com/vita-rust/socket2?branch=v0.4.9-vita#12c617dca2bd0017f2831afd5c6fc89459c76ed7" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "socket2" +version = "0.5.4" +source = "git+https://github.com/vita-rust/socket2?branch=v0.5.3-vita#187fe7d56f684b36efd2c939e300df50143270c5" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "syn" +version = "2.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +dependencies = [ + "cfg-if", + "fastrand", + "redox_syscall", + "rustix", + "windows-sys", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.32.0" +source = "git+https://github.com/vita-rust/tokio?branch=vita#79e084494b200d354b3352ff795c048efec65f44" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2 0.5.4", + "tokio-macros", + "windows-sys", +] + +[[package]] +name = "tokio-macros" +version = "2.1.0" +source = "git+https://github.com/vita-rust/tokio?branch=vita#79e084494b200d354b3352ff795c048efec65f44" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "ureq" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5ccd538d4a604753ebc2f17cd9946e89b77bf87f6a8e2309667c6f2e87855e3" +dependencies = [ + "base64", + "flate2", + "log", + "once_cell", + "url", +] + +[[package]] +name = "url" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "vita-example-cross-isa" +version = "0.1.0" + +[[package]] +name = "vita-example-http" +version = "0.1.0" +dependencies = [ + "anyhow", + "libc", + "oxhttp", + "reqwest", + "tokio", + "ureq", + "vita-newlib-shims", +] + +[[package]] +name = "vita-newlib-shims" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82410d11383c2cb16bf587fadcfec7a79229271264ee8093ede6186a7e0b1d59" +dependencies = [ + "libc", +] + +[[package]] +name = "vita-std-tests" +version = "0.1.0" +dependencies = [ + "anyhow", + "libc", + "rand", + "serde", + "serde_json", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" + +[[package]] +name = "web-sys" +version = "0.3.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..5df8928 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,17 @@ +[workspace] +members = ["./crates/*"] +resolver = "2" + +[profile.release] +panic = 'unwind' +lto = true +opt-level = 2 + +[patch.crates-io] +mio = { git = "https://github.com/vita-rust/mio", branch = "vita" } +tokio = { git = "https://github.com/vita-rust/tokio", branch = "vita" } +socket2053 = { git = "https://github.com/vita-rust/socket2", branch = "v0.5.3-vita", package = "socket2", version = "0.5.3" } +socket2049 = { git = "https://github.com/vita-rust/socket2", branch = "v0.4.9-vita", package = "socket2", version = "0.4.9" } + +# Required for rustls +ring = { git = "https://github.com/vita-rust/ring", branch = "v0.16.20-vita" } diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 0000000..a7e77cb --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..9cf1062 --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,19 @@ +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..4519c15 --- /dev/null +++ b/README.md @@ -0,0 +1,63 @@ +# Examples + +[![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](https://github.com/vita-rust/examples) +[![GitHub Actions Build Status](https://img.shields.io/github/actions/workflow/status/vita-rust/examples/release.yml)](https://github.com/vita-rust/examples/actions/workflows/release.yml) +[![Current Release](https://img.shields.io/github/release/vita-rust/examples.svg)](https://github.com/vita-rust/examples/releases) +[![Main Commits RSS Feed](https://img.shields.io/badge/rss-commits-ffa500?logo=rss)](https://github.com/vita-rust/examples/commits/main.atom) + +This repository holds examples in Rust that can be compiled as `vpk` for Sony Playstation Vita + +## Prerequisites + +- [Vita SDK](https://vitasdk.org/) must be installed, and `VITASDK` environment variable must be set to its location. You can add the environment variable to your `.bashrc` (or another configuration file if you are using a different shell), or you can use a tool like [direnv](https://direnv.net/), and put this in a `.envrc`. +- [cargo-vita](https://github.com/vita-rust/cargo-vita) tool is required for building `vpk`` files. Run this command to install it: + ```sh + cargo install cargo-vita + ``` +- [PrincessLog](https://github.com/CelesteBlue-dev/PSVita-RE-tools/tree/master/PrincessLog/build) is required for monitoring stdout/stderr from your Vita. +- [vitacompanion](https://github.com/devnoname120/vitacompanion) is required for uploading `eboot.bin`/`vpk` files to Vita, and running commands. + + +## Building + +To build the `vpk` for every example run: + +```sh +cargo vita build vpk --release +``` + +To build the `vpk` for `std-tests` run: + +```sh +cargo vita build vpk --release --package vita-std-tests --tests +``` + +To build the `vpk` for any specific package: + +```sh +cargo vita build vpk --release --package {PACKAGE} +``` + + +## Running + +You can automate uploading of `vpk` to `ux0:/download/`, or update `eboot.bin` for already installed `vpk`. + +To upload all `vpk` artifacts, use `--upload` flag of `vpk` subcommand: + +```sh +cargo vita build vpk --upload --release +``` + +To update a specific `eboot.bin` and run it use `--update --run` flags of `eboot` subcommand. Keep in mind that `vpk` must be installed in order for that to work: + +```sh +cargo vita build eboot --update --run --release --package {PACKAGE} +``` + +## License + +Except where noted (below and/or in individual files), all code in this repository is dual-licensed at your option under either: + +* MIT License ([LICENSE-MIT](LICENSE-MIT) or [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT)) +* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)) diff --git a/crates/0-std-tests/Cargo.toml b/crates/0-std-tests/Cargo.toml new file mode 100644 index 0000000..f25b635 --- /dev/null +++ b/crates/0-std-tests/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "vita-std-tests" +version = "0.1.0" +edition = "2021" + +license = "MIT OR Apache-2.0" +repository = "https://github.com/vita-rust/examples" +homepage = "https://github.com/vita-rust/examples/crates/0-std-tests" + +[dependencies] +anyhow = "1.0.71" +libc = "0.2.149" +serde = { version = "1.0.160", features = ["derive"] } +serde_json = "1.0.96" +rand = "0.8.5" + +[package.metadata.vita] +title_id = "RUSTTESTS" +title_name = "Rust std tests" diff --git a/crates/0-std-tests/src/lib.rs b/crates/0-std-tests/src/lib.rs new file mode 100644 index 0000000..dc3b9e2 --- /dev/null +++ b/crates/0-std-tests/src/lib.rs @@ -0,0 +1,6 @@ +#![feature(fs_try_exists)] + +mod tests_fs; +mod tests_pthread; +mod tests_tcp; +mod tests_unwind; diff --git a/crates/0-std-tests/src/tests_fs.rs b/crates/0-std-tests/src/tests_fs.rs new file mode 100644 index 0000000..3c058d3 --- /dev/null +++ b/crates/0-std-tests/src/tests_fs.rs @@ -0,0 +1,86 @@ +#[cfg(test)] +mod tests { + use std::fs; + + struct FsScope; + + impl Drop for FsScope { + fn drop(&mut self) { + if fs::try_exists("ux0:/data/.rust_test").unwrap_or(false) { + fs::remove_dir_all("ux0:/data/.rust_test").expect("unable to cleanup"); + } + } + } + + #[test] + pub fn test_fs_read_dir() { + let _ = FsScope; + + let mut data_found = false; + + for file in fs::read_dir("ux0:/").expect("read_dir ux0 failed") { + let file = file.expect("unable to get dir entry of file"); + + if file.file_name().to_str() == Some("data") { + data_found = true; + let meta = file.metadata().expect("unable to stat ux0:/data"); + assert!(meta.is_dir(), "ux:0/data is not a directory"); + assert!(!meta.is_file(), "ux:0/data is a file"); + assert!(!meta.is_symlink(), "ux:0/data is a symlink"); + assert!(meta.created().is_ok(), "created time is error"); + assert!(meta.modified().is_ok(), "modified time is error"); + assert!(meta.accessed().is_ok(), "access time is error"); + break; + } + } + + assert!(data_found, "ux0:/data not found"); + } + + #[test] + pub fn test_fs_creation() { + let _ = FsScope; + + fs::create_dir("ux0:/data/.rust_test").expect("unable to create ux0:/data/.rust_test"); + let meta = + fs::metadata("ux0:/data/.rust_test").expect("ux0:/data/.rust_test does not exist"); + assert!(meta.is_dir(), "ux0:/data/.rust_test is not a directory"); + + fs::write("ux0:/data/.rust_test/file", "contents").expect("unable to create a test file"); + let data = fs::read("ux0:/data/.rust_test/file").expect("unable to read file"); + assert!(&data == "contents".as_bytes(), "invalid file contents"); + + let data = fs::read_to_string("ux0:/data/.rust_test/file").expect("unable to read file"); + assert!(&data == "contents", "invalid file contents"); + + assert!( + fs::try_exists("ux0:/data/.rust_test/file").unwrap(), + "file does not exist", + ); + + fs::copy( + "ux0:/data/.rust_test/file", + "ux0:/data/.rust_test/file_copy", + ) + .expect("unable to copy file to file_copy"); + let data = + fs::read_to_string("ux0:/data/.rust_test/file_copy").expect("unable to read file_copy"); + assert!(&data == "contents", "invalid file_copy contents"); + + fs::remove_file("ux0:/data/.rust_test/file").expect("unable to delete file"); + assert!( + !fs::try_exists("ux0:/data/.rust_test/file").unwrap(), + "file exists, but should not", + ); + + assert!( + fs::remove_dir("ux0:/data/.rust_test").is_err(), + "remove_dir should fail, because directory is not empty", + ); + + assert!( + fs::remove_dir_all("ux0:/data/.rust_test").is_ok(), + "remove_dir_all should succeed", + ); + } +} diff --git a/crates/0-std-tests/src/tests_pthread.rs b/crates/0-std-tests/src/tests_pthread.rs new file mode 100644 index 0000000..c9969bb --- /dev/null +++ b/crates/0-std-tests/src/tests_pthread.rs @@ -0,0 +1,159 @@ +#[cfg(test)] +mod tests { + use anyhow::{anyhow, Result}; + use std::{ + collections::HashMap, + sync::{mpsc, Arc, Condvar, Mutex, RwLock}, + thread, + }; + + #[test] + pub fn test_thread_mutex() { + let map = Arc::new(Mutex::new(HashMap::::new())); + { + let map = map.lock().expect("Dirty mutex"); + assert!(map.len() == 0, "map is not empty"); + } + + let threads = (0..10) + .map(|_| { + let map = Arc::clone(&map); + thread::Builder::new() + .stack_size(128 * 1024) + .spawn(move || { + // Mutex contention + for i in 0..100 { + let v = rand::random::() % 1000; + let mut map = map.lock().expect("Dirty mutex"); + let old = map.get(&i).cloned().unwrap_or(0); + map.insert(i, v + old); + } + }) + .expect("Unable to spawn thread") + }) + .collect::>(); + + for t in threads { + t.join().expect("Unable to join thread"); + } + + let map = map.lock().expect("Dirty mutex!"); + + assert!(map.len() == 100, "map should have exactly 100 keys"); + } + + #[test] + pub fn test_drop_mutex_from_another_thread() -> Result<()> { + let mutex = Mutex::new(0u64); + { + let mut v = mutex.lock().expect("Dirty mutex"); + *v = 10; + } + + thread::Builder::new() + .stack_size(128 * 1024) + .spawn(move || -> Result<()> { + { + let mut v = mutex.lock().expect("Dirty mutex"); + *v += 1; + assert!(*v == 11, "Should be 10"); + } + drop(mutex); + Ok(()) + }) + .map_err(|_| anyhow!("Unable to spawn thread"))? + .join() + .map_err(|_| anyhow!("Unable to join thread"))??; + + Ok(()) + } + + #[test] + pub fn test_condvar() { + const NUM_THREADS: u32 = 10; + let pair = Arc::new((Mutex::new(0), Condvar::new())); + + let mut handles = vec![]; + + for _ in 0..NUM_THREADS { + let pair2 = pair.clone(); + let handle = thread::spawn(move || { + let (lock, condvar) = &*pair2; + let mut started = lock.lock().expect("dirty mutex"); + *started += 1; + condvar.notify_one(); + }); + handles.push(handle); + } + + { + let (lock, condvar) = &*pair; + let mut started = lock.lock().expect("dirty mutex"); + while *started < NUM_THREADS { + started = condvar.wait(started).expect("dirty condvar"); + } + } + + for handle in handles { + handle.join().expect("unable to join thread"); + } + + let (lock, _) = &*pair; + let final_val = lock.lock().unwrap(); + assert!(*final_val == NUM_THREADS, "final value muse be equal to 10"); + } + + #[test] + pub fn test_semaphore() { + const NUM_THREADS: usize = 10; + const NUM_RESOURCES: usize = 5; + + // Create a channel with a bounded capacity + let (tx, rx) = mpsc::sync_channel(NUM_RESOURCES); + let tx = Arc::new(Mutex::new(tx)); + + let handles = (0..NUM_THREADS) + .map(|_| { + let tx = Arc::clone(&tx); + thread::spawn(move || { + let tx = tx.lock().expect("Dirty mutex"); + tx.send(()).unwrap(); + }) + }) + .collect::>(); + for _ in 0..NUM_THREADS { + rx.recv().expect("recv error"); + } + + for handle in handles { + handle.join().expect("join error"); + } + + assert!(rx.try_recv().is_err(), "recv is not error"); + } + + #[test] + pub fn test_rwlock() { + let data = Arc::new(RwLock::new(0)); + { + let data = data.read().expect("Dirty mutex"); + assert!(*data == 0, "map is not empty"); + } + let threads = (0..10) + .map(|_| { + let data = Arc::clone(&data); + thread::spawn(move || { + let mut data = data.write().expect("Dirty RwLock"); + *data += 1; + }) + }) + .collect::>(); + + for t in threads { + t.join().expect("join error"); + } + + let data = data.read().unwrap(); + assert!(*data == 10, "counter is not 10"); + } +} diff --git a/crates/0-std-tests/src/tests_tcp.rs b/crates/0-std-tests/src/tests_tcp.rs new file mode 100644 index 0000000..a1d304c --- /dev/null +++ b/crates/0-std-tests/src/tests_tcp.rs @@ -0,0 +1,115 @@ +#[cfg(test)] +mod tests { + use std::{ + io::{Read, Write}, + time::Duration, + }; + use std::{ + net::{Shutdown, TcpListener, TcpStream}, + sync::atomic::{AtomicBool, Ordering}, + }; + use std::{ + sync::{mpsc, Arc, Mutex}, + thread, + }; + + fn handle_client(mut stream: TcpStream, counter: Arc>, should_end: Arc) { + let mut buffer = [0; 3]; + + while match stream.read(&mut buffer) { + Ok(size) => match &buffer[..size] { + b"ADD" => { + let mut counter = counter.lock().unwrap(); + *counter += 1; + true + } + b"END" => { + stream.shutdown(Shutdown::Both).unwrap(); + should_end.store(true, Ordering::SeqCst); + false + } + _ => true, + }, + Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => { + thread::sleep(Duration::from_millis(1000)); + true + } + Err(e) => { + println!( + "An error occurred, terminating connection with {}. {:?}", + stream.peer_addr().unwrap(), + e + ); + stream.shutdown(Shutdown::Both).unwrap(); + false + } + } {} + } + + #[test] + pub fn test_tcp() { + let counter = Arc::new(Mutex::new(0)); + let should_end = Arc::new(AtomicBool::new(false)); + let (tx, rx) = mpsc::channel(); + + let server_handle = { + let counter = Arc::clone(&counter); + let tx = tx.clone(); + + thread::spawn(move || { + let listener = + TcpListener::bind("localhost:12345").expect("Unable to bind to port"); + listener + .set_nonblocking(true) + .expect("unable to set non-blocking mode"); + + tx.send(()).unwrap(); + + loop { + if should_end.load(Ordering::SeqCst) { + break; + } + + match listener.accept() { + Ok((stream, _)) => { + let counter = Arc::clone(&counter); + let should_end = Arc::clone(&should_end); + thread::spawn(move || { + handle_client(stream, counter, should_end); + }); + } + Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => { + thread::sleep(Duration::from_millis(100)); + continue; + } + Err(e) => { + println!("Failed: {}", e); + } + } + } + }) + }; + + // Wait until server starts + rx.recv().unwrap(); + + { + let mut stream = + TcpStream::connect("localhost:12345").expect("unable to connect to server"); + for _ in 0..4 { + let _ = stream.write(b"ADD"); + let _ = stream.flush(); + thread::sleep(Duration::from_millis(100)); + } + + let _ = stream.write(b"END"); + let _ = stream.flush(); + } + + server_handle.join().expect("unable to join server thread"); + + let counter = counter.lock().unwrap(); + + assert!(*counter == 4, "counter should be 4"); + } +} diff --git a/crates/0-std-tests/src/tests_unwind.rs b/crates/0-std-tests/src/tests_unwind.rs new file mode 100644 index 0000000..ab9d46f --- /dev/null +++ b/crates/0-std-tests/src/tests_unwind.rs @@ -0,0 +1,16 @@ +#[cfg(test)] +mod tests { + use std::panic; + + #[test] + pub fn test_unwind() { + let result = panic::catch_unwind(|| std::hint::black_box(())); + assert!(result.is_ok(), "panic shouldn't happen"); + + let result = panic::catch_unwind(|| { + panic!("oh no!"); + }); + + assert!(result.is_err(), "panic should be handled"); + } +} diff --git a/crates/1-cross-isa/Cargo.toml b/crates/1-cross-isa/Cargo.toml new file mode 100644 index 0000000..13417ab --- /dev/null +++ b/crates/1-cross-isa/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "vita-example-cross-isa" +version = "0.1.0" +edition = "2021" + +license = "MIT OR Apache-2.0" +repository = "https://github.com/vita-rust/examples" +homepage = "https://github.com/vita-rust/examples/crates/1-cross-isa" + +[dependencies] + +[package.metadata.vita] +title_id = "RUSTTEST1" +title_name = "Rust cross-isa test" diff --git a/crates/1-cross-isa/src/main.rs b/crates/1-cross-isa/src/main.rs new file mode 100644 index 0000000..3001259 --- /dev/null +++ b/crates/1-cross-isa/src/main.rs @@ -0,0 +1,15 @@ +#[instruction_set(arm::a32)] +fn arm_fn(n: i32) { + println!("Hello from ARM!, {n}"); +} + +#[instruction_set(arm::t32)] +fn thumb_fn(n: i32) { + println!("Hello from Thumb!, {n}"); + arm_fn(n + 1); +} + +#[instruction_set(arm::a32)] +fn main() { + thumb_fn(0); +} diff --git a/crates/2-http-client/Cargo.toml b/crates/2-http-client/Cargo.toml new file mode 100644 index 0000000..9a6a668 --- /dev/null +++ b/crates/2-http-client/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "vita-example-http" +version = "0.1.0" +edition = "2021" + +license = "MIT OR Apache-2.0" +repository = "https://github.com/vita-rust/examples" +homepage = "https://github.com/vita-rust/examples/crates/2-http-client" + +[features] +default = ["rustls", "shims"] +shims = ["vita-newlib-shims"] +rustls = ["reqwest/rustls-tls", "oxhttp/rustls"] +openssl = ["reqwest/native-tls"] + +[dependencies] +anyhow = "1.0" +libc = "0.2.149" +reqwest = { version = "0.11", default-features = false, features = ["json"] } +tokio = { version = "1", features = ["macros", "rt", "net"] } +oxhttp = { version = "0.1.7", features = ["rustls"] } +ureq = { version = "2.7.1", default-features = false, features = ["gzip"] } +vita-newlib-shims = { version = "0.2", optional = true } + +[package.metadata.vita] +title_id = "RUSTTEST2" +title_name = "Rust http test" + +# This disables safe mode (default -s flag) for reading openssl certs +vita_make_fself_flags = [] diff --git a/crates/2-http-client/src/main.rs b/crates/2-http-client/src/main.rs new file mode 100644 index 0000000..91c3927 --- /dev/null +++ b/crates/2-http-client/src/main.rs @@ -0,0 +1,39 @@ +#[cfg(all(target_os = "vita", feature = "shims"))] +use vita_newlib_shims as _; + +use oxhttp::{ + model::{Method, Request}, + Client, +}; + +fn main() -> anyhow::Result<()> { + std::env::set_var("RUST_BACKTRACE", "full"); + // For openssl instead of rustls you must provide cert files. + // The shared cert files are located on a vs0 partition which is only accessible with unsafe apps. + // If you want to use openssl, you must either make your app unsafe or provide your own certs. + std::env::set_var("SSL_CERT_FILE", "vs0:data/external/cert/CA_LIST.cer"); + + tokio::runtime::Builder::new_current_thread() + .enable_all() + .build()? + .block_on(async { + println!(">>> Trying oxhttp"); + let client = Client::new(); + let body = client + .request(Request::builder(Method::GET, "https://example.com".parse()?).build())? + .into_body() + .to_string()?; + println!(">>> oxhttp response: {body}"); + + // Requires std to depend on the latest libc + // println!(">>> Trying ureq"); + // let body = ureq::get("http://example.com").call()?; + // println!(">>> Ureq response: {:?}", body); + + println!(">>> Trying reqwest"); + let body = reqwest::get("https://example.com").await?.text().await?; + println!(">>> Reqwest response: {:#?}", body); + + Ok(()) + }) +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..5d56faf --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "nightly"