From 5cb14d290ae58342125400a4f902ac46ee06521a Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Sun, 10 Aug 2025 00:48:39 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Mejora=20fu?= =?UTF-8?q?nci=C3=B3n=20`from=5Fdir`=20por=20compatibilidad=20(#3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.cillero.es/manuelcillero/pagetop/pulls/3 Co-authored-by: Manuel Cillero Co-committed-by: Manuel Cillero --- helpers/pagetop-build/src/lib.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/helpers/pagetop-build/src/lib.rs b/helpers/pagetop-build/src/lib.rs index b360377..bb32606 100644 --- a/helpers/pagetop-build/src/lib.rs +++ b/helpers/pagetop-build/src/lib.rs @@ -129,8 +129,7 @@ use std::fs::{create_dir_all, remove_dir_all, File}; use std::io::Write; use std::path::Path; -/// Prepara un conjunto de recursos para ser incluidos en el binario del proyecto utilizando -/// [static_files](https://docs.rs/static-files/). +/// Prepara un conjunto de recursos para ser incluidos en el binario del proyecto. pub struct StaticFilesBundle { resource_dir: ResourceDir, } @@ -163,8 +162,19 @@ impl StaticFilesBundle { /// .build() /// } /// ``` - pub fn from_dir(dir: impl AsRef, filter: Option bool>) -> Self { - let mut resource_dir = resource_dir(dir.as_ref()); + pub fn from_dir

(dir: P, filter: Option bool>) -> Self + where + P: AsRef, + { + let dir_path = dir.as_ref(); + let dir_str = dir_path.to_str().unwrap_or_else(|| { + panic!( + "Resource directory path is not valid UTF-8: {}", + dir_path.display() + ); + }); + + let mut resource_dir = resource_dir(dir_str); // Aplica el filtro si está definido. if let Some(f) = filter {