pub struct ScriptedResponder { /* private fields */ }Expand description
A position-based scripted responder.
Built from a queue of PromptResponse values. Each call to
respond pops the next response and
validates that its kind is compatible with the prompt the source
actually asked for; if not, it panics with a message that names the
position, the prompt kind, and the response kind.
This makes wizard-reorder bugs surface as test failures at the offending step rather than as silent wrong-data assertions later.
use standout_input::{ScriptedResponder, PromptResponse};
let responder = ScriptedResponder::new([
PromptResponse::text("buy milk"),
PromptResponse::Bool(true),
PromptResponse::Choice(2),
]);Implementations§
Source§impl ScriptedResponder
impl ScriptedResponder
Sourcepub fn new(responses: impl IntoIterator<Item = PromptResponse>) -> Self
pub fn new(responses: impl IntoIterator<Item = PromptResponse>) -> Self
Create a scripted responder from a sequence of responses.
Trait Implementations§
Source§impl Debug for ScriptedResponder
impl Debug for ScriptedResponder
Source§impl PromptResponder for ScriptedResponder
impl PromptResponder for ScriptedResponder
Source§fn respond(&self, ctx: PromptContext<'_>) -> PromptResponse
fn respond(&self, ctx: PromptContext<'_>) -> PromptResponse
Produce a response for the given prompt.
Auto Trait Implementations§
impl !Freeze for ScriptedResponder
impl RefUnwindSafe for ScriptedResponder
impl Send for ScriptedResponder
impl Sync for ScriptedResponder
impl Unpin for ScriptedResponder
impl UnsafeUnpin for ScriptedResponder
impl UnwindSafe for ScriptedResponder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more