Add support for wasm (#278)
This commit is contained in:
parent
362b6b728a
commit
d329bc0912
|
@ -60,3 +60,29 @@ jobs:
|
|||
run: cargo build --locked --tests --verbose
|
||||
- name: Run tests
|
||||
run: cargo test --locked --verbose
|
||||
|
||||
test-wasm:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install nightly
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
components: rustfmt
|
||||
default: false
|
||||
target: wasm32-unknown-unknown
|
||||
- uses: nanasess/setup-chromedriver@v1
|
||||
- name: Install stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
components: rustfmt
|
||||
default: true
|
||||
target: wasm32-unknown-unknown
|
||||
- name: Install wasm-bindgen-cli
|
||||
run: cargo install --version 0.2.84 wasm-bindgen-cli
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd example-wasm
|
||||
CHROMEDRIVER=$(which chromedriver) cargo test --target wasm32-unknown-unknown --locked --verbose
|
||||
|
|
|
@ -292,6 +292,16 @@ dependencies = [
|
|||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "console_error_panic_hook"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.9.2"
|
||||
|
@ -503,6 +513,21 @@ dependencies = [
|
|||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "example-wasm"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"chrono",
|
||||
"progenitor",
|
||||
"progenitor-client",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"uuid",
|
||||
"wasm-bindgen-test",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "expectorate"
|
||||
version = "1.0.7"
|
||||
|
@ -668,8 +693,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"wasi 0.10.2+wasi-snapshot-preview1",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -921,9 +948,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.59"
|
||||
version = "0.3.61"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2"
|
||||
checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
@ -1589,6 +1616,12 @@ dependencies = [
|
|||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scoped-tls"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294"
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.1.0"
|
||||
|
@ -2268,6 +2301,7 @@ checksum = "5b55a3fef2a1e3b3a00ce878640918820d3c51081576ac657d23af9fc7928fdb"
|
|||
dependencies = [
|
||||
"getrandom",
|
||||
"serde",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2317,9 +2351,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.82"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d"
|
||||
checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"wasm-bindgen-macro",
|
||||
|
@ -2327,9 +2361,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.82"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f"
|
||||
checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
|
@ -2342,9 +2376,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-futures"
|
||||
version = "0.4.28"
|
||||
version = "0.4.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e8d7523cb1f2a4c96c1317ca690031b714a51cc14e05f712446691f413f5d39"
|
||||
checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
|
@ -2354,9 +2388,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.82"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602"
|
||||
checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
|
@ -2364,9 +2398,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.82"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da"
|
||||
checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -2377,9 +2411,33 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.82"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a"
|
||||
checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-test"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6db36fc0f9fb209e88fb3642590ae0205bb5a56216dabd963ba15879fe53a30b"
|
||||
dependencies = [
|
||||
"console_error_panic_hook",
|
||||
"js-sys",
|
||||
"scoped-tls",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"wasm-bindgen-test-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-test-macro"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0734759ae6b3b1717d661fe4f016efcfb9828f5edb4520c18eaee05af3b43be9"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-streams"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
members = [
|
||||
"example-build",
|
||||
"example-macro",
|
||||
"example-wasm",
|
||||
"progenitor",
|
||||
"progenitor-client",
|
||||
"progenitor-impl",
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
[target.wasm32-unknown-unknown]
|
||||
runner = 'wasm-bindgen-test-runner'
|
|
@ -0,0 +1,19 @@
|
|||
[package]
|
||||
name = "example-wasm"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
progenitor-client = { path = "../progenitor-client" }
|
||||
reqwest = { version = "0.11.16", features = ["json", "stream"] }
|
||||
base64 = "0.21"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
uuid = { version = "1.3", features = ["serde", "v4", "js"] }
|
||||
|
||||
[dev-dependencies]
|
||||
wasm-bindgen-test = "0.3.34"
|
||||
|
||||
[build-dependencies]
|
||||
progenitor = { path = "../progenitor" }
|
||||
serde_json = "1.0"
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright 2022 Oxide Computer Company
|
||||
|
||||
use std::{
|
||||
env,
|
||||
fs::{self, File},
|
||||
path::Path,
|
||||
};
|
||||
|
||||
fn main() {
|
||||
let src = "../sample_openapi/keeper.json";
|
||||
println!("cargo:rerun-if-changed={}", src);
|
||||
let file = File::open(src).unwrap();
|
||||
let spec = serde_json::from_reader(file).unwrap();
|
||||
let mut generator = progenitor::Generator::default();
|
||||
|
||||
let content = generator.generate_text(&spec).unwrap();
|
||||
|
||||
let mut out_file = Path::new(&env::var("OUT_DIR").unwrap()).to_path_buf();
|
||||
out_file.push("codegen.rs");
|
||||
|
||||
fs::write(out_file, content).unwrap();
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
release = false
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2021 Oxide Computer Company
|
||||
|
||||
// Include the generated code.
|
||||
include!(concat!(env!("OUT_DIR"), "/codegen.rs"));
|
||||
|
||||
fn main() {
|
||||
let client = Client::new("https://foo/bar");
|
||||
let _ = client.enrol(
|
||||
"auth-token",
|
||||
&types::EnrolBody {
|
||||
host: "".to_string(),
|
||||
key: "".to_string(),
|
||||
},
|
||||
);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
use wasm_bindgen_test::*;
|
||||
|
||||
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/codegen.rs"));
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn test_client_new() {
|
||||
let client = Client::new("http://foo/bar");
|
||||
assert!(client.baseurl == "http://foo/bar");
|
||||
}
|
|
@ -11,9 +11,14 @@ use futures_core::Stream;
|
|||
use reqwest::RequestBuilder;
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
type InnerByteStream =
|
||||
std::pin::Pin<Box<dyn Stream<Item = reqwest::Result<Bytes>> + Send + Sync>>;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
type InnerByteStream =
|
||||
std::pin::Pin<Box<dyn Stream<Item = reqwest::Result<Bytes>>>>;
|
||||
|
||||
/// Untyped byte stream used for both success and error responses.
|
||||
pub struct ByteStream(InnerByteStream);
|
||||
|
||||
|
@ -76,6 +81,7 @@ impl<T: DeserializeOwned> ResponseValue<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
impl ResponseValue<reqwest::Upgraded> {
|
||||
#[doc(hidden)]
|
||||
pub async fn upgrade<E: std::fmt::Debug>(
|
||||
|
|
|
@ -346,13 +346,18 @@ impl Generator {
|
|||
baseurl: &str,
|
||||
#inner_parameter
|
||||
) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client, #inner_value)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
|
||||
Self::new_with_client(baseurl, client.build().unwrap(), #inner_value)
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -1591,13 +1591,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -1591,13 +1591,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -266,13 +266,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -916,13 +916,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -916,13 +916,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -155,13 +155,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -17075,13 +17075,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -17131,13 +17131,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -5903,13 +5903,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -27,13 +27,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -27,13 +27,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -27,13 +27,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -1969,13 +1969,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -1975,13 +1975,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -622,13 +622,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -240,13 +240,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -70,13 +70,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -39,13 +39,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
|
@ -39,13 +39,16 @@ impl Client {
|
|||
/// `reqwest::Client`, and should include a scheme and hostname,
|
||||
/// as well as port and a path stem if applicable.
|
||||
pub fn new(baseurl: &str) -> Self {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let client = {
|
||||
let dur = std::time::Duration::from_secs(15);
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
reqwest::ClientBuilder::new()
|
||||
.connect_timeout(dur)
|
||||
.timeout(dur)
|
||||
.build()
|
||||
.unwrap();
|
||||
Self::new_with_client(baseurl, client)
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let client = reqwest::ClientBuilder::new();
|
||||
Self::new_with_client(baseurl, client.build().unwrap())
|
||||
}
|
||||
|
||||
/// Construct a new client with an existing `reqwest::Client`,
|
||||
|
|
Loading…
Reference in New Issue