diff options
Diffstat (limited to 'src/fs.rs')
-rwxr-xr-x | src/fs.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/fs.rs b/src/fs.rs index e47889b..8266053 100755 --- a/src/fs.rs +++ b/src/fs.rs @@ -1,6 +1,5 @@ use camino::{Utf8Path, Utf8PathBuf}; -use core::fmt; -use std::{fmt, io, ops::Deref, str::FromStr}; +use std::{fmt, io, ops::Deref, path::Display, str::FromStr}; use crate::RuntimeError; @@ -105,6 +104,20 @@ pub struct PathResolution { pub is_dirfile: bool, } +impl Deref for PathResolution { + type Target = Utf8Path; + + fn deref(&self) -> &Self::Target { + self.filepath.as_path() + } +} + +impl fmt::Display for PathResolution { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", *self) + } +} + #[derive(Clone, Debug)] pub struct Filesystem { webroot: Utf8PathBuf, @@ -213,6 +226,8 @@ impl Filesystem { } pub async fn read_to_string<P: AsRef<Utf8Path>>(path: P) -> Result<String, RuntimeError> { + tracing::trace!("read_to_string {}", path.as_ref()); + tokio::fs::read_to_string(path.as_ref()) .await .map_err(|ioe| RuntimeError::from_io(ioe, path.as_ref().to_owned())) |