1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright 2026 1o1 Co. Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//! The single place this crate reads the process environment (spec F1.9).
//!
//! `std::env::vars()` panics *while iterating* if any entry's name or value is
//! not valid UTF-8 — which on Unix any parent process can arrange — so
//! collecting it made every entry point that inherits the environment abort on
//! an entry the config never mentions. Everything here goes through
//! [`std::env::vars_os`] instead, and what happens to an undecodable entry
//! depends on whether the caller asked for it:
//!
//! - [`vars`] — **substitution lookup** (F1.9a). Undecodable entries are
//! absent, so `${?VAR}` falls through to its default and `${VAR}` raises the
//! ordinary unresolved error. Never lossy or replacement-character text.
//! Nobody's working config changes meaning as a result: before this existed,
//! a single undecodable entry *anywhere* in the environment crashed the
//! parse regardless of which variables the document named, so the prior
//! behaviour for every affected user was an abort, not a working parse.
//! - [`entries`] — **bulk mount** (F1.9b). The caller named a whole namespace,
//! so `adapters::env` must be able to tell a decode failure from an absent
//! variable and refuse rather than hand back a subtree that looks complete
//! while the operator's setting is missing.
use OsString;
/// The process environment as UTF-8 pairs, skipping any entry whose name or
/// value is not valid UTF-8 (F1.9a). This is what substitution resolution
/// consumes, so a skipped entry is simply absent: `${?VAR}` falls through to
/// its default and `${VAR}` raises the ordinary unresolved error, rather than
/// resolving to lossy or replacement-character text.
///
/// Deliberately not written in terms of [`entries`]: that type carries the raw
/// name bytes a bulk mount needs for prefix matching, and only the adapter
/// wants them, so keeping the two apart avoids a feature-shaped struct.
pub
/// One process-environment entry, decoded where possible.
///
/// `name_bytes` is always present so a caller can prefix-match and name the
/// offender in a diagnostic even when the name itself is not UTF-8.
pub
/// Every entry in the process environment, decoded where possible (F1.9b).
pub