[package]
name = "pjson-rs"
version = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
rust-version = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
description = "Priority JSON Streaming Protocol - high-performance priority-based JSON streaming (requires nightly Rust)"
keywords = { workspace = true }
categories = { workspace = true }
readme = { workspace = true }
exclude = ["/target", "/benches", "/tests", "examples/*"]
publish = true
build = "build.rs"

[dependencies]
async-stream = { workspace = true, optional = true }
axum = { workspace = true, optional = true, features = ["ws"] }
metrics = { workspace = true, optional = true }
metrics-exporter-prometheus = { workspace = true, optional = true }
bitflags = { workspace = true }
brotli = { workspace = true, optional = true }

bytes = { workspace = true }
chrono = { workspace = true, features = ["serde"] }
crossbeam = { workspace = true }
dashmap = { workspace = true }
flate2 = { workspace = true, optional = true }
futures = { workspace = true, optional = true }
getrandom = { workspace = true, optional = true }
hmac = { workspace = true, optional = true }
jiter = { workspace = true, optional = true }
jsonwebtoken = { workspace = true, optional = true }
maplit = { workspace = true }
mimalloc = { workspace = true, optional = true }
once_cell = { workspace = true }
parking_lot = { workspace = true }
paste = { workspace = true }
pjson-rs-domain = { workspace = true }
rayon = { workspace = true }
regex = { workspace = true, optional = true }
reqwest = { workspace = true, features = ["json"], optional = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
sha2 = { workspace = true, optional = true }
smallvec = { workspace = true, features = ["serde", "union", "const_generics"] }
sonic-rs = { workspace = true }
subtle = { workspace = true, optional = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = [
    "rt-multi-thread",
    "sync",
    "time",
    "macros",
    "net",
    "parking_lot",
] }
tokio-tungstenite = { workspace = true, optional = true }
tower = { workspace = true, optional = true }
tower-http = { workspace = true, features = ["cors", "trace"], optional = true }
tracing = { workspace = true }
typed-arena = { workspace = true }
url = { workspace = true, optional = true }
uuid = { workspace = true, features = ["v4", "serde"] }
zstd = { workspace = true, optional = true }

[dev-dependencies]
serde_json = { workspace = true }
tokio = { workspace = true, features = ["test-util"] }
tokio-test = { workspace = true }

[features]
default = [
  "simd-auto",
  "schema-validation",
  "compression",
  "http-server",
  "http-client",
  "websocket-server",
  "websocket-client",
]

# SIMD features
simd-auto = []
simd-avx2 = []
simd-avx512 = ["sonic-rs/avx512"]
simd-neon = []
simd-sse42 = []

# Process-wide allocator (opt-in; registers MiMalloc as #[global_allocator] on non-wasm targets)
# Note: conflicts with any other crate in the binary that also declares #[global_allocator].
mimalloc = ["dep:mimalloc"]

# Optional features
compression = ["dep:brotli", "dep:flate2", "dep:zstd"]
partial-parse = ["dep:jiter"]
schema-validation = ["dep:regex"]

# Infrastructure features
http-client = ["dep:reqwest"]
http-server = [
    "dep:async-stream",
    "dep:axum",
    "dep:tower",
    "dep:tower-http",
    "dep:futures",
    "dep:subtle",
    "dep:hmac",
    "dep:sha2",
    "dep:getrandom",
]
http-auth-jwt = ["http-server", "dep:jsonwebtoken"]
metrics = ["http-server", "dep:metrics", "dep:metrics-exporter-prometheus"]
websocket-client = ["dep:tokio-tungstenite", "dep:url"]
websocket-server = ["http-server"]

[package.metadata.cargo-udeps.ignore]
normal = ["axum", "tower", "tower-http", "hyper", "futures", "sha2"]

[package.metadata.cargo-machete]
# mimalloc is referenced only via #[global_allocator] static; machete cannot detect this usage.
ignored = ["mimalloc"]

# Trusted publishing configuration for crates.io
[package.metadata.release.publishers.crates-io]
trusted-publishing = true
# GitHub Actions OIDC issuer for trusted publishing
# Repository: https://github.com/bug-ops/pjs
# Workflow: .github/workflows/release.yml
issuer = "https://token.actions.githubusercontent.com"
repository = "bug-ops/pjs"
workflow = "release.yml"

[[test]]
name = "websocket_security"
path = "tests/websocket_security.rs"
required-features = ["websocket-server"]

[[test]]
name = "websocket_wire_level"
path = "tests/websocket_wire_level.rs"
required-features = ["http-server", "websocket-client"]

[[example]]
name = "simple_priority_demo"
required-features = []

[[example]]
name = "zero_copy_demo"
required-features = []

[[example]]
name = "compression_demo"
required-features = ["compression"]

[[example]]
name = "schema_validation_demo"
required-features = ["schema-validation"]

[[example]]
name = "gat_performance_showcase"
required-features = []

[[example]]
name = "object_pool_performance"
required-features = []
