Extract the canonical `memoryKind`, accepting legacy `kind`/`type` fields.
(frontmatter_json: &str)
| 681 | |
| 682 | /// Extract the canonical `memoryKind`, accepting legacy `kind`/`type` fields. |
| 683 | fn frontmatter_kind(frontmatter_json: &str) -> String { |
| 684 | serde_json::from_str::<serde_json::Value>(frontmatter_json) |
| 685 | .ok() |
| 686 | .and_then(|v| { |
| 687 | ["memoryKind", "kind", "type"] |
| 688 | .iter() |
| 689 | .find_map(|key| v.get(key).and_then(|value| value.as_str())) |
| 690 | .map(String::from) |
| 691 | }) |
| 692 | .unwrap_or_else(|| "project".to_string()) |
| 693 | } |
| 694 | |
| 695 | fn frontmatter_status(frontmatter_json: &str) -> Option<String> { |
| 696 | let value = serde_json::from_str::<serde_json::Value>(frontmatter_json).ok()?; |
no test coverage detected