Load an agent's receipt, if one exists.
(agent: &str)
| 130 | |
| 131 | /// Load an agent's receipt, if one exists. |
| 132 | pub fn load(agent: &str) -> AgentResult<Option<Self>> { |
| 133 | let path = receipt_path(agent)?; |
| 134 | if !path.exists() { |
| 135 | return Ok(None); |
| 136 | } |
| 137 | let text = std::fs::read_to_string(&path)?; |
| 138 | let receipt: Receipt = |
| 139 | serde_json::from_str(&text).map_err(|e| AgentError::Integration { |
| 140 | agent: agent.to_string(), |
| 141 | reason: format!("corrupt receipt at {}: {}", path.display(), e), |
| 142 | })?; |
| 143 | Ok(Some(receipt)) |
| 144 | } |
| 145 | |
| 146 | /// Delete the receipt file. Returns `true` if one existed. |
| 147 | pub fn remove(agent: &str) -> AgentResult<bool> { |
nothing calls this directly
no test coverage detected