pub fn document(source: &str, records: &[Record]) -> ValueExpand description
Wrap a project’s records in the standard envelope.
source identifies the emitting project and revision (e.g. "myapp@a1b2c3d")
and should be stamped by the build, not typed by hand.
Examples found in repository?
examples/consumer.rs (line 192)
175fn main() {
176 // One call: parse argv+env, lint the result, fail on errors.
177 let resolved = Contract::parse_and_lint(OnProblems::FailOnError);
178
179 // Read typed values as often as needed — the resolution is cheap to clone.
180 let level = Contract::LOG_LEVEL.get_from_or_default(&resolved);
181 let hdr = Contract::HDR.get_from_or_default(&resolved);
182
183 eprintln!(
184 "log_level = {level:?} (from {:?}), hdr = {hdr:?} (from {:?})",
185 resolved.source("log_level"),
186 resolved.source("hdr")
187 );
188
189 // Emit the machine-readable contract — what `argenv lint` reads.
190 println!(
191 "{}",
192 serde_json::to_string_pretty(&document("myapp@a1b2c3d", &Contract::records())).unwrap()
193 );
194}