From f857137f074bccaa956b606448afa0a8ed8bb51d Mon Sep 17 00:00:00 2001 From: Brandon Ros Date: Tue, 26 Nov 2024 18:21:42 -0500 Subject: [PATCH 1/2] use web_time --- Cargo.lock | 81 +++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/config.rs | 2 +- src/request.rs | 2 +- src/unversioned/transport/time.rs | 6 +-- 5 files changed, 87 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0dd9fd8a..352eba77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -141,6 +141,12 @@ dependencies = [ "alloc-stdlib", ] +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + [[package]] name = "byteorder" version = "1.5.0" @@ -598,6 +604,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" +[[package]] +name = "js-sys" +version = "0.3.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "libc" version = "0.2.164" @@ -1229,6 +1244,7 @@ dependencies = [ "ureq-proto", "url", "utf-8", + "web-time", "webpki-root-certs", "webpki-roots", ] @@ -1308,6 +1324,71 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2 1.0.92", + "quote 1.0.37", + "syn 2.0.89", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +dependencies = [ + "quote 1.0.37", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +dependencies = [ + "proc-macro2 1.0.92", + "quote 1.0.37", + "syn 2.0.89", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webpki-root-certs" version = "0.26.7" diff --git a/Cargo.toml b/Cargo.toml index 8127335c..916043b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,7 @@ log = "0.4.22" once_cell = "1.19.0" utf-8 = "0.7.6" percent-encoding = "2.3.1" +web-time = "1.1.0" # These are used regardless of TLS implementation. rustls-pemfile = { version = "2.1.2", optional = true, default-features = false, features = ["std"] } diff --git a/src/config.rs b/src/config.rs index cba6e2b1..8692421a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -3,7 +3,7 @@ use std::fmt; use std::net::SocketAddr; use std::sync::Arc; -use std::time::Duration; +use web_time::Duration; use http::Uri; diff --git a/src/request.rs b/src/request.rs index 285bee7e..40b6e4cf 100644 --- a/src/request.rs +++ b/src/request.rs @@ -519,7 +519,7 @@ impl fmt::Debug for RequestBuilder { #[cfg(test)] mod test { - use std::time::Duration; + use web_time::Duration; use crate::get; use crate::test::init_test_log; diff --git a/src/unversioned/transport/time.rs b/src/unversioned/transport/time.rs index 21705fa8..0fdd8392 100644 --- a/src/unversioned/transport/time.rs +++ b/src/unversioned/transport/time.rs @@ -2,7 +2,7 @@ use std::cmp::Ordering; use std::ops::{Add, Deref}; -use std::time; +use web_time as time; /// Wrapper for [`std::time::Instant`] that provides additional time points in the past or future #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -128,8 +128,8 @@ impl Ord for Duration { } } -impl From for Duration { - fn from(value: std::time::Duration) -> Self { +impl From for Duration { + fn from(value: time::Duration) -> Self { Self::Exact(value) } } From d4a33236ab1d338fb010e36a7a092a127e3c222a Mon Sep 17 00:00:00 2001 From: Brandon Ros Date: Fri, 29 Nov 2024 13:09:30 -0500 Subject: [PATCH 2/2] use ureq-proto no-std --- Cargo.lock | 3 +-- Cargo.toml | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 352eba77..08621fb2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1252,8 +1252,7 @@ dependencies = [ [[package]] name = "ureq-proto" version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcec9cbfbf05a7feef00db0295c6183f468635c7adb12a31e941f3660b071bff" +source = "git+https://github.com/algesten/ureq-proto.git?rev=baf0cd408bdcb08be481008bc2b688c0fa984ecc#baf0cd408bdcb08be481008bc2b688c0fa984ecc" dependencies = [ "http", "httparse", diff --git a/Cargo.toml b/Cargo.toml index 916043b6..53a37a40 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,8 +38,8 @@ _test = [] [dependencies] base64 = "0.22.1" -ureq-proto = "0.2.0" -# ureq-proto = { path = "../ureq-proto" } +#ureq-proto = "0.2.0" +ureq-proto = { git = "https://github.com/algesten/ureq-proto.git", rev = "baf0cd408bdcb08be481008bc2b688c0fa984ecc", default-features = false } log = "0.4.22" once_cell = "1.19.0" utf-8 = "0.7.6"