Reads only the exact metadata prefix of an owned comment.
(body: &str)
| 70 | |
| 71 | /// Reads only the exact metadata prefix of an owned comment. |
| 72 | pub fn parse(body: &str) -> Result<Self> { |
| 73 | let encoded = body |
| 74 | .strip_prefix(&format!("{MARKER}\n{META_PREFIX}")) |
| 75 | .and_then(|tail| tail.split_once(" -->").map(|(metadata, _)| metadata)) |
| 76 | .ok_or_else(|| eyre::eyre!("owned marker has invalid metadata"))?; |
| 77 | let metadata: Self = serde_json::from_str(encoded)?; |
| 78 | metadata.validate()?; |
| 79 | Ok(metadata) |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | /// `GitHub` comment publisher with bounded requests and narrow comment ownership. |
no test coverage detected