Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ bytes = "1.6.0"
futures-lite = "2.3.0"

[dependencies.bevy]
version = "0.17"
version = "0.18"
# git = "https://github.com/bevyengine/bevy"
default-features = false

Expand Down
18 changes: 7 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl Plugin for ReqwestPlugin {
.url
.clone();

if let None = world.get::<Name>(ctx.entity) {
if world.get::<Name>(ctx.entity).is_none() {
let mut commands = world.commands();
let mut entity = commands.get_entity(ctx.entity).unwrap();
entity.insert(Name::new(format!("http: {url}")));
Expand Down Expand Up @@ -228,7 +228,7 @@ pub struct BevyReqwest<'w, 's> {
impl<'w, 's> BevyReqwest<'w, 's> {
/// Starts sending and processing the supplied [`reqwest::Request`]
/// then use the [`BevyReqwestBuilder`] to add handlers for responses and errors
pub fn send(&mut self, req: reqwest::Request) -> BevyReqwestBuilder {
pub fn send(&mut self, req: reqwest::Request) -> BevyReqwestBuilder<'_> {
let inflight = self.create_inflight_task(req);
BevyReqwestBuilder(self.commands.spawn((inflight, DespawnReqwestEntity)))
}
Expand All @@ -239,7 +239,7 @@ impl<'w, 's> BevyReqwest<'w, 's> {
&mut self,
entity: Entity,
req: reqwest::Request,
) -> Result<BevyReqwestBuilder, Box<dyn std::error::Error>> {
) -> Result<BevyReqwestBuilder<'_>, Box<dyn std::error::Error>> {
let inflight = self.create_inflight_task(req);
let mut ec = self.commands.get_entity(entity)?;
info!("inserting request on entity: {:?}", entity);
Expand Down Expand Up @@ -362,17 +362,13 @@ pub struct ReqwestInflight {
impl ReqwestInflight {
fn poll(&mut self) -> Option<Resp> {
#[cfg(target_family = "wasm")]
if let Ok(v) = self.res.try_recv() {
Some(v)
} else {
None
{
self.res.try_recv().ok()
}

#[cfg(not(target_family = "wasm"))]
if let Some(v) = future::block_on(future::poll_once(&mut self.res)) {
Some(v)
} else {
None
{
future::block_on(future::poll_once(&mut self.res)).map(|v| v)
}
}

Expand Down