| 65 | } |
| 66 | |
| 67 | pub fn put(&self, artifact: ToolArtifact) { |
| 68 | let mut state = self.inner.write().unwrap(); |
| 69 | let artifact_uri = artifact.artifact_uri.clone(); |
| 70 | if let Some(existing) = state.artifacts.remove(&artifact_uri) { |
| 71 | state.total_bytes = state.total_bytes.saturating_sub(existing.content.len()); |
| 72 | state.insertion_order.retain(|uri| uri != &artifact_uri); |
| 73 | } |
| 74 | |
| 75 | state.total_bytes += artifact.content.len(); |
| 76 | state.insertion_order.push_back(artifact_uri.clone()); |
| 77 | state.artifacts.insert(artifact_uri, artifact); |
| 78 | |
| 79 | self.enforce_limits(&mut state); |
| 80 | } |
| 81 | |
| 82 | pub fn get(&self, artifact_uri: &str) -> Option<ToolArtifact> { |
| 83 | self.inner |