WaitHuman Rust Client
A Rust client library for WaitHuman - pause execution and request human input or confirmation on demand.
Features
- Async API: Built on tokio for efficient async I/O
- Type-safe: Leverages Rust's type system for compile-time safety
- Multiple answer formats: Support for free text and multiple choice questions
- Configurable timeouts: Optional timeout support for all requests
- Ergonomic API: Generic type parameters eliminate the need for
.to_string()calls
Installation
Add this to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["rt-multi-thread", "macros"] }
Quick Start
use WaitHuman;
async
API Methods
new_from_key(api_key)
Create a client with just an API key (uses default endpoint):
let client = new_from_key?;
new(config)
Create a client with custom configuration:
use WaitHumanConfig;
let client = new?;
ask_free_text(subject, body, options)
Ask an open-ended text question:
let answer = client
.ask_free_text
.await?;
ask_multiple_choice(subject, choices, body, options)
Ask a multiple-choice question:
let choice = client
.ask_multiple_choice
.await?;
ask(question, options)
Low-level method for full control:
use ;
let question = ConfirmationQuestion ;
let answer = client.ask.await?;
Timeouts
Configure request timeouts:
use AskOptions;
let answer = client
.ask_free_text
.await?;
Error Handling
The library uses Result<T, WaitHumanError> for error handling:
match client.ask_free_text.await
Error types include:
Timeout- Request exceeded timeoutNetworkError- Network connectivity issuesCreateFailed- Failed to create confirmationPollFailed- Failed to poll for answerUnexpectedAnswerType- Answer type mismatchInvalidSelectedIndex- Invalid choice indexInvalidResponse- Unexpected server response
Examples
Run the demo example:
License
This project is licensed under the MIT License - see the LICENSE file for details.