id_effect
Effect<A, E = Never, R = HNil>: a lazy, Send effect over a typed capability list R, run on a
fiber runtime (Tokio executor by default), with layers, streams, schedules and coordination.
Tier: core (ADR 0010); kernel design A
(ADR 0011).
Quick start
use ;
;
>
let ok = next_port.provide.block_on;
assert_eq!;
assert!;
succeed/fail/sync/from_asyncbuild effects;map,flat_map,map_err,catch,zip,ensuringcombine them.effect!({ .. })is do-notation over an async body:~Capreads a capability,~exprbinds a sub-effect (widening its error),~(a, b)joins effects in parallel,?fails with aResult's error.effect_local!builds aLocalEffect(!Sendbodies).Ris an HList (caps!(A, B)=HCons<A, HCons<B, HNil>>). Provide it with.provide(v),.provide_env(hlist![..])or aLayer(.provide_layer(layer)); a missing capability is a compile error.- Run at the edge with
Effect::block_on, orRuntime::run(eff).awaitinside async code.
Cargo features: compute (default — the Compute Fabric substrate, adaptive Rayon bulk ops,
sysinfo telemetry), schema-serde, schema-regex (regex-backed schema::regex validator),
proptest (testing::property). --no-default-features drops rayon and sysinfo.
Algebraic type classes, persistent (im) collections and STM live in the maintenance-tier
id_effect_fp crate. Examples: examples/README.md.
Construct catalog (src/)
Every module's items are re-exported at the crate root (use id_effect::{Effect, Layer, Stream, …}).
| Module | What lives there |
|---|---|
kernel |
Effect, LocalEffect, constructors (succeed, fail, die, sync, suspend, from_async, sleep, yield_fiber), Ctx, the runloop, ensuring / masks / acquire_use_release, block_on edges, ExitKind |
capability |
typed R: HCons, HNil, hlist!, Selector / Plucker / Sculptor / Embed, need, provide*, narrow, DynEnv |
layer |
Layer<Out, E, In>: succeed, effect, scoped, acquire_release, merge, provide_to, provide_merge, fresh, launch |
runtime |
Runtime (global, run, block_on, fork), Executor, TokioExecutor, fibers (FiberHandle, FiberContext), FiberRef, run_fiber |
concurrency / par / race |
fork_all + Concurrency, all, for_each_par, zip_par, race, race_all, race_first, timeout |
scope |
Scope (finalizers, fork_in), Effect::scoped |
coordination |
Queue, Channel, Deferred, Latch, PubSub, Ref, SynchronizedRef, SubscriptionRef, Semaphore / Permit, Supervisor |
resource |
Pool, KeyedPool, Cache / CacheStats |
streaming |
Stream (pull, chunked), Sink, StreamSender / stream_from_channel*, backpressure, broadcast, windows, Chunk, Transducer |
scheduling |
Schedule (recurs, spaced, exponential, …) for Effect::retry / repeat; Duration, UtcDateTime, ZonedDateTime |
observability |
LogLevel, metrics (Metric, MetricRegistry), spans (with_span, SpanHook), the in-process tracing buffer (install_tracing_layer, snapshot_tracing, tracing_hook) |
request |
Request, RequestResolver (batching), request cache |
random / testing |
Random; the deterministic TestExecutor (virtual time), TestRandom |
compute |
the kernel's admission Fabric; with compute: ComputeFabric, AdmissionController, FabricGovernor, adaptive Rayon dispatch |
failure |
Cause, Exit, Defect, FiberId, Never, Or |
foundation |
Either, Pipe (+ pipe!), Predicate, identity / always / compose |
schema |
Schema, Unknown, ParseError(s), HasSchema (+ derive(Schema)), EffectData, Brand, Equal, Ordering, Redacted |
match_ |
Matcher, HasTag (+ match_effect!, #[effect_tagged]) |
macros |
effect!, effect_local!, caps!, pipe!, err! |
The 0.6 kernel (runtime capability DI with Env / ProviderSpec / run_with, run_blocking,
ThreadSleepRuntime, CancellationToken, TestClock, run_test) was removed in 0.7; see
docs/MIGRATION-0.7.md.