Skip to content

Commit

Permalink
Add docs clarifying the wasm32 limitations in the code
Browse files Browse the repository at this point in the history
  • Loading branch information
nmldiegues authored and adamchalmers committed Dec 8, 2020
1 parent ff44acf commit 37d52e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions cloudflare/src/framework/async_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Client {
.default_headers(config.default_headers);

cfg_if! {
// There are no timeouts in wasm.
// There are no timeouts in wasm. The property is documented as no-op in wasm32.
if #[cfg(not(target_arch = "wasm32"))] {
builder = builder.timeout(config.http_timeout);
}
Expand Down Expand Up @@ -95,7 +95,8 @@ impl Client {
}
}

// The async_trait does not work nicely in wasm.
// The async_trait does not work nicely in wasm. The mapping of Rust Futures to wasm bindgen
// Promises does not seem to work when the async_trait macro is used: it causes compilation failures.
#[cfg(not(target_arch = "wasm32"))]
#[async_trait]
impl ApiClient for Client {
Expand Down
4 changes: 3 additions & 1 deletion cloudflare/src/framework/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ pub struct HttpApiClient {

/// Configuration for the API client. Allows users to customize its behaviour.
pub struct HttpApiClientConfig {
/// The maximum time limit for an API request. If a request takes longer than this, it will be cancelled.
/// The maximum time limit for an API request. If a request takes longer than this, it will be
/// cancelled.
/// Note: this configuration has no effect when the target is wasm32.
pub http_timeout: Duration,
/// A default set of HTTP headers which will be sent with each API request.
pub default_headers: http::HeaderMap,
Expand Down

0 comments on commit 37d52e1

Please sign in to comment.