MCPcopy Create free account
hub / github.com/PRQL/prql / fetch

Method fetch

prqlc/prqlc/src/error_message.rs:227–237  ·  view source on GitHub ↗
(&mut self, id: &PathBuf)

Source from the content-addressed store, hash-verified

225impl Cache<PathBuf> for FileTreeCache<'_> {
226 type Storage = String;
227 fn fetch(&mut self, id: &PathBuf) -> Result<&Source<Self::Storage>, impl fmt::Debug> {
228 let file_contents = match self.file_tree.sources.get(id) {
229 Some(v) => v,
230 None => return Err(format!("Unknown file `{id:?}`")),
231 };
232
233 Ok(self
234 .cache
235 .entry(id.clone())
236 .or_insert_with(|| Source::from(file_contents.to_string())))
237 }
238
239 fn display<'b>(&self, id: &'b PathBuf) -> Option<impl fmt::Display + 'b> {
240 id.as_os_str().to_str().map(str::to_string)

Callers 1

composedMethod · 0.80

Calls 1

getMethod · 0.45

Tested by

no test coverage detected