artifact = "rust-library" and [features] whose roots are modules or pub items (blocks #928)Open and answer this issue on GitHub.
ready · opened 2026-10-29 · updated 2026-10-29 · 0 comments
The yaml package (#928) ships to Rust users as one crate, nikaia-yaml, with the features serde (default), tree and stream. Its parts:
nikaia-yaml is the hand-written serde_yaml facade. It depends on a crate generated from the Nikaia package, an implementation detail like serde_derive.Today a package can only become a program or a C library (artifact = "c-library"). A C library loses the Rust types and zero-copy, and a package cannot say which of its parts a Rust user may switch off.
1. artifact = "rust-library". The package’s lowered Rust is written as an ordinary library crate with a public API. It depends on nikaia-std and is usable as a path dependency, and published once nikaia-std is.
2. [features] in nikaia.toml:
[features]
default = ["serde"]
tree = ["yaml::tree"] # a module: all its pub items
stream = ["yaml::stream"]
serde = ["yaml::serde"]
# a single pub item is a root too: "yaml::tree::Value"
pub items, or a single pub item such as a function or a type.pub item in no feature is always present (the core).yaml::serde reaches yaml::tree, then serde ⇒ tree, recorded in the ledger and written into the generated Cargo.toml.stream with a reader gets its streaming version only under stream. This is the per-grammar or per-entry switch requested from winnow-grammar.#[cfg] in the code. A feature decides only whether something is there, never how it behaves, so features are additive by construction.[features], everything public is exported, as today.rust-library and on the bindings (nikaia bind). A Nikaia program using the package needs none, because the compiler already emits only what the program uses.artifact, [features], the checks), with its NK codes.artifact = "rust-library": write the lowered package as a crate (lib target, public API, nikaia-std dependency). Test: a small package used from a Rust crate in the repository.[features]: roots, reachability, derived implications and optional dependencies, #[cfg(feature)] written into the lowered crate, the generated Cargo.toml, and the check of every feature alone and all together. Test: a package with a module root, an item root, an implication and an optional dependency.nikaia bind (a binding without the parts that are switched off).The commit that builds the last step says Fixes #N.