pub trait RunnablePick<I: Send + Sync + 'static>: Sized {
// Required methods
fn pick<K>(
self,
keys: impl IntoIterator<Item = K>,
) -> RunnableSequence<I, HashMap<String, Value>>
where K: Into<String>;
fn pluck(self, key: impl Into<String>) -> RunnableSequence<I, Value>;
}Expand description
Extracts keys / values from a Runnable whose output is a HashMap<String, Value>.
Required Methods§
Sourcefn pick<K>(
self,
keys: impl IntoIterator<Item = K>,
) -> RunnableSequence<I, HashMap<String, Value>>
fn pick<K>( self, keys: impl IntoIterator<Item = K>, ) -> RunnableSequence<I, HashMap<String, Value>>
Keep only the given keys of the dict output, dropping everything else.
Missing keys are omitted from the result (Python raises KeyError;
Rust’s map semantics make omission the closest safe equivalent).
§Example
ⓘ
let parallel = RunnableParallel::<String>::new()
.with("a", RunnableLambda::new_sync(|s: String| s.len() as i64))
.with("b", RunnableLambda::new_sync(|s: String| s.to_uppercase()));
let picked = parallel.pick(["a"]); // output: {"a": N}Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".