MCPcopy Create free account
hub / github.com/Stranger6667/css-inline / retrieve_from_path

Method retrieve_from_path

css-inline/src/resolver.rs:54–66  ·  view source on GitHub ↗

Retrieve a stylesheet from the local filesystem. # Errors Any filesystem-related error.

(&self, path: &str)

Source from the content-addressed store, hash-verified

52 ///
53 /// Any filesystem-related error.
54 fn retrieve_from_path(&self, path: &str) -> Result<String> {
55 let path = path.trim_start_matches("file://");
56 std::fs::read_to_string(path).map_err(|error| match error.kind() {
57 ErrorKind::NotFound => InlineError::MissingStyleSheet {
58 path: path.to_string(),
59 },
60 #[cfg(target_family = "wasm")]
61 ErrorKind::Unsupported => self.unsupported(&format!(
62 "Loading local files is not supported on WASM: {path}"
63 )),
64 _ => InlineError::IO(error),
65 })
66 }
67 /// Return the "Unsupported" kind of error.
68 fn unsupported(&self, reason: &str) -> InlineError {
69 std::io::Error::new(ErrorKind::Unsupported, reason).into()

Callers 1

retrieveMethod · 0.80

Implementers 4

resolver.rscss-inline/src/resolver.rs
test_cachecss-inline/tests/test_inlining.rs
test_resolver_without_implementationcss-inline/tests/test_inlining.rs
try_frombindings/javascript/src/options.rs

Calls 1

unsupportedMethod · 0.80

Tested by

no test coverage detected