Skip to content

Commit

Permalink
Moved to no-std-net
Browse files Browse the repository at this point in the history
  • Loading branch information
domenukk committed Apr 10, 2023
1 parent 315eb43 commit 6d622ab
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
with:
toolchain: ${{ matrix.rust }}
# Add toolchain for no_std tests
- run: rustup toolchain install nightly
- run: rustup target add aarch64-unknown-none
- run: cargo build --all-targets
# Run tests
Expand All @@ -50,7 +51,7 @@ jobs:
matrix.rust == 'nightly'
run: cargo test --test debugger_visualizer --features "url/serde,url/debugger_visualizer" -- --test-threads=1
- name: Test `no_std` support
run: cargo +nightly test --no-default-features --features=alloc
run: cargo test --no-default-features --features=alloc
- name: Build `aarch64-unknown-none` with `no_std`
run: cargo +nightly build -Zbuild-std=core,alloc --target aarch64-unknown-none -v --release --no-default-features --features=alloc

Expand Down
2 changes: 1 addition & 1 deletion data-url/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ alloc = []

[dev-dependencies]
tester = "0.9"
serde = {version = "1.0", features = ["derive"]}
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] }
serde_json = "1.0"

[lib]
Expand Down
2 changes: 1 addition & 1 deletion idna/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ name = "unit"
assert_matches = "1.3"
bencher = "0.1"
tester = "0.9"
serde_json = "1.0"
serde_json = { version = "1.0" }

[dependencies]
unicode-bidi = { version = "0.3.10", default-features = false, features = ["hardcoded-data"] }
Expand Down
3 changes: 1 addition & 2 deletions idna/tests/punycode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

use crate::test::TestFn;
use idna::punycode::{decode, encode_str};
use serde_json::map::Map;
use serde_json::Value;
use serde_json::{map::Map, Value};
use std::str::FromStr;

fn one_test(decoded: &str, encoded: &str) {
Expand Down
15 changes: 9 additions & 6 deletions url/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,23 @@ debugger_test = "0.1"
debugger_test_parser = "0.1"

[dependencies]
form_urlencoded = { version = "1.1.0", path = "../form_urlencoded", default-features = false }
idna = { version = "0.3.0", path = "../idna", default-features = false }
percent-encoding = { version = "2.2.0", path = "../percent_encoding", default-features = false }
serde = {version = "1.0", optional = true, features = ["derive"]}
form_urlencoded = { version = "1.1.0", path = "../form_urlencoded", default-features = false, features = ["alloc"] }
idna = { version = "0.3.0", path = "../idna", default-features = false, features = ["alloc"] }
percent-encoding = { version = "2.2.0", path = "../percent_encoding", default-features = false, features = ["alloc"] }
data-url = { version = "0.2.0", path = "../data-url", default-features = false, features = ["alloc"] }
serde = {version = "1.0", optional = true, default-features = false, features = ["alloc", "derive"]}
no-std-net = { version = "0.6.0", default-features = false }

[features]
default = ["std"]
std = ["idna/std", "percent-encoding/std", "form_urlencoded/std", "alloc"]
alloc = ["idna/alloc", "percent-encoding/alloc", "form_urlencoded/alloc"]
std = ["idna/std", "percent-encoding/std", "form_urlencoded/std", "no-std-net/std", "alloc"]
alloc = []
# UNSTABLE FEATURES (requires Rust nightly)
# Enable to use the #[debugger_visualizer] attribute.
debugger_visualizer = []
# Expose internal offsets of the URL.
expose_internals = []
serde = ["dep:serde", "no-std-net/serde"]

[[bench]]
name = "parse_url"
Expand Down
5 changes: 1 addition & 4 deletions url/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ use alloc::{
string::{String, ToString},
vec::Vec,
};
#[cfg(not(feature = "std"))]
use core::net::{Ipv4Addr, Ipv6Addr};
use core::{
cmp,
fmt::{self, Formatter},
};
#[cfg(feature = "std")]
use std::net::{Ipv4Addr, Ipv6Addr};
use no_std_net::{Ipv4Addr, Ipv6Addr};

use percent_encoding::{percent_decode, utf8_percent_encode, CONTROLS};
#[cfg(feature = "serde")]
Expand Down
7 changes: 2 additions & 5 deletions url/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ url = { version = "2", features = ["serde"] }
debugger_visualizer(natvis_file = "../../debug_metadata/url.natvis")
)]
#![no_std]
#![cfg_attr(not(feature = "std"), feature(ip_in_core))]

pub use form_urlencoded;

Expand All @@ -155,13 +154,11 @@ use core::convert::TryFrom;
use core::fmt::{self, Write};
use core::hash;
use core::mem;
#[cfg(not(feature = "std"))]
use core::net::IpAddr;
use core::ops::{Range, RangeFrom, RangeTo};
use core::str;
use no_std_net::IpAddr;
use percent_encoding::utf8_percent_encode;
#[cfg(feature = "std")]
use std::net::IpAddr;

#[cfg(feature = "std")]
use std::{
io,
Expand Down
4 changes: 2 additions & 2 deletions url/tests/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

//! Unit tests

use core::cell::{Cell, RefCell};
use no_std_net::{Ipv4Addr, Ipv6Addr};
use std::borrow::Cow;
use std::cell::{Cell, RefCell};
use std::net::{Ipv4Addr, Ipv6Addr};
#[cfg(feature = "std")]
use std::path::{Path, PathBuf};
use url::{form_urlencoded, Host, Origin, Url};
Expand Down

0 comments on commit 6d622ab

Please sign in to comment.