pub enum ParamsSpecFieldless<T>{
Stored,
Value {
value: T,
},
InMemory,
MappingFn(Box<dyn MappingFn<Output = T>>),
}Expand description
How to populate a field’s value in an item’s params.
The MappingFn variant’s mapping function is None when deserialized, as
it is impossible to determine the underlying F and U type parameters for
the backing MappingFnImpl.
For deserialization:
-
A
ParamsSpecsTypeRegis constructed, and deserialization functions are registered fromItemIdtoParamsSpecFieldlessDe<T, F, U>, whereFandUare derived from theValueSpecprovided by the user. -
value_specs.yamlis deserialized using that type registry. -
Each
ParamsSpecFieldlessDe<T>is mapped into aParamsSpecFieldless<T>, and subsequentlyAnySpecRtBoxedto be passed around in aCmdCtx. -
These
AnySpecRtBoxeds are downcasted back toParamsSpecFieldless<T>when resolving values for item params and params partials.
Variants§
Stored
Loads a stored value spec.
The value used is determined by the value spec that was
last stored in the params_specs_file. This means it
could be loaded as a Value(T) during context build().
This variant may be provided when defining a command context builder. However, this variant is never serialized, but whichever value was first stored is re-loaded then re-serialized.
If no value spec was previously serialized, then the command context build will return an error.
Value
Uses the provided value.
The value used is whatever is passed in to the command context builder.
Fields
value: TThe value to use.
InMemory
Uses a value loaded from resources at runtime.
The value may have been provided by workspace params, or inserted by a predecessor at runtime.
MappingFn(Box<dyn MappingFn<Output = T>>)
Uses a mapped value loaded from resources at runtime.
The value may have been provided by workspace params, or inserted by a predecessor at runtime, and is mapped by the given function.
This is serialized as MappingFn with a string value. For
deserialization, there is no actual backing function, so
the user must provide the MappingFn in subsequent command
context builds.
Implementations§
Source§impl<T> ParamsSpecFieldless<T>
impl<T> ParamsSpecFieldless<T>
Source§impl<T> ParamsSpecFieldless<T>where
T: ParamsFieldless<Spec = ParamsSpecFieldless<T>> + Clone + Debug + Send + Sync + 'static,
T::Partial: From<T>,
impl<T> ParamsSpecFieldless<T>where
T: ParamsFieldless<Spec = ParamsSpecFieldless<T>> + Clone + Debug + Send + Sync + 'static,
T::Partial: From<T>,
pub fn resolve( &self, resources: &Resources<SetUp>, value_resolution_ctx: &mut ValueResolutionCtx, ) -> Result<T, ParamsResolveError>
pub fn resolve_partial( &self, resources: &Resources<SetUp>, value_resolution_ctx: &mut ValueResolutionCtx, ) -> Result<T::Partial, ParamsResolveError>
Trait Implementations§
Source§impl<T> AnySpecRt for ParamsSpecFieldless<T>where
T: ParamsFieldless<Spec = ParamsSpecFieldless<T>> + Clone + Debug + Serialize + Send + Sync + 'static,
impl<T> AnySpecRt for ParamsSpecFieldless<T>where
T: ParamsFieldless<Spec = ParamsSpecFieldless<T>> + Clone + Debug + Serialize + Send + Sync + 'static,
Source§impl<T> Clone for ParamsSpecFieldless<T>
impl<T> Clone for ParamsSpecFieldless<T>
Source§fn clone(&self) -> ParamsSpecFieldless<T>
fn clone(&self) -> ParamsSpecFieldless<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T> Debug for ParamsSpecFieldless<T>
impl<T> Debug for ParamsSpecFieldless<T>
Source§impl<'de, T> Deserialize<'de> for ParamsSpecFieldless<T>
impl<'de, T> Deserialize<'de> for ParamsSpecFieldless<T>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<T> From<ParamsSpecFieldlessDe<T>> for ParamsSpecFieldless<T>
impl<T> From<ParamsSpecFieldlessDe<T>> for ParamsSpecFieldless<T>
Source§fn from(value_spec_de: ParamsSpecFieldlessDe<T>) -> Self
fn from(value_spec_de: ParamsSpecFieldlessDe<T>) -> Self
Source§impl<T> From<T> for ParamsSpecFieldless<T>
impl<T> From<T> for ParamsSpecFieldless<T>
Source§impl<T> Serialize for ParamsSpecFieldless<T>
impl<T> Serialize for ParamsSpecFieldless<T>
Source§impl<T> ValueSpecRt for ParamsSpecFieldless<T>
impl<T> ValueSpecRt for ParamsSpecFieldless<T>
Source§fn resolve(
&self,
resources: &Resources<SetUp>,
value_resolution_ctx: &mut ValueResolutionCtx,
) -> Result<T, ParamsResolveError>
fn resolve( &self, resources: &Resources<SetUp>, value_resolution_ctx: &mut ValueResolutionCtx, ) -> Result<T, ParamsResolveError>
Source§fn try_resolve(
&self,
resources: &Resources<SetUp>,
value_resolution_ctx: &mut ValueResolutionCtx,
) -> Result<Option<T>, ParamsResolveError>
fn try_resolve( &self, resources: &Resources<SetUp>, value_resolution_ctx: &mut ValueResolutionCtx, ) -> Result<Option<T>, ParamsResolveError>
None if it is not
present.Auto Trait Implementations§
impl<T> Freeze for ParamsSpecFieldless<T>where
T: Freeze,
impl<T> !RefUnwindSafe for ParamsSpecFieldless<T>
impl<T> Send for ParamsSpecFieldless<T>
impl<T> Sync for ParamsSpecFieldless<T>
impl<T> Unpin for ParamsSpecFieldless<T>where
T: Unpin,
impl<T> !UnwindSafe for ParamsSpecFieldless<T>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DataType for T
impl<T> DataType for T
fn type_name(&self) -> TypeNameLit
fn type_id_inner(&self) -> TypeId
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.