Parse a JSON array of parts into a Vec , skipping invalid entries.
(value: &serde_json::Value)
| 84 | impl PartInput { |
| 85 | /// Parse a JSON array of parts into a Vec<PartInput>, skipping invalid entries. |
| 86 | pub fn parse_array(value: &serde_json::Value) -> Vec<PartInput> { |
| 87 | match value.as_array() { |
| 88 | Some(arr) => arr |
| 89 | .iter() |
| 90 | .filter_map(|v| serde_json::from_value(v.clone()).ok()) |
| 91 | .collect(), |
| 92 | None => Vec::new(), |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | struct PromptState { |