crate::ix!();
#[async_trait]
impl ReadFileString for CrateHandle {
async fn read_file_string(&self, path: &Path) -> Result<String, CrateError> {
let mut full_path = path.to_path_buf();
if !full_path.is_absolute() {
let crate_str = self.crate_path().to_string_lossy().to_string();
let path_str = full_path.to_string_lossy().to_string();
if path_str.starts_with(&crate_str) {
debug!("Path is already under crate_path: {}", path_str);
} else {
full_path = self.crate_path().join(path_str);
}
}
let content_result = fs::read_to_string(&full_path).await;
content_result.map_err(|io_err| CrateError::IoError {
io_error: Arc::new(io_err),
context: format!("Failed to read file: {}", full_path.display()),
})
}
}