pub struct Inputs { /* private fields */ }Expand description
Name-keyed storage for resolved inputs.
Each entry stores the resolved T value boxed as dyn Any + Send + Sync,
while its InputSourceKind metadata is tracked separately on the
internal entry. Lookups are by (name, T) — wrong-type lookups return
None rather than panicking.
Names are stored as Cow<'static, str> so both string literals and
runtime-generated names (e.g. config-driven command setups) work without
leaking memory.
Implementations§
Source§impl Inputs
impl Inputs
Sourcepub fn insert<T>(
&mut self,
name: impl Into<Cow<'static, str>>,
resolved: ResolvedInput<T>,
) -> Option<InputSourceKind>
pub fn insert<T>( &mut self, name: impl Into<Cow<'static, str>>, resolved: ResolvedInput<T>, ) -> Option<InputSourceKind>
Insert a resolved input under name.
name accepts anything convertible into Cow<'static, str> —
string literals ("body"), owned Strings, and explicit Cows
all work.
Returns the previous entry’s source kind if name was already present.
Sourcepub fn get<T: 'static>(&self, name: &str) -> Option<&T>
pub fn get<T: 'static>(&self, name: &str) -> Option<&T>
Get a reference to the value stored under name, if it exists and has
type T.
Returns None if no entry exists or the stored type does not match.
Sourcepub fn get_required<T: 'static>(&self, name: &str) -> Result<&T, MissingInput>
pub fn get_required<T: 'static>(&self, name: &str) -> Result<&T, MissingInput>
Get the value stored under name, returning a descriptive error if
missing or of the wrong type.
Sourcepub fn source_of(&self, name: &str) -> Option<InputSourceKind>
pub fn source_of(&self, name: &str) -> Option<InputSourceKind>
Get the InputSourceKind that provided name, if it exists.
Sourcepub fn iter_sources(&self) -> impl Iterator<Item = (&str, InputSourceKind)> + '_
pub fn iter_sources(&self) -> impl Iterator<Item = (&str, InputSourceKind)> + '_
Iterate over (name, source) pairs.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Inputs
impl !RefUnwindSafe for Inputs
impl Send for Inputs
impl Sync for Inputs
impl Unpin for Inputs
impl UnsafeUnpin for Inputs
impl !UnwindSafe for Inputs
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more