ruststream 0.3.0

Async messaging framework for Rust: broker-agnostic traits, router, codecs, and a conformance harness for broker authors.
Documentation
[workspace]
members = ["crates/ruststream-macros"]

[workspace.package]
version = "0.3.0"
edition = "2024"
rust-version = "1.85"
license = "Apache-2.0"
repository = "https://github.com/powersemmi/ruststream"
authors = ["RustStream contributors"]

# The `nats_*` examples depend on `ruststream-nats`, which depends on `ruststream` from crates.io.
# Point that back at this in-tree copy so the example and the broker share one `ruststream` instead
# of pulling a second, incompatible one. cargo strips `[patch]` on publish, so this is dev-only.
[patch.crates-io]
ruststream = { path = "." }

[[bin]]
name = "ruststream"
path = "src/bin/ruststream/main.rs"
required-features = ["cli"]

[[example]]
name = "macro_app"
required-features = ["macros", "memory"]

[[example]]
name = "routed_service"
path = "examples/routed_service/main.rs"
required-features = ["macros", "memory", "json"]

[[example]]
name = "quickstart"
required-features = ["macros", "memory", "json"]

[[example]]
name = "tutorial"
path = "examples/tutorial/main.rs"
required-features = ["macros", "memory", "json"]

[[example]]
name = "subscribers"
required-features = ["macros", "memory", "json"]

[[example]]
name = "publishing"
required-features = ["macros", "memory", "json"]

[[example]]
name = "routing"
required-features = ["macros", "memory", "json"]

[[example]]
name = "codecs"
required-features = ["macros", "memory", "json", "cbor"]

[[example]]
name = "middleware"
required-features = ["macros", "memory", "json"]

[[example]]
name = "middleware_app_scope"
required-features = ["macros", "memory", "json"]

[[example]]
name = "middleware_router_scope"
required-features = ["macros", "memory", "json"]

[[example]]
name = "context"
required-features = ["macros", "memory", "json"]

[[example]]
name = "lifespan"
required-features = ["macros", "memory", "json"]

[[example]]
name = "asyncapi_http"
required-features = ["macros", "memory", "asyncapi"]

[[example]]
name = "metrics_http"
required-features = ["macros", "memory", "metrics"]

[[example]]
name = "logging"
required-features = ["macros", "memory", "json", "logging"]

[[example]]
name = "logging_middleware"
required-features = ["macros", "memory", "json", "logging"]

# The nats_* examples and the doc_testing_nats test depend on ruststream-nats, which is still on
# ruststream 0.2 and cannot compile against this 0.3 tree. autoexamples/autotests are off so the
# files stay in place (the docs embed snippets from them) without being built. Re-enable these
# entries and the ruststream-nats dev-dependency once ruststream-nats 0.3 is published.
#
# [[example]]
# name = "nats_core"
# required-features = ["macros", "json"]
#
# [[example]]
# name = "nats_jetstream"
# required-features = ["macros", "json"]
#
# [[example]]
# name = "nats_request_reply"
# required-features = ["macros"]

[[test]]
name = "app_dispatch"
required-features = ["memory", "json"]

[[test]]
name = "asyncapi"
required-features = ["asyncapi", "memory", "macros"]

[[test]]
name = "conformance_self"
required-features = ["conformance", "memory"]

[[test]]
name = "doc_testing_memory"
required-features = ["memory", "macros", "json"]

[[test]]
name = "macro_subscriber"
required-features = ["macros", "memory", "json"]

[[test]]
name = "metrics"
required-features = ["metrics", "memory", "json"]

# [[test]]
# name = "doc_testing_nats"
# required-features = ["macros", "json"]

[package]
name = "ruststream"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true
authors.workspace = true
description = "Async messaging framework for Rust: broker-agnostic traits, router, codecs, and a conformance harness for broker authors."
readme = "README.md"
keywords = ["messaging", "async", "broker", "faststream", "nats"]
categories = ["asynchronous", "network-programming"]
# Examples and tests are listed explicitly so the parked nats_* targets (see the commented-out
# entries above) are not auto-discovered while ruststream-nats is still on 0.2.
autoexamples = false
autotests = false

[features]
default = ["json"]
memory = []
conformance = []
json = ["dep:serde_json"]
msgpack = ["dep:rmp-serde"]
cbor = ["dep:ciborium"]
macros = ["dep:ruststream-macros"]
asyncapi = ["json", "dep:schemars", "dep:serde_norway"]
metrics = ["dep:prometheus"]
logging = ["dep:tracing-subscriber"]
cli = ["dep:clap", "dep:anyhow"]

[dependencies]
bytes = "1"
futures = "0.3"
serde = { version = "1", features = ["derive"] }
thiserror = "2"

tokio = { version = "1", features = ["rt-multi-thread", "macros", "sync", "time", "signal"] }
tokio-util = { version = "0.7", features = ["rt"] }
tracing = "0.1"

ruststream-macros = { version = "0.3.0", path = "crates/ruststream-macros", optional = true }
tracing-subscriber = { version = "0.3", features = ["env-filter"], optional = true }
serde_json = { version = "1", optional = true }
rmp-serde = { version = "1", optional = true }
ciborium = { version = "0.2", optional = true }
prometheus = { version = "0.14", default-features = false, optional = true }
schemars = { version = "1", optional = true }
serde_norway = { version = "0.9", optional = true }
clap = { version = "4", features = ["derive"], optional = true }
anyhow = { version = "1", optional = true }

[dev-dependencies]
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tokio = { version = "1", features = ["rt-multi-thread", "macros", "sync", "time", "net"] }
tempfile = "3"
axum = "0.8"
# `testing` pulls the in-memory NATS test broker used by tests/doc_testing_nats.rs (the snippet
# source for the testing guide). Parked until ruststream-nats 0.3 is published; see the note on
# the nats_* example entries.
# ruststream-nats = { version = "0.2", features = ["testing"] }

[lints.rust]
unsafe_op_in_unsafe_fn = "deny"
unreachable_pub = "deny"
missing_docs = "deny"
missing_debug_implementations = "warn"
unused_qualifications = "warn"

[lints.clippy]
correctness = { level = "deny", priority = -1 }
suspicious = { level = "deny", priority = -1 }
perf = { level = "deny", priority = -1 }
pedantic = { level = "warn", priority = -1 }
nursery = { level = "warn", priority = -1 }
cargo = { level = "warn", priority = -1 }
module_name_repetitions = "allow"
missing_const_for_fn = "allow"
multiple_crate_versions = "allow"
redundant_pub_crate = "allow"