Skip to main content

Crate gust_stdlib

Crate gust_stdlib 

Source
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

MachineConstantDescription
CircuitBreakerCIRCUIT_BREAKERProtects calls to external services by tracking failures and opening the circuit when a threshold is reached. Transitions through Closed, Open, and HalfOpen states.
RetryRETRYImplements retry-with-backoff logic. Tracks attempt counts, computes exponential delays with jitter, and caps at a maximum delay.
SagaSAGAOrchestrates a sequence of distributed steps with automatic compensation (rollback) on failure, following the saga pattern.
RateLimiterRATE_LIMITERToken-bucket rate limiter that transitions between Available and Exhausted states based on remaining tokens.
HealthCheckHEALTH_CHECKModels service health with Healthy, Degraded, and Unhealthy states, tracking consecutive failures before transitioning.
RequestResponseREQUEST_RESPONSEModels an async request lifecycle with Pending, Completed, Failed, and TimedOut states.

§Available types

TypeConstantDescription
EngineFailureENGINE_FAILURETyped 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.