-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Description
In the latest release, the mode field was added to ehttp::Request on native targets as well (likely to unify the API). However, the ehttp::Mode enum itself seems to still be gated behind #[cfg(target_arch = "wasm32")].
As a result, it is currently impossible to construct an ehttp::Request manually or specify the mode on non-WASM targets, because ehttp::Mode cannot be imported.
Reproduction Code
Trying to compile the following code on a native target (e.g., Linux/macOS/Windows) results in an error:
impl LoginCredentials {
fn login_request(&self, frame: &mut eframe::Frame) -> ehttp::Request {
ehttp::Request {
method: HttpMethod::Post.into(),
url: get_url(Path::Token, frame),
body: format!(
"&username={}&password={}",
self.username, self.password,
)
.into(),
headers: ehttp::Headers::new(&[
("Accept", ContentType::ApplicationJson.as_str()),
(
"Content-Type",
ContentType::ApplicationXWwwFormUrlencoded.as_str(),
),
]),
#[cfg(target_arch = "wasm32")]
mode: ehttp::Mode::default(),
timeout: None,
}
}
}Relevant Code Location
It seems the visibility of the module or the enum definition needs to be updated. I believe the issue is located here where types might be conditionally compiled or the Mode enum inside it is restricted: https://docs.rs/ehttp/latest/src/ehttp/lib.rs.html#80
Expected Behavior
ehttp::Mode should be available on all targets (Native and WASM) since ehttp::Request now requires it regardless of the architecture.
Environment:
-
ehttp version: 0.6.0 -
Compile target: Native & WASM32
Images