Merge pull request #3543 from rtfeldman/http-sync

Http example
This commit is contained in:
Richard Feldman 2022-07-18 21:35:23 -04:00 committed by GitHub
commit 2b0bfbb590
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 5770 additions and 74 deletions

132
Cargo.lock generated
View File

@ -146,16 +146,16 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "backtrace"
version = "0.3.65"
version = "0.3.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61"
checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7"
dependencies = [
"addr2line",
"cc",
"cfg-if 1.0.0",
"libc",
"miniz_oxide",
"object 0.28.4",
"object 0.29.0",
"rustc-demangle",
]
@ -237,9 +237,9 @@ dependencies = [
[[package]]
name = "bitvec"
version = "1.0.0"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1489fcb93a5bb47da0462ca93ad252ad6af2145cce58d10d46a83931ba9f016b"
checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c"
dependencies = [
"funty 2.0.0",
"radium 0.7.0",
@ -330,9 +330,9 @@ dependencies = [
[[package]]
name = "bytemuck"
version = "1.9.1"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdead85bdec19c194affaeeb670c0e41fe23de31459efd1c174d049269cf02cc"
checksum = "c53dfa917ec274df8ed3c572698f381a24eef2efba9492d797301b72b6db408a"
dependencies = [
"bytemuck_derive",
]
@ -475,9 +475,9 @@ dependencies = [
[[package]]
name = "clap"
version = "3.2.8"
version = "3.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "190814073e85d238f31ff738fcb0bf6910cedeb73376c87cd69291028966fd83"
checksum = "d646c7ade5eb07c4aa20e907a922750df0c448892513714fd3e4acbc7130829f"
dependencies = [
"atty",
"bitflags",
@ -660,9 +660,9 @@ checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935"
[[package]]
name = "const_format"
version = "0.2.25"
version = "0.2.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2906f2480cdc015e998deac388331a0f1c1cd88744948c749513020c83c370bc"
checksum = "939dc9e2eb9077e0679d2ce32de1ded8531779360b003b4a972a7a39ec263495"
dependencies = [
"const_format_proc_macros",
]
@ -801,9 +801,9 @@ dependencies = [
[[package]]
name = "corosensei"
version = "0.1.2"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab4b310cff9117ec16d05970743c20df3eaddafd461829f2758e76a8de2863a9"
checksum = "9847f90f32a50b0dcbd68bc23ff242798b13080b97b0569f6ed96a45ce4cf2cd"
dependencies = [
"autocfg",
"cfg-if 1.0.0",
@ -1019,9 +1019,9 @@ dependencies = [
[[package]]
name = "crypto-common"
version = "0.1.3"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8"
checksum = "2ccfd8c0ee4cce11e45b3fd6f9d5e69e0cc62912aa6a0cb1bf4617b0eba5a12f"
dependencies = [
"generic-array 0.14.5",
"typenum",
@ -1246,7 +1246,7 @@ checksum = "64fba5a42bd76a17cad4bfa00de168ee1cbfa06a5e8ce992ae880218c05641a9"
dependencies = [
"byteorder",
"dynasm",
"memmap2 0.5.4",
"memmap2 0.5.5",
]
[[package]]
@ -1713,9 +1713,9 @@ dependencies = [
[[package]]
name = "hashbrown"
version = "0.12.1"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3"
checksum = "607c8a29735385251a339424dd462993c0fed8fa09d378f259377df08c126022"
dependencies = [
"ahash",
"bumpalo",
@ -1805,7 +1805,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
dependencies = [
"autocfg",
"hashbrown 0.12.1",
"hashbrown 0.12.2",
"serde",
]
@ -2153,9 +2153,9 @@ dependencies = [
[[package]]
name = "memmap2"
version = "0.5.4"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5172b50c23043ff43dd53e51392f36519d9b35a8f3a410d30ece5d1aedd58ae"
checksum = "3a79b39c93a7a5a27eeaf9a23b5ff43f1b9e0ad6b1cdd441140ae53c35613fc7"
dependencies = [
"libc",
]
@ -2556,7 +2556,7 @@ checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53"
dependencies = [
"crc32fast",
"flate2",
"hashbrown 0.12.1",
"hashbrown 0.12.2",
"indexmap",
"memchr",
]
@ -2595,9 +2595,9 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.12.0"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225"
checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
[[package]]
name = "oorandom"
@ -2906,15 +2906,15 @@ dependencies = [
[[package]]
name = "plotters-backend"
version = "0.3.2"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c"
checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142"
[[package]]
name = "plotters-svg"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9"
checksum = "e0918736323d1baff32ee0eade54984f6f201ad7e97d5cfb5d6ab4a358529615"
dependencies = [
"plotters-backend",
]
@ -3196,9 +3196,9 @@ dependencies = [
[[package]]
name = "regex"
version = "1.5.6"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1"
checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b"
dependencies = [
"aho-corasick",
"memchr",
@ -3213,9 +3213,9 @@ checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
[[package]]
name = "regex-syntax"
version = "0.6.26"
version = "0.6.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
[[package]]
name = "region"
@ -3287,7 +3287,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cec2b3485b07d96ddfd3134767b8a447b45ea4eb91448d0a35180ec0ffd5ed15"
dependencies = [
"bytecheck",
"hashbrown 0.12.1",
"hashbrown 0.12.2",
"ptr_meta",
"rend",
"rkyv_derive",
@ -3319,7 +3319,7 @@ name = "roc-bindgen"
version = "0.1.0"
dependencies = [
"bumpalo",
"clap 3.2.8",
"clap 3.2.11",
"cli_utils",
"ctor",
"dircpy",
@ -3435,7 +3435,7 @@ dependencies = [
name = "roc_can"
version = "0.1.0"
dependencies = [
"bitvec 1.0.0",
"bitvec 1.0.1",
"bumpalo",
"indoc",
"pretty_assertions",
@ -3455,7 +3455,7 @@ name = "roc_cli"
version = "0.1.0"
dependencies = [
"bumpalo",
"clap 3.2.8",
"clap 3.2.11",
"cli_utils",
"const_format",
"criterion",
@ -3515,9 +3515,9 @@ dependencies = [
name = "roc_collections"
version = "0.1.0"
dependencies = [
"bitvec 1.0.0",
"bitvec 1.0.1",
"bumpalo",
"hashbrown 0.12.1",
"hashbrown 0.12.2",
"im",
"im-rc",
"wyhash",
@ -3596,7 +3596,7 @@ dependencies = [
name = "roc_docs_cli"
version = "0.1.0"
dependencies = [
"clap 3.2.8",
"clap 3.2.11",
"roc_docs",
]
@ -3725,7 +3725,7 @@ dependencies = [
name = "roc_gen_wasm"
version = "0.1.0"
dependencies = [
"bitvec 1.0.0",
"bitvec 1.0.1",
"bumpalo",
"roc_builtins",
"roc_collections",
@ -3769,10 +3769,10 @@ version = "0.1.0"
dependencies = [
"bincode",
"bumpalo",
"clap 3.2.8",
"clap 3.2.11",
"iced-x86",
"mach_object",
"memmap2 0.5.4",
"memmap2 0.5.5",
"object 0.26.2",
"roc_build",
"roc_collections",
@ -3850,7 +3850,7 @@ name = "roc_mono"
version = "0.1.0"
dependencies = [
"bumpalo",
"hashbrown 0.12.1",
"hashbrown 0.12.2",
"roc_builtins",
"roc_can",
"roc_collections",
@ -4147,14 +4147,14 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver 1.0.11",
"semver 1.0.12",
]
[[package]]
name = "rustix"
version = "0.35.6"
version = "0.35.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef258c11e17f5c01979a10543a30a4e12faef6aab217a74266e747eefa3aed88"
checksum = "d51cc38aa10f6bbb377ed28197aa052aa4e2b762c22be9d3153d01822587e787"
dependencies = [
"bitflags",
"errno",
@ -4255,9 +4255,9 @@ dependencies = [
[[package]]
name = "semver"
version = "1.0.11"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d92beeab217753479be2f74e54187a6aed4c125ff0703a866c3147a02f0c6dd"
checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1"
[[package]]
name = "semver-parser"
@ -4276,9 +4276,9 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.137"
version = "1.0.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1"
checksum = "0171ebb889e45aa68b44aee0859b3eede84c6f5f5c228e6f140c0b2a0a46cad6"
dependencies = [
"serde_derive",
]
@ -4316,9 +4316,9 @@ dependencies = [
[[package]]
name = "serde_derive"
version = "1.0.137"
version = "1.0.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be"
checksum = "dc1d3230c1de7932af58ad8ffbe1d784bd55efd5a9d84ac24f69c72d83543dfb"
dependencies = [
"proc-macro2",
"quote",
@ -4338,9 +4338,9 @@ dependencies = [
[[package]]
name = "serde_yaml"
version = "0.8.24"
version = "0.8.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "707d15895415db6628332b737c838b88c598522e4dc70647e59b72312924aebc"
checksum = "1ec0091e1f5aa338283ce049bd9dfefd55e1f168ac233e85c1ffe0038fb48cbe"
dependencies = [
"indexmap",
"ryu",
@ -4526,7 +4526,7 @@ dependencies = [
"dlib",
"lazy_static",
"log",
"memmap2 0.5.4",
"memmap2 0.5.5",
"nix 0.24.1",
"pkg-config",
"wayland-client",
@ -4987,9 +4987,9 @@ dependencies = [
[[package]]
name = "tracing-attributes"
version = "0.1.21"
version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc6b8ad3567499f98a1db7a752b07a7c8c7c7c34c332ec00effb2b0027974b7c"
checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2"
dependencies = [
"proc-macro2",
"quote",
@ -5036,9 +5036,9 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
[[package]]
name = "ucd-trie"
version = "0.1.3"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c"
[[package]]
name = "unicase"
@ -5220,9 +5220,9 @@ checksum = "6a89911bd99e5f3659ec4acf9c4d93b0a90fe4a2a11f15328472058edc5261be"
[[package]]
name = "wasm-encoder"
version = "0.13.0"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31f0c17267a5ffd6ae3d897589460e21db1673c84fb7016b909c9691369a75ea"
checksum = "f76068e87fe9b837a6bc2ccded66784173eadb828c4168643e9fddf6f9ed2e61"
dependencies = [
"leb128",
]
@ -5368,7 +5368,7 @@ dependencies = [
"enumset",
"lazy_static",
"loupe",
"memmap2 0.5.4",
"memmap2 0.5.5",
"more-asserts",
"rustc-demangle",
"serde",
@ -5548,9 +5548,9 @@ checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a"
[[package]]
name = "wast"
version = "42.0.0"
version = "44.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "badcb03f976f983ff0daf294da9697be659442f61e6b0942bb37a2b6cbfe9dd4"
checksum = "5f474d1b1cb7d92e5360b293f28e8bc9b2d115197a5bbf76bdbfba9161cf9cdc"
dependencies = [
"leb128",
"memchr",
@ -5560,9 +5560,9 @@ dependencies = [
[[package]]
name = "wat"
version = "1.0.44"
version = "1.0.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b92f20b742ac527066c8414bc0637352661b68cab07ef42586cefaba71c965cf"
checksum = "82d002ce2eca0730c6df2c21719e9c4d8d0cafe74fb0cb8ff137c0774b8e4ed1"
dependencies = [
"wast",
]

View File

@ -64,7 +64,8 @@ impl MakeSpecializationsDependents {
let entry = self.entry(module_id);
debug_assert!(
entry.succ.is_empty(),
"already added successors for this module"
"already added successors for module '{:?}'",
module_id
);
entry.succ.extend(succ.into_iter());

View File

@ -3,3 +3,4 @@ echo
effects
form
tui
http-get

View File

@ -2,25 +2,186 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "adler"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "arrayvec"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
[[package]]
name = "base64"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]]
name = "bumpalo"
version = "3.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3"
[[package]]
name = "cc"
version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chunked_transfer"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fff857943da45f546682664a79488be82e69e43c1a7a2307679ab9afb3a66d2e"
[[package]]
name = "crc32fast"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
dependencies = [
"cfg-if",
]
[[package]]
name = "flate2"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6"
dependencies = [
"crc32fast",
"miniz_oxide",
]
[[package]]
name = "form_urlencoded"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191"
dependencies = [
"matches",
"percent-encoding",
]
[[package]]
name = "host"
version = "0.1.0"
dependencies = [
"libc",
"roc_std",
"ureq",
]
[[package]]
name = "libc"
version = "0.2.106"
name = "idna"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a60553f9a9e039a333b4e9b20573b9e9b9c0bb3a11e201ccc48ef4283456d673"
checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8"
dependencies = [
"matches",
"unicode-bidi",
"unicode-normalization",
]
[[package]]
name = "js-sys"
version = "0.3.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3fac17f7123a73ca62df411b1bf727ccc805daa070338fda671c86dac1bdc27"
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.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
[[package]]
name = "log"
version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
"cfg-if",
]
[[package]]
name = "matches"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]]
name = "miniz_oxide"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc"
dependencies = [
"adler",
]
[[package]]
name = "once_cell"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
[[package]]
name = "percent-encoding"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
name = "proc-macro2"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
dependencies = [
"proc-macro2",
]
[[package]]
name = "ring"
version = "0.16.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc"
dependencies = [
"cc",
"libc",
"once_cell",
"spin",
"untrusted",
"web-sys",
"winapi",
]
[[package]]
name = "roc_std"
@ -30,8 +191,223 @@ dependencies = [
"static_assertions",
]
[[package]]
name = "rustls"
version = "0.20.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aab8ee6c7097ed6057f43c187a62418d0c05a4bd5f18b3571db50ee0f9ce033"
dependencies = [
"log",
"ring",
"sct",
"webpki",
]
[[package]]
name = "sct"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4"
dependencies = [
"ring",
"untrusted",
]
[[package]]
name = "spin"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "syn"
version = "1.0.98"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[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.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "unicode-bidi"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
[[package]]
name = "unicode-ident"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
[[package]]
name = "unicode-normalization"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6"
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.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b97acb4c28a254fd7a4aeec976c46a7fa404eac4d7c134b30c75144846d7cb8f"
dependencies = [
"base64",
"chunked_transfer",
"flate2",
"log",
"once_cell",
"rustls",
"url",
"webpki",
"webpki-roots",
]
[[package]]
name = "url"
version = "2.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c"
dependencies = [
"form_urlencoded",
"idna",
"matches",
"percent-encoding",
]
[[package]]
name = "wasm-bindgen"
version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c53b543413a17a202f4be280a7e5c62a1c69345f5de525ee64f8cfdbc954994"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5491a68ab4500fa6b4d726bd67408630c3dbe9c4fe7bda16d5c82a1fd8c7340a"
dependencies = [
"bumpalo",
"lazy_static",
"log",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c441e177922bc58f1e12c022624b6216378e5febc2f0533e41ba443d505b80aa"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d94ac45fcf608c1f45ef53e748d35660f168490c10b23704c7779ab8f5c3048"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a89911bd99e5f3659ec4acf9c4d93b0a90fe4a2a11f15328472058edc5261be"
[[package]]
name = "web-sys"
version = "0.3.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fed94beee57daf8dd7d51f2b15dc2bcde92d7a72304cdf662a4371008b71b90"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "webpki"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd"
dependencies = [
"ring",
"untrusted",
]
[[package]]
name = "webpki-roots"
version = "0.22.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1c760f0d366a6c24a02ed7816e23e691f5d92291f94d15e836006fd11b04daf"
dependencies = [
"webpki",
]
[[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"

View File

@ -19,5 +19,6 @@ path = "src/main.rs"
[dependencies]
roc_std = { path = "../../../crates/roc_std" }
libc = "0.2"
ureq = "2.5.0"
[workspace]

View File

@ -1,8 +1,10 @@
hosted Effect
exposes [Effect, after, map, always, forever, loop, putLine, getLine]
imports []
exposes [Effect, after, map, always, forever, loop, putLine, getLine, sendRequest]
imports [InternalHttp.{ Request, Response }]
generates Effect with [after, map, always, forever, loop]
putLine : Str -> Effect {}
getLine : Effect Str
sendRequest : Box Request -> Effect Response

View File

@ -0,0 +1,115 @@
interface Http
exposes [
Request,
Method,
Header,
Timeout,
ProgressTracking,
Body,
Response,
Metadata,
Error,
header,
emptyBody,
bytesBody,
stringBody,
handleStringResponse,
defaultRequest,
errorToString,
send,
]
imports [Effect, InternalTask, Task.{ Task }, InternalHttp]
Request : InternalHttp.Request
Method : InternalHttp.Method
Header : InternalHttp.Header
Timeout : InternalHttp.Timeout
ProgressTracking : InternalHttp.ProgressTracking
Body : InternalHttp.Body
Response : InternalHttp.Response
Metadata : InternalHttp.Metadata
Error : InternalHttp.Error
defaultRequest : Request
defaultRequest = {
method: Get,
headers: [],
url: "",
body: Http.emptyBody,
timeout: NoTimeout,
progressTracking: NoProgressTracking,
allowCookiesFromOtherDomains: False,
}
## An HTTP header for configuring requests. See a bunch of common headers
## [here](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields).
##
header : Str, Str -> Header
header =
Header
emptyBody : Body
emptyBody =
EmptyBody
bytesBody : [MimeType Str], List U8 -> Body
bytesBody =
Body
stringBody : [MimeType Str], Str -> Body
stringBody = \mimeType, str ->
Body mimeType (Str.toUtf8 str)
# jsonBody : a -> Body | a has Encoding
# jsonBody = \val ->
# Body (MimeType "application/json") (Encode.toBytes val Json.format)
#
# multiPartBody : List Part -> Body
# multiPartBody = \parts ->
# boundary = "7MA4YWxkTrZu0gW" # TODO: what's this exactly? a hash of all the part bodies?
# beforeName = Str.toUtf8 "-- \(boundary)\r\nContent-Disposition: form-data; name=\""
# afterName = Str.toUtf8 "\"\r\n"
# appendPart = \buffer, Part name partBytes ->
# buffer
# |> List.concat beforeName
# |> List.concat (Str.toUtf8 name)
# |> List.concat afterName
# |> List.concat partBytes
# bodyBytes = List.walk parts [] appendPart
# Body (MimeType "multipart/form-data;boundary=\"\(boundary)\"") bodyBytes
# bytesPart : Str, List U8 -> Part
# bytesPart =
# Part
# stringPart : Str, Str -> Part
# stringPart = \name, str ->
# Part name (Str.toUtf8 str)
handleStringResponse : Response -> Result Str Error
handleStringResponse = \response ->
when response is
BadUrl url -> Err (BadUrl url)
Timeout -> Err Timeout
NetworkError -> Err NetworkError
BadStatus metadata _ -> Err (BadStatus metadata.statusCode)
GoodStatus _ bodyBytes ->
Str.fromUtf8 bodyBytes
|> Result.mapErr
\BadUtf8 _ pos ->
position = Num.toStr pos
BadBody "Invalid UTF-8 at byte offset \(position)"
errorToString : Error -> Str
errorToString = \err ->
when err is
BadUrl url -> "\(url) is not a valid URL"
Timeout -> "Request timed out"
NetworkError -> "Network error"
BadStatus code -> Str.concat "Request failed with status " (Num.toStr code)
BadBody details -> Str.concat "Request failed. Invalid body. " details
send : Request -> Task Str Error [Network [Http]*]*
send = \req ->
# TODO: Fix our C ABI codegen so that we don't this Box.box heap allocation
Effect.sendRequest (Box.box req)
|> Effect.map handleStringResponse
|> InternalTask.fromEffect

View File

@ -0,0 +1,51 @@
interface InternalHttp
exposes [Request, Method, Header, Timeout, ProgressTracking, Part, Body, Response, Metadata, Error]
imports []
Request : {
method : Method,
headers : List Header,
url : Str,
body : Body,
timeout : Timeout,
progressTracking : ProgressTracking,
allowCookiesFromOtherDomains : Bool,
}
Method : [Options, Get, Post, Put, Delete, Head, Trace, Connect, Patch]
Header : [Header Str Str]
Timeout : [Timeout F64, NoTimeout]
ProgressTracking : [ProgressTrackingId Str, NoProgressTracking]
Part : [Part Str (List U8)]
Body : [
Body [MimeType Str] (List U8),
EmptyBody,
]
Response : [
BadUrl Str,
Timeout,
NetworkError,
BadStatus Metadata (List U8),
GoodStatus Metadata (List U8),
]
Metadata : {
url : Str,
statusCode : U16,
statusText : Str,
headers : List Header,
}
Error : [
BadUrl Str,
Timeout,
NetworkError,
BadStatus U16,
BadBody Str,
]

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,16 @@
#![allow(non_snake_case)]
mod glue;
use core::alloc::Layout;
use core::ffi::c_void;
use core::mem::{ManuallyDrop, MaybeUninit};
use core::mem::MaybeUninit;
use glue::Metadata;
use libc;
use roc_std::RocStr;
use roc_std::{RocList, RocStr};
use std::ffi::CStr;
use std::os::raw::c_char;
use ureq::Error;
extern "C" {
#[link_name = "roc__mainForHost_1_exposed_generic"]
@ -123,3 +127,70 @@ pub extern "C" fn roc_fx_putLine(line: &RocStr) {
let string = line.as_str();
println!("{}", string);
}
const BODY_MAX_BYTES: usize = 10 * 1024 * 1024;
#[no_mangle]
pub extern "C" fn roc_fx_sendRequest(roc_request: &glue::Request) -> glue::Response {
use std::io::Read;
let url = roc_request.url.as_str();
match ureq::get(url).call() {
Ok(response) => {
let statusCode = response.status();
let len: usize = response
.header("Content-Length")
.and_then(|val| val.parse::<usize>().ok())
.map(|val| val.max(BODY_MAX_BYTES))
.unwrap_or(BODY_MAX_BYTES);
let mut bytes: Vec<u8> = Vec::with_capacity(len);
match response
.into_reader()
.take(len as u64)
.read_to_end(&mut bytes)
{
Ok(_read_bytes) => {}
Err(_) => {
// Not totally accurate, but let's deal with this later when we do async
return glue::Response::NetworkError;
}
}
// Note: we could skip a full memcpy if we had `RocList::from_iter`.
let body = RocList::from_slice(&bytes);
let metadata = Metadata {
headers: RocList::empty(), // TODO
statusText: RocStr::empty(), // TODO
url: RocStr::empty(), // TODO
statusCode,
};
glue::Response::GoodStatus(metadata, body)
}
Err(Error::Status(statusCode, response)) => {
let mut buffer: Vec<u8> = vec![];
let mut reader = response.into_reader();
reader.read(&mut buffer).expect("can't read response");
let body = RocList::from_slice(&buffer);
let metadata = Metadata {
headers: RocList::empty(), // TODO
statusText: RocStr::empty(), // TODO
url: RocStr::empty(), // TODO
statusCode,
};
glue::Response::BadStatus(metadata, body)
}
Err(transportError) => {
use ureq::ErrorKind::*;
match transportError.kind() {
InvalidUrl | UnknownScheme => glue::Response::BadUrl(RocStr::from(url)),
_ => glue::Response::NetworkError,
}
}
}
}

View File

@ -0,0 +1,26 @@
app "http-get"
packages { pf: "cli-platform/main.roc" }
imports [pf.Http, pf.Task, pf.Stdin, pf.Stdout]
provides [main] to pf
main : Task.Task {} [] [Read [Stdin], Write [Stdout], Network [Http]]
main =
_ <- Task.await (Stdout.line "Please enter a URL to fetch")
url <- Task.await Stdin.line
request = {
method: Get,
headers: [],
url,
body: Http.emptyBody,
timeout: NoTimeout,
progressTracking: NoProgressTracking,
allowCookiesFromOtherDomains: False,
}
output <- Http.send request
|> Task.onFail (\err -> err |> Http.errorToString |> Task.succeed)
|> Task.await
Stdout.line output