Skip to content

Commit

Permalink
release 0.6.0 for bevy 0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
foxzool committed Jul 5, 2024
1 parent f2394e4 commit 610ea89
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keywords = ["bevy", "http", "plugin", "wasm"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = { version = "0.14.0-rc.3", default-features = false, features = ["multi_threaded"] }
bevy = { version = "0.14.0", default-features = false, features = ["multi_threaded"] }
crossbeam-channel = "0.5.11"
ehttp = { version = "0.5.0", features = ["native-async", "json"] }
serde = { version = "1.0", features = ["derive"] }
Expand Down
1 change: 1 addition & 0 deletions examples/ipinfo.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use bevy::{prelude::*, time::common_conditions::on_timer};

use bevy_http_client::prelude::*;

fn main() {
Expand Down
61 changes: 38 additions & 23 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#![doc = include_str!("../README.md")]

use bevy::ecs::world::CommandQueue;
use bevy::prelude::*;
use bevy::tasks::IoTaskPool;
use bevy::{ecs::world::CommandQueue, prelude::*, tasks::IoTaskPool};
use crossbeam_channel::Receiver;
use ehttp::{Headers, Request, Response};

use crate::prelude::TypedRequest;
use ehttp::{Headers, Request, Response};

pub mod prelude;
mod typed;
Expand Down Expand Up @@ -133,7 +131,8 @@ impl HttpClient {
///
/// # Arguments
///
/// * `url` - A value that can be converted into a string. This is the URL to which the HTTP request will be sent.
/// * `url` - A value that can be converted into a string. This is the URL to which the HTTP
/// request will be sent.
///
/// # Returns
///
Expand All @@ -154,7 +153,8 @@ impl HttpClient {
///
/// # Arguments
///
/// * `url` - A value that can be converted into a string. This is the URL to which the HTTP request will be sent.
/// * `url` - A value that can be converted into a string. This is the URL to which the HTTP
/// request will be sent.
///
/// # Returns
///
Expand All @@ -175,7 +175,8 @@ impl HttpClient {
///
/// # Arguments
///
/// * `url` - A value that can be converted into a string. This is the URL to which the HTTP request will be sent.
/// * `url` - A value that can be converted into a string. This is the URL to which the HTTP
/// request will be sent.
///
/// # Returns
///
Expand All @@ -196,7 +197,8 @@ impl HttpClient {
///
/// # Arguments
///
/// * `url` - A value that can be converted into a string. This is the URL to which the HTTP request will be sent.
/// * `url` - A value that can be converted into a string. This is the URL to which the HTTP
/// request will be sent.
///
/// # Returns
///
Expand All @@ -217,7 +219,8 @@ impl HttpClient {
///
/// # Arguments
///
/// * `url` - A value that can be converted into a string. This is the URL to which the HTTP request will be sent.
/// * `url` - A value that can be converted into a string. This is the URL to which the HTTP
/// request will be sent.
///
/// # Returns
///
Expand All @@ -238,7 +241,8 @@ impl HttpClient {
///
/// # Arguments
///
/// * `url` - A value that can be converted into a string. This is the URL to which the HTTP request will be sent.
/// * `url` - A value that can be converted into a string. This is the URL to which the HTTP
/// request will be sent.
///
/// # Returns
///
Expand All @@ -259,7 +263,8 @@ impl HttpClient {
///
/// # Arguments
///
/// * `headers` - A slice of tuples where each tuple represents a header. The first element of the tuple is the header name and the second element is the header value.
/// * `headers` - A slice of tuples where each tuple represents a header. The first element of
/// the tuple is the header name and the second element is the header value.
///
/// # Returns
///
Expand All @@ -281,7 +286,8 @@ impl HttpClient {
///
/// # Arguments
///
/// * `body` - A reference to any type that implements the `serde::Serialize` trait. This is the data that will be serialized to JSON and set as the body of the HTTP request.
/// * `body` - A reference to any type that implements the `serde::Serialize` trait. This is the
/// data that will be serialized to JSON and set as the body of the HTTP request.
///
/// # Returns
///
Expand Down Expand Up @@ -311,12 +317,14 @@ impl HttpClient {
self
}

/// This method is used to set the properties of the `HttpClient` instance using an `Request` instance.
/// This version of the method is used when the target architecture is not `wasm32`.
/// This method is used to set the properties of the `HttpClient` instance using an `Request`
/// instance. This version of the method is used when the target architecture is not
/// `wasm32`.
///
/// # Arguments
///
/// * `request` - An instance of `Request` which includes the HTTP method, URL, body, and headers.
/// * `request` - An instance of `Request` which includes the HTTP method, URL, body, and
/// headers.
///
/// # Returns
///
Expand Down Expand Up @@ -345,7 +353,8 @@ impl HttpClient {

/// Associates an `Entity` with the `HttpClient`.
///
/// This method is used to associate an `Entity` with the `HttpClient`. This can be useful when you want to track which entity initiated the HTTP request.
/// This method is used to associate an `Entity` with the `HttpClient`. This can be useful when
/// you want to track which entity initiated the HTTP request.
///
/// # Parameters
///
Expand All @@ -366,12 +375,13 @@ impl HttpClient {
self
}

/// This method is used to set the properties of the `HttpClient` instance using an `Request` instance.
/// This version of the method is used when the target architecture is `wasm32`.
/// This method is used to set the properties of the `HttpClient` instance using an `Request`
/// instance. This version of the method is used when the target architecture is `wasm32`.
///
/// # Arguments
///
/// * `request` - An instance of `Request` which includes the HTTP method, URL, body, headers, and mode.
/// * `request` - An instance of `Request` which includes the HTTP method, URL, body, headers,
/// and mode.
///
/// # Returns
///
Expand Down Expand Up @@ -402,15 +412,19 @@ impl HttpClient {

/// Builds an `HttpRequest` from the `HttpClient` instance.
///
/// This method is used to construct an `HttpRequest` from the current state of the `HttpClient` instance. The resulting `HttpRequest` includes the HTTP method, URL, body, headers, and mode (only available on wasm builds).
/// This method is used to construct an `HttpRequest` from the current state of the `HttpClient`
/// instance. The resulting `HttpRequest` includes the HTTP method, URL, body, headers, and mode
/// (only available on wasm builds).
///
/// # Returns
///
/// An `HttpRequest` instance which includes the HTTP method, URL, body, headers, and mode (only available on wasm builds).
/// An `HttpRequest` instance which includes the HTTP method, URL, body, headers, and mode (only
/// available on wasm builds).
///
/// # Panics
///
/// This method will panic if the HTTP method, URL, or headers are not set in the `HttpClient` instance.
/// This method will panic if the HTTP method, URL, or headers are not set in the `HttpClient`
/// instance.
///
/// # Examples
///
Expand All @@ -423,7 +437,8 @@ impl HttpClient {
///
/// # Note
///
/// This method consumes the `HttpClient` instance, meaning it can only be called once per instance.
/// This method consumes the `HttpClient` instance, meaning it can only be called once per
/// instance.
pub fn build(self) -> HttpRequest {
HttpRequest {
from_entity: self.from_entity,
Expand Down
2 changes: 1 addition & 1 deletion src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub use super::typed::{HttpTypedRequestTrait, TypedRequest, TypedResponse, TypedResponseError};
pub use super::{
typed::{HttpTypedRequestTrait, TypedRequest, TypedResponse, TypedResponseError},
HttpClient, HttpClientPlugin, HttpClientSetting, HttpRequest, HttpResponse, HttpResponseError,
RequestTask,
};
31 changes: 21 additions & 10 deletions src/typed.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use std::marker::PhantomData;

use bevy::app::{App, PreUpdate};
use bevy::ecs::world::CommandQueue;
use bevy::hierarchy::DespawnRecursiveExt;
use bevy::prelude::{Commands, Deref, Entity, Event, EventReader, Events, ResMut, World};
use bevy::tasks::IoTaskPool;
use bevy::{
app::{App, PreUpdate},
ecs::world::CommandQueue,
hierarchy::DespawnRecursiveExt,
prelude::{Commands, Deref, Entity, Event, EventReader, Events, ResMut, World},
tasks::IoTaskPool,
};
use ehttp::{Request, Response};
use serde::Deserialize;

Expand All @@ -13,7 +15,10 @@ use crate::{HttpClientSetting, RequestTask};
pub trait HttpTypedRequestTrait {
/// Registers a new request type `T` to the application.
///
/// This method is used to register a new request type `T` to the application. The request type `T` must implement the `Deserialize` trait, and be `Send` and `Sync`. This is necessary for the request type to be safely shared across threads and for it to be deserialized from a HTTP response.
/// This method is used to register a new request type `T` to the application. The request type
/// `T` must implement the `Deserialize` trait, and be `Send` and `Sync`. This is necessary for
/// the request type to be safely shared across threads and for it to be deserialized from a
/// HTTP response.
///
/// # Type Parameters
///
Expand Down Expand Up @@ -47,11 +52,14 @@ impl HttpTypedRequestTrait for App {

/// A struct that represents a typed HTTP request.
///
/// This struct is used to represent a typed HTTP request. The type `T` is the type of the data that is expected to be returned by the HTTP request. The `Request` is the actual HTTP request that will be sent.
/// This struct is used to represent a typed HTTP request. The type `T` is the type of the data that
/// is expected to be returned by the HTTP request. The `Request` is the actual HTTP request that
/// will be sent.
///
/// # Type Parameters
///
/// * `T`: The type of the data that is expected to be returned by the HTTP request. This type must implement `Deserialize`.
/// * `T`: The type of the data that is expected to be returned by the HTTP request. This type must
/// implement `Deserialize`.
///
/// # Fields
///
Expand Down Expand Up @@ -86,11 +94,14 @@ impl<T: for<'a> serde::Deserialize<'a>> TypedRequest<T> {

/// A struct that represents a typed HTTP response.
///
/// This struct is used to represent a typed HTTP response. The type `T` is the type of the data that is expected to be contained in the HTTP response. The `inner` field is the actual data contained in the HTTP response.
/// This struct is used to represent a typed HTTP response. The type `T` is the type of the data
/// that is expected to be contained in the HTTP response. The `inner` field is the actual data
/// contained in the HTTP response.
///
/// # Type Parameters
///
/// * `T`: The type of the data that is expected to be contained in the HTTP response. This type must implement `Deserialize`.
/// * `T`: The type of the data that is expected to be contained in the HTTP response. This type
/// must implement `Deserialize`.
///
/// # Fields
///
Expand Down

0 comments on commit 610ea89

Please sign in to comment.