zenwave 0.3.0

Write once, fetch anywhere
Documentation
[package]
name = "zenwave"
version = "0.3.0"
edition = "2024"
authors = ["Lexo Liu<me@lexo.cool>"]
repository = "https://github.com/zen-rs/zenwave"
description = "Write once, fetch anywhere"
license = "MIT"
keywords = ["http", "client", "wasm", "fetch", "websocket"]
categories = ["network-programming", "web-programming::http-client", "wasm"]

[dependencies]
http-kit = "0.4"
serde = { version = "1.0", default-features = false, features = ["derive"]}
serde_json = "1.0"
base64 = "0.22"
url = "2.5"
futures-util = { version = "0.3", features = ["io", "sink"] }
futures-channel = "0.3"
thiserror = "2.0"
futures-io = "0.3"
async-lock = "3.4"
anyhow = "1.0.100"
js-sys = "0.3.82"
http = "1.3.1"
httpdate = "1.0"

[dev-dependencies]
serde_json = "1.0"
tempfile = "3.13"
async-std = { version = "1.13", features = ["attributes"] }
tiny_http = "0.12"

[features]
# Default: hyper backend with rustls (aws-lc-rs).
# - Pure Rust TLS, works on all platforms with proper toolchain
# - For Android: requires NDK setup (set ANDROID_NDK env var)
# - For Apple: consider using `hyper-native-tls` for better performance
# - For wasm32: built-in web backend using Fetch API (automatic)
default = ["default-backend", "ws"]

# Default backend uses rustls with aws-lc-rs crypto provider.
default-backend = ["hyper-backend", "rustls"]

# Explicit backend selections (native platforms only).
# On wasm32, using any of these will result in a compile error - the web backend
# is always used automatically.
#
# hyper + native-tls: Uses the platform's native TLS (OpenSSL, SChannel, or Security.framework)
hyper-native-tls = ["hyper-backend", "native-tls"]
# hyper + rustls: Uses rustls with system certificates
hyper-rustls = ["hyper-backend", "rustls"]
# Apple's NSURLSession (macOS/iOS only)
apple-backend = []
# libcurl backend with proxy support
curl-backend = ["dep:curl", "dep:blocking", "proxy"]
# Websocket support (async-tungstenite on native, web-sys WebSocket on wasm)
# TLS for WebSocket follows the selected TLS backend (native-tls or rustls)
ws = ["dep:async-tungstenite"]

# TLS implementations (internal features, prefer using hyper-native-tls or hyper-rustls)
# native-tls: Uses platform TLS (OpenSSL on Linux/Android, Security.framework on Apple, SChannel on Windows)
native-tls = ["dep:async-native-tls", "dep:native-tls", "async-tungstenite?/async-native-tls"]
# rustls: Pure Rust TLS with aws-lc-rs crypto provider (good for cross-compilation including Android)
# Note: WebSocket TLS with rustls requires manual TLS wrapping (async-tls is stuck on old rustls)
rustls = [
    "dep:futures-rustls",
    "dep:rustls",
    "dep:webpki-roots",
    "dep:rustls-native-certs",
]

# Core hyper backend (internal)
hyper-backend = [
    "dep:hyper",
    "dep:http-body-util",
]

# Proxy support for hyper-backend and curl-backend (native platforms only).
proxy = []

[target.'cfg(target_arch = "wasm32")'.dependencies]
web-sys = { version = "0.3", features = [
    "Window",
    "Request",
    "RequestInit",
    "Headers",
    "ReadableStream",
    "Response",
    "WebSocket",
    "MessageEvent",
    "CloseEvent",
    "ErrorEvent",
    "BinaryType",
] }
wasm-streams = "0.4.2"
wasm-bindgen = "0.2.105"
wasm-bindgen-futures = "0.4.55"
gloo-timers = { version = "0.3", features = ["futures"] }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
async-io = "2.4"
async-net = "2.0"
blocking = { version = "1.6", optional = true }
curl = { version = "0.4", optional = true }
executor-core = { version = "0.7.0" }
hyper = { version = "1.8", default-features = false, features = ["client", "http1"], optional = true }
http-body-util = { version = "0.1.3", optional = true }
async-native-tls = { version = "0.5.0", optional = true, default-features = false, features = ["runtime-async-std"] }
futures-rustls = { version = "0.26", optional = true }
rustls = { version = "0.23", optional = true, default-features = false, features = ["std", "tls12"] }
rustls-native-certs = { version = "0.8", optional = true }
native-tls = { version = "0.2", optional = true }
webpki-roots = { version = "1.0", optional = true }
async-tungstenite = { version = "0.32.0", default-features = false, features = ["async-std-runtime"], optional = true }
async-fs = { version = "2.2.0", default-features = false }
dirs = "6.0"
once_cell = "1.19"
time = "0.3"
tower-service = "0.3"

[target.'cfg(target_vendor = "apple")'.dependencies]
block = "0.1"
objc = "0.2"


[[example]]
name = "basic_get"
required-features = ["hyper-backend"]

[[example]]
name = "custom_client"
required-features = ["hyper-backend"]

[[example]]
name = "websocket_echo"
required-features = ["hyper-backend", "ws"]

[lints]
rust.missing_docs = "warn"
rust.missing_debug_implementations = "warn"
rust.unexpected_cfgs = "allow"
clippy.all = "warn"
clippy.style = "warn"
clippy.correctness = "warn"
clippy.complexity = "warn"
clippy.suspicious = "warn"
clippy.perf = "warn"
clippy.pedantic = "warn"
clippy.nursery = "warn"
clippy.cargo = "allow"