|
1 | | -use std::any::Any; |
| 1 | +use std::any::{Any, TypeId}; |
2 | 2 | use std::borrow::Cow; |
3 | 3 | use std::path::PathBuf; |
4 | 4 | use std::pin::Pin; |
@@ -243,7 +243,7 @@ pub struct Arg { |
243 | 243 |
|
244 | 244 | pub struct Pipe { |
245 | 245 | _context: Arc<Context>, |
246 | | - modules: HashMap<String, Arc<dyn CommandRunner + Send + Sync>>, |
| 246 | + modules: IndexMap<String, Arc<dyn CommandRunner + Send + Sync>>, |
247 | 247 | pub(crate) defn: Arc<PipelineDefinition>, |
248 | 248 | } |
249 | 249 |
|
@@ -318,7 +318,7 @@ impl PipelineHandle { |
318 | 318 | impl Pipe { |
319 | 319 | #[inline] |
320 | 320 | pub fn new(context: Arc<Context>, defn: Arc<PipelineDefinition>) -> Result<Self, Error> { |
321 | | - let mut cache: HashMap<String, Arc<dyn CommandRunner + Send + Sync>> = HashMap::new(); |
| 321 | + let mut cache: IndexMap<String, Arc<dyn CommandRunner + Send + Sync>> = IndexMap::new(); |
322 | 322 |
|
323 | 323 | for (key, command) in defn.commands.iter() { |
324 | 324 | if cache.contains_key(&**key) { |
@@ -352,11 +352,14 @@ impl Pipe { |
352 | 352 | }) |
353 | 353 | } |
354 | 354 |
|
355 | | - pub fn command<T: CommandRunner>(&self, key: &str) -> Option<&Arc<T>> { |
| 355 | + pub fn command<T: CommandRunner>(&self, key: &str) -> Option<&T> { |
356 | 356 | self.modules |
357 | 357 | .get(key) |
358 | | - .map(|x| x as &dyn Any) |
359 | | - .and_then(|x| x.downcast_ref::<Arc<T>>()) |
| 358 | + .map(|x| &**x as &(dyn Any + Send + Sync)) |
| 359 | + .and_then(|x| { |
| 360 | + println!("Command TypeId: {:?}", x.type_id()); |
| 361 | + x.downcast_ref::<T>() |
| 362 | + }) |
360 | 363 | } |
361 | 364 |
|
362 | 365 | pub async fn create_stream( |
|
0 commit comments