aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/io/buffer_io.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-05 01:50:16 +0900
committernsfisis <nsfisis@gmail.com>2026-06-05 01:50:16 +0900
commitbbb2f9454b6580fcbd337ced61b5a1888d52ce8d (patch)
tree45563449df57f63ae4a4d010a3e8e6007518c35b /crates/shirabe/src/io/buffer_io.rs
parentadf14510b00929aaee85ccb8dedf9164878a0164 (diff)
downloadphp-shirabe-bbb2f9454b6580fcbd337ced61b5a1888d52ce8d.tar.gz
php-shirabe-bbb2f9454b6580fcbd337ced61b5a1888d52ce8d.tar.zst
php-shirabe-bbb2f9454b6580fcbd337ced61b5a1888d52ce8d.zip
refactor(io): model ask_and_validate validators with anyhow::Result
PHP's askAndValidate throws when a validator rejects input. Change the IOInterface validator callback and return type to anyhow::Result so the call sites can return Err instead of panic, faithfully modeling the throw semantics already supported by the Question layer. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/io/buffer_io.rs')
-rw-r--r--crates/shirabe/src/io/buffer_io.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/shirabe/src/io/buffer_io.rs b/crates/shirabe/src/io/buffer_io.rs
index 291b64b..836fd95 100644
--- a/crates/shirabe/src/io/buffer_io.rs
+++ b/crates/shirabe/src/io/buffer_io.rs
@@ -175,10 +175,10 @@ impl crate::io::IOInterfaceImmutable for BufferIO {
fn ask_and_validate(
&self,
question: String,
- validator: Box<dyn Fn(PhpMixed) -> PhpMixed>,
+ validator: Box<dyn Fn(PhpMixed) -> anyhow::Result<PhpMixed>>,
attempts: Option<i64>,
default: PhpMixed,
- ) -> PhpMixed {
+ ) -> anyhow::Result<PhpMixed> {
self.inner
.ask_and_validate(question, validator, attempts, default)
}