Retrieve a stylesheet from a network or local filesystem location. # Errors Any network or filesystem related error, or an error during response parsing.
(&self, location: &str)
| 9 | /// |
| 10 | /// Any network or filesystem related error, or an error during response parsing. |
| 11 | fn retrieve(&self, location: &str) -> Result<String> { |
| 12 | if location.starts_with("https") || location.starts_with("http") { |
| 13 | #[cfg(feature = "http")] |
| 14 | { |
| 15 | self.retrieve_from_url(location) |
| 16 | } |
| 17 | |
| 18 | #[cfg(not(feature = "http"))] |
| 19 | { |
| 20 | Err(std::io::Error::new( |
| 21 | ErrorKind::Unsupported, |
| 22 | "Loading external URLs requires the `http` feature", |
| 23 | ) |
| 24 | .into()) |
| 25 | } |
| 26 | } else { |
| 27 | #[cfg(feature = "file")] |
| 28 | { |
| 29 | self.retrieve_from_path(location) |
| 30 | } |
| 31 | #[cfg(not(feature = "file"))] |
| 32 | { |
| 33 | Err(std::io::Error::new( |
| 34 | ErrorKind::Unsupported, |
| 35 | "Loading local files requires the `file` feature", |
| 36 | ) |
| 37 | .into()) |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | /// Retrieve a stylesheet from a network location. |
| 42 | /// |
| 43 | /// # Errors |
no test coverage detected