Parse a query plan from JSON.
(json: &str)
| 533 | |
| 534 | /// Parse a query plan from JSON. |
| 535 | pub fn parse_plan(json: &str) -> Result<QueryPlan, RepositoryError> { |
| 536 | let plan: QueryPlan = serde_json::from_str(json) |
| 537 | .map_err(|e| RepositoryError::Serialization(format!("Invalid query plan: {}", e)))?; |
| 538 | if plan.schema_version != 1 { |
| 539 | return Err(RepositoryError::Serialization( |
| 540 | "unsupported query plan schema version".into(), |
| 541 | )); |
| 542 | } |
| 543 | Ok(plan) |
| 544 | } |
| 545 | |
| 546 | #[cfg(test)] |
| 547 | mod tests { |
no outgoing calls