| Crates.io | wait-human |
| lib.rs | wait-human |
| version | 0.1.1 |
| created_at | 2026-01-05 17:02:50.268356+00 |
| updated_at | 2026-01-05 17:09:45.238454+00 |
| description | Rust client library for WaitHuman - pause execution and request human input on demand |
| homepage | https://waithuman.com |
| repository | https://github.com/wait-human/wait-human-client-rs |
| max_upload_size | |
| id | 2024251 |
| size | 67,671 |
A Rust client library for WaitHuman - pause execution and request human input or confirmation on demand.
.to_string() callsAdd this to your Cargo.toml:
[dependencies]
wait-human = "0.1"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
use wait_human::WaitHuman;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a new client
let client = WaitHuman::new_from_key("your-api-key")?;
// Ask a multiple choice question
let answer = client
.ask_multiple_choice(
"Send invoice?",
["yes, send", "no"],
Some("Customer asked for a 3-page website. is 500$ ok?"),
None,
)
.await?;
if answer == "yes, send" {
println!("Send!");
} else {
println!("wait...");
}
// Ask a free-text question
let feedback = client
.ask_free_text(
"User Feedback",
Some("Please explain why you rejected the invoice."),
None,
)
.await?;
println!("{}", feedback);
Ok(())
}
new_from_key(api_key)Create a client with just an API key (uses default endpoint):
let client = WaitHuman::new_from_key("your-api-key")?;
new(config)Create a client with custom configuration:
use wait_human::WaitHumanConfig;
let client = WaitHuman::new(
WaitHumanConfig::new("your-api-key")
.with_endpoint("https://custom.endpoint.com")
)?;
ask_free_text(subject, body, options)Ask an open-ended text question:
let answer = client
.ask_free_text(
"What's your favorite color?",
Some("Please be specific"),
None,
)
.await?;
ask_multiple_choice(subject, choices, body, options)Ask a multiple-choice question:
let choice = client
.ask_multiple_choice(
"Choose a framework",
["Actix", "Rocket", "Axum"],
None::<&str>,
None,
)
.await?;
ask(question, options)Low-level method for full control:
use wait_human::{ConfirmationQuestion, QuestionMethod, AnswerFormat};
let question = ConfirmationQuestion {
method: QuestionMethod::Push,
subject: "Approve deployment?".to_string(),
body: Some("Production environment".to_string()),
answer_format: AnswerFormat::FreeText,
};
let answer = client.ask(question, None).await?;
Configure request timeouts:
use wait_human::AskOptions;
let answer = client
.ask_free_text(
"Quick question",
None::<&str>,
Some(AskOptions {
timeout_seconds: Some(30),
}),
)
.await?;
The library uses Result<T, WaitHumanError> for error handling:
match client.ask_free_text("Question?", None::<&str>, None).await {
Ok(answer) => println!("Answer: {}", answer),
Err(e) => eprintln!("Error: {}", e),
}
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 responseRun the demo example:
cargo run --example demo
This project is licensed under the MIT License - see the LICENSE file for details.