Imported from pouriya/tanzim (
crates/tanzim/src/AGENTS.md). Install upstream withnpx skills add pouriya/tanzim --skill src. Copyright stays with the author.
tanzim/src
Facade crate. The crate root exposes only two types — Config and Source — everything else is a
per-concern module.
lib.rs— module declarations;pub use config::{Config, ConfigBuilder, ConfigStages, Sources, Plan, BuilderState};andpub use source::Source;logging.rs—is_debug_level_enabled!/is_trace_level_enabled!macros
Stage modules (glob re-export of the backing crate, plus facade-owned types)
loader.rs—pub use tanzim_load::*;parser.rs—pub use tanzim_parse::*;+Parsed(aPayloadpaired with its parsedLocatedValue)merger.rs—pub use tanzim_merge::*;(includes the rawMergedalias for merge implementors)Entries/EntryName/EntryNameRef(consumer map;root()/named()hideOption<String>keys), plus the pipeline's internalpub(crate)merge-tree helpers (leaves,root_merger,push_child,set_root_merger) andgroup_by_source
validator.rs—pub use tanzim_validate::*;value.rs—pub use tanzim_value::*;source.rs—pub use tanzim_source::*;entry.rs—Entry: one merged entry (contributing payloads + combined value)
config.rs — the single-configuration pipeline
- Typestate builder:
ConfigBuilder<State>whereStateisSourcesorPlan(sealedBuilderState).Config::builder()→ConfigBuilder<Sources>(simple-fold: exposeswith_defaults/with_value/with_source/add_source/with_source_merged/with_merger);Config::from_plan(plan)→ConfigBuilder<Plan>(carries amerger::plan::MergePlantree, no source builders). Mixing modes is a compile error — there is no runtimePlanConflict. Builders are infallible (bad source strings / serialize failures are deferred torun). There is nonew(). build()produces the runnableConfig; the builder'srun()/try_deserialize()are sugar forbuild().run()/build().try_deserialize().Config— load → parse → merge → unify → validate;run()returns one unifiedEntry,try_deserialize::<T>()returns oneT. Error type isconfig::Error(kept off the crate root).- Stage methods live behind
Config::stages() -> ConfigStages<'_>(load/parse/merge/unify/validate). with_default_loaders/set_default_loadersandwith_default_parsers/set_default_parsersappend/replace the feature-gated built-ins.- Sources + merger are stored as one
merger::plan::MergePlantree with amerger_setflag; the simple builders append/replace via themerger::{push_child, set_root_merger}helpers. unify()collapses all merge groups into one value using the configured merger (defaulting toLastWins).- Stored trait objects are
Box<dyn Load/Parse/Merge + Send + Sync>, soConfig/ConfigBuilderareSend + Sync.
pipeline.rs — the multi-configuration pipeline
PipelineBuilder<State>mirrorsConfigBuilder<State>(shares theSources/Planmarkers fromconfig). Construct withPipeline::builder()/Pipeline::from_plan(plan).Pipeline— load → parse → merge → validate (nounify);run()returnsEntries(Entries<Entry>),try_deserialize::<T>()returnsEntries<T>. Stages behindPipeline::stages() -> PipelineStages<'_>. Error type ispipeline::Error.with_root_schema/with_named_schema/with_schemas(Schemas)register per-entry validation schemas (Schemasis a struct with the same root/named insert helpers).- Same default loader/parser helpers as
Config.
Testing
No tests here — they belong in tests/, not src/.