Something went wrong. Try again.
An experimental alternative to Rust sans-io that enables the direct style
Something went wrong. Try again.
2.0 kB · 46 lines
Rust
at experiments
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647//! What a program is, and how a foreign host steps one.//!//! [`run::Run`] is the shape of a program: a `step` that is one turn of its//! loop, and a `run` that repeats it. A program implements `Run`; what its//! waits *do* is decided by whatever it is given to run against — a context,//! an outbox, a host — not here.//!//! This crate is copied verbatim (package name aside) into each experiment//! that has a driver; `hosts/check-sync.sh` keeps the copies honest.//!//! [`drive`] is for hosts that are not Rust. In Rust you hand a `Run` to an//! executor and it polls. A Java or Python host cannot poll a Rust future, so//! `drive` turns a `Run` into a *steppable* thing with sans-io's host API://! `start()` returns the effects recorded before the first wait; each//! `answer(token, value)` delivers one reply and returns the effects recorded//! before the next.//!//! ```text//! host Driver program//! start() ────────────▶ poll once ────────────────▶ ctx.write(..); ctx.read_line().await//! ◀── [Write, ReadLine(Token 1)]//! answer(Token 1, "bob") ▶ mail[1] = "bob"; poll once ▶ name = "bob"; …//! ◀── [Lookup("bob", Token 2)]//! ```//!//! Two drivers share that API — [`drive::local`] (`Rc`, thread-affine, no//! synchronisation) and [`drive::sync`] (`Arc`, `Send`, one lock) — and a//! context written against [`drive::Post`] runs on either. [`wire`] is what a//! host sees: the byte codec, the closed menu of reply values, and the traits//! an effect type implements to be shown across a boundary. `no_std` + `alloc`//! throughout; the `std` feature swaps `sync`'s spin lock for `std::sync::Mutex`.
#![no_std]
extern crate alloc;
#[cfg(any(feature = "std", test))]extern crate std;
mod lock;
pub mod drive;pub mod join;pub mod request;pub mod run;pub mod wire;