rusty_harness/lib.rs
1//! `rusty_harness` — a tiny agent harness that's blazing fast.
2//!
3//! The crate is async by default and runtime-agnostic: public APIs are `async fn`s that
4//! return plain futures, so you drive them with whichever executor you already use.
5//! Anything that needs a runtime (spawning, timers) goes through the [`Runtime`] trait,
6//! implemented behind the `rt-tokio` and `rt-wasm` features.
7//!
8//! ```
9//! # tokio::runtime::Builder::new_current_thread().build().unwrap().block_on(async {
10//! let greeting = rusty_harness::hello().await;
11//! assert_eq!(greeting, "Hello from rusty-harness!");
12//! # });
13//! ```
14#![warn(missing_docs)]
15
16pub mod runtime;
17
18pub use runtime::{MaybeSend, Runtime};
19
20/// Returns a greeting from the harness.
21///
22/// ```
23/// # tokio::runtime::Builder::new_current_thread().build().unwrap().block_on(async {
24/// assert_eq!(rusty_harness::hello().await, "Hello from rusty-harness!");
25/// # });
26/// ```
27#[allow(
28 clippy::unused_async,
29 reason = "the public API is async by design; real APIs will await"
30)]
31pub async fn hello() -> String {
32 "Hello from rusty-harness!".to_owned()
33}
34
35#[cfg(all(test, feature = "rt-tokio"))]
36mod tests {
37 use super::hello;
38
39 #[tokio::test]
40 async fn hello_greets() {
41 assert_eq!(hello().await, "Hello from rusty-harness!");
42 }
43}