pub struct FeatureContext<'a> {
pub id: String,
pub feature_type: String,
pub params: &'a Value,
pub persistent: &'a Value,
pub env: &'a Env,
pub scene: &'a SceneMap,
pub later_inputs: Option<&'a [String]>,
}Expand description
The read-only context handed to each feature’s execute. Features resolve
their reference_selection params against scene and read numeric params via
FeatureContext::number (which evaluates expression strings against env).
Fields§
§id: String§feature_type: String§params: &'a Value§persistent: &'a ValueThe feature’s persistentData (round-tripped from the saved part file).
The SKETCH feature reads its sketch + basis here (the scene-computed
plane frame stays caller-side per directive §1 and is marshaled in via this).
env: &'a Env§scene: &'a SceneMap§later_inputs: Option<&'a [String]>Some when the history walk knows nothing that follows this feature
references the solids it consumes, by face name or by persistent data
(lane X row 11b): the boolean feature may then re-seat an operand’s
cylinder seam before imprint. None (the walk cannot tell, or a later
feature might reference them, or a direct execute_feature call)
never re-seats.
Implementations§
Source§impl<'a> FeatureContext<'a>
impl<'a> FeatureContext<'a>
Sourcepub fn param(&self, key: &str) -> Option<&Value>
pub fn param(&self, key: &str) -> Option<&Value>
The raw param value (an object field of inputParams), if present.
Sourcepub fn number(&self, key: &str) -> Result<f64, String>
pub fn number(&self, key: &str) -> Result<f64, String>
A numeric param: a JSON number passes through; a JSON string is evaluated as an expression against the shared env; anything else is an error. This is how a feature declares which of its params are numeric (the engine has no per-feature schema).
Sourcepub fn string(&self, key: &str) -> Option<String>
pub fn string(&self, key: &str) -> Option<String>
A string param (read verbatim — never expression-evaluated; used for ids
and reference_selection names). Contract surface for fan-out features;
the two implemented features read the id via ctx.id directly.
Sourcepub fn fail(&self, refusal: impl Into<FeatureRefusal>) -> FeatureResult
pub fn fail(&self, refusal: impl Into<FeatureRefusal>) -> FeatureResult
A convenience FeatureResult::refuse carrying this feature’s id +
type: text from a stringly producer, or a typed KernelRefusal.