Newer
Older
use std::{fs, io::ErrorKind, path::Path};
pub struct Style {
pub content: String,
}
impl Style {
pub fn load_if_exists<P: AsRef<Path>>(path: P) -> anyhow::Result<Option<Self>> {
let content = match fs::read_to_string(path) {
Ok(x) => x,
Err(e) => {
if e.kind() == ErrorKind::NotFound {
return Ok(None);
}
return Err(e.into());
}
};
Ok(Some(Self { content }))
}
}