Crate sans

Crate sans 

Source
Expand description

§Sans: Composable Coroutine-Based Programming

Build composable computations that can yield intermediate values and be driven to completion by external input.

§Core Traits

  • Sans<I, O>: Stateful computations that process input and yield values
  • InitSans<I, O>: Computations that provide initial output before processing input

§Key Features

  • Composable: Chain coroutines together with .chain()
  • Transformable: Use .map_input(), .map_yield(), .map_done()
  • Async Support: Both sync and async execution with handle() and handle_async()

§Example

use sans::prelude::*;

// Build a pipeline that yields initial value, processes input, then finishes
let pipeline = init_once(10, |x: i32| x * 2)  // Yields 10, then multiplies input by 2
    .chain(once(|x: i32| x + 1));              // Adds 1 to input, then completes

// Drive the pipeline with responses to each yield
let result = handle(pipeline, |output| output + 5);

§Module Organization

This library is organized by capability:

§Common Functions

Building Coroutines:

Execution:

Modules§

build
Building coroutines from scratch
compose
Combining coroutines together
concurrent
Run multiple coroutines concurrently
iter
Iterator adapters for Sans coroutines with unit input.
poll
Polling for both Sans and InitSans
prelude
Commonly used imports
result
Result combinators for error handling in coroutines.
run
Running coroutines to completion
sequential
Run coroutines one after another

Structs§

PoisonError

Enums§

Step
Result of a computation step, either yielding a value to continue or completing with a final value.

Traits§

InitSans
Computations that yield an initial value before processing input.
Sans
Core trait for stateful computations that process input and yield intermediate values.