Skip to content

Commit

Permalink
Updated examples - enabled oxhttp, using latest mio pr
Browse files Browse the repository at this point in the history
  • Loading branch information
nikarh committed Oct 18, 2023
1 parent 1b904d4 commit 0ab8ad5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 41 deletions.
37 changes: 12 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ opt-level = 2
[patch.crates-io]
mio = { git = "https://github.com/vita-rust/mio", branch = "vita" }
tokio = { git = "https://github.com/vita-rust/tokio", branch = "vita" }
socket2053 = { git = "https://github.com/vita-rust/socket2", branch = "v0.5.3-vita", package = "socket2", version = "0.5.3" }
socket2049 = { git = "https://github.com/vita-rust/socket2", branch = "v0.4.9-vita", package = "socket2", version = "0.4.9" }

socket2053 = { git = "https://github.com/rust-lang/socket2", branch = "master", package = "socket2", version = "0.5.3" }
socket2049 = { git = "https://github.com/rust-lang/socket2", branch = "v0.4.x", package = "socket2", version = "0.4.9" }

# Required for rustls
ring = { git = "https://github.com/vita-rust/ring", branch = "v0.16.20-vita" }
7 changes: 3 additions & 4 deletions crates/2-http-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ repository = "https://github.com/vita-rust/examples"
homepage = "https://github.com/vita-rust/examples/crates/2-http-client"

[features]
default = ["rustls", "shims"]
shims = ["vita-newlib-shims"]
default = ["rustls"]
rustls = ["reqwest/rustls-tls", "oxhttp/rustls"]
openssl = ["reqwest/native-tls"]

Expand All @@ -18,9 +17,9 @@ anyhow = "1.0"
libc = "0.2.149"
reqwest = { version = "0.11", default-features = false, features = ["json"] }
tokio = { version = "1", features = ["macros", "rt", "net"] }
oxhttp = { version = "0.1.7", features = ["rustls"] }
oxhttp = { version = "0.2.0-alpha.1", features = ["rustls", "webpki-roots"] }
ureq = { version = "2.7.1", default-features = false, features = ["gzip"] }
vita-newlib-shims = { version = "0.2", optional = true }
vita-newlib-shims = { version = "0.3", features = ["fcntl"] }

[package.metadata.vita]
title_id = "RUSTTEST2"
Expand Down
12 changes: 7 additions & 5 deletions crates/2-http-client/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(all(target_os = "vita", feature = "shims"))]
#[cfg(all(target_os = "vita"))]
use vita_newlib_shims as _;

use oxhttp::{
Expand All @@ -17,6 +17,7 @@ fn main() -> anyhow::Result<()> {
.enable_all()
.build()?
.block_on(async {
println!(">>>");
println!(">>> Trying oxhttp");
let client = Client::new();
let body = client
Expand All @@ -25,11 +26,12 @@ fn main() -> anyhow::Result<()> {
.to_string()?;
println!(">>> oxhttp response: {body}");

// Requires std to depend on the latest libc
// println!(">>> Trying ureq");
// let body = ureq::get("http://example.com").call()?;
// println!(">>> Ureq response: {:?}", body);
println!(">>>");
println!(">>> Trying ureq");
let res = ureq::get("http://example.com").call()?.into_string()?;
println!(">>> Ureq response: {:?}", res);

println!(">>>");
println!(">>> Trying reqwest");
let body = reqwest::get("https://example.com").await?.text().await?;
println!(">>> Reqwest response: {:#?}", body);
Expand Down
7 changes: 2 additions & 5 deletions crates/3-sdl/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,13 @@ pub fn main() -> Result<(), String> {
let available = controller_subsystem
.num_joysticks()
.map_err(|e| format!("can't enumerate joysticks: {}", e))?;
let controller = (0..available)
let _controller = (0..available)
.find_map(|id| {
if !controller_subsystem.is_game_controller(id) {
return None;
}

match controller_subsystem.open(id) {
Ok(c) => Some(c),
Err(e) => None,
}
controller_subsystem.open(id).ok()
})
.expect("Couldn't open any controller");

Expand Down

0 comments on commit 0ab8ad5

Please sign in to comment.