about summary refs log tree commit diff
path: root/src/fs.rs
diff options
context:
space:
mode:
authorgennyble <gen@nyble.dev>2024-12-18 00:28:11 -0600
committergennyble <gen@nyble.dev>2024-12-18 00:28:11 -0600
commit5401674797d35d8f95a37a62b2858a3673bf1261 (patch)
tree40afd6b72cacbe436013bfeba3d57d3d17eb632f /src/fs.rs
parent958aac71e9130b4f61e2e829dafe1b3ee16caa66 (diff)
downloadawake-main.tar.gz
awake-main.zip
Stack overflow? Cat, help HEAD main
Diffstat (limited to 'src/fs.rs')
-rwxr-xr-xsrc/fs.rs19
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()))