pub struct Resolution { /* private fields */ }Expand description
Everything an invocation resolved to, with provenance and any problems found.
Implementations§
Source§impl Resolution
impl Resolution
Sourcepub fn raw(&self, key: &str) -> Option<&str>
pub fn raw(&self, key: &str) -> Option<&str>
The raw text resolved for key, if anything supplied one.
Sourcepub fn source(&self, key: &str) -> Option<Source>
pub fn source(&self, key: &str) -> Option<Source>
Where the value for key came from.
Examples found in repository?
examples/consumer.rs (line 185)
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}Sourcepub fn positionals(&self) -> &[String]
pub fn positionals(&self) -> &[String]
Arguments that were not flags, in order, plus anything after --.
Trait Implementations§
Source§impl Clone for Resolution
impl Clone for Resolution
Source§impl Debug for Resolution
impl Debug for Resolution
Auto Trait Implementations§
impl Forget for Resolution
impl Freeze for Resolution
impl Move for Resolution
impl RefUnwindSafe for Resolution
impl Send for Resolution
impl Sync for Resolution
impl Unpin for Resolution
impl UnsafeUnpin for Resolution
impl UnwindSafe for Resolution
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more