Expand description
§Gust Standard Library
A collection of reusable, production-ready Gust state machines that solve common distributed systems and application patterns.
Each machine is shipped as a .gu source string embedded at compile time.
You can feed these sources directly to the Gust compiler or include them
alongside your own .gu files.
§Available machines
| Machine | Constant | Description |
|---|---|---|
| CircuitBreaker | CIRCUIT_BREAKER | Protects calls to external services by tracking failures and opening the circuit when a threshold is reached. Transitions through Closed, Open, and HalfOpen states. |
| Retry | RETRY | Implements retry-with-backoff logic. Tracks attempt counts, computes exponential delays with jitter, and caps at a maximum delay. |
| Saga | SAGA | Orchestrates a sequence of distributed steps with automatic compensation (rollback) on failure, following the saga pattern. |
| RateLimiter | RATE_LIMITER | Token-bucket rate limiter that transitions between Available and Exhausted states based on remaining tokens. |
| HealthCheck | HEALTH_CHECK | Models service health with Healthy, Degraded, and Unhealthy states, tracking consecutive failures before transitioning. |
| RequestResponse | REQUEST_RESPONSE | Models an async request lifecycle with Pending, Completed, Failed, and TimedOut states. |
§Available types
| Type | Constant | Description |
|---|---|---|
| EngineFailure | ENGINE_FAILURE | Typed runtime/engine failure for workflow-style machines: UserError, SystemError, IntegrationError, Timeout, Cancelled. |
§Usage
Use all_sources to iterate over every standard-library source for
bulk compilation, or access individual constants directly:
let sources = gust_stdlib::all_sources();
assert_eq!(sources.len(), 7);
// Each entry is a (filename, source_code) pair
for (filename, source) in &sources {
println!("{filename}: {} bytes", source.len());
}Constants§
- CIRCUIT_
BREAKER - The Gust source for the CircuitBreaker machine.
- ENGINE_
FAILURE - The Gust source for the EngineFailure enum.
- HEALTH_
CHECK - The Gust source for the HealthCheck machine.
- RATE_
LIMITER - The Gust source for the RateLimiter machine.
- REQUEST_
RESPONSE - The Gust source for the RequestResponse machine.
- RETRY
- The Gust source for the Retry machine.
- SAGA
- The Gust source for the Saga machine.
Functions§
- all_
sources - Returns all standard library machine sources as an array of
(filename, source_code)pairs.