Expand description
Effect<A, E = Never, R = HNil>: a lazy, Send effect over a typed capability list R, run
on a fiber runtime (design A, ADR 0011).
Effect— the core value:succeed,fail,sync,from_async,map/flat_map/map_err/catch, run at the edge withEffect::block_onor awaited withRuntime::run.LocalEffectholds!Sendvalues.effect!— do-notation over an async body:~Capreads a capability,~exprbinds a sub-effect,~(a, b)joins in parallel;caps!spellsR.- Typed
R— an HList of capabilities (HCons,HNil,need,provide,provide_env), built fromLayers (merge,provide_to, scoped layers). - Fibers —
fork/join/ interrupt,FiberRef,Scope,all/zip_par/race, theFabricadmission scheduler, deterministicTestExecutor. - Libraries —
Stream/Sink,Schedule(Effect::retry/repeat), coordination (Queue,Channel,Deferred,Semaphore,PubSub,Ref, …), resources (Pool,Cache), metrics and spans (MetricRegistry,with_span), request batching and caching. - Kernel-independent —
failure(Cause,Exit,Defect,Or),foundation(Pipe,pipe!),schema,scheduling(Duration,UtcDateTime),match_.
§Cargo features
compute(default) — the Compute Fabric (compute): admission control, adaptive Rayon parallelism for bulk operations andsysinfohost telemetry. Without it, bulk operations run serially;rayonandsysinfoare not built.schema-serde—serde_json::Value↔Unknownand JSON Schema helpers.
Algebraic type classes, persistent (im) collections and STM live in the maintenance-tier
id_effect_fp crate.
Re-exports§
pub use crate::match_::HasTag;pub use crate::match_::Matcher;pub use failure::Cause;pub use failure::Defect;pub use failure::Exit;pub use failure::FiberId;pub use failure::Never;pub use failure::Or;pub use foundation::func::always;pub use foundation::func::compose;pub use foundation::func::identity;pub use foundation::piping::Pipe;pub use foundation::predicate::Predicate;pub use schema::brand::Brand;pub use schema::data::DataError;pub use schema::data::DataStruct;pub use schema::data::DataTuple;pub use schema::data::EffectData as EffectDataTrait;pub use schema::equal::EffectHash;pub use schema::equal::Equal;pub use schema::order::DynOrder;pub use schema::order::ordering;pub use schema::HasSchema;pub use schema::ParseError;pub use schema::ParseErrors;pub use schema::Redacted;pub use schema::Schema;pub use schema::Unknown;pub use capability::*;pub use compute::*;pub use concurrency::*;pub use coordination::*;pub use kernel::*;pub use layer::*;pub use observability::*;pub use par::*;pub use race::*;pub use random::*;pub use request::*;pub use resource::*;pub use runtime::*;pub use scheduling::*;pub use scope::*;pub use streaming::*;pub use testing::*;
Modules§
- capability
- Typed R: the
HListenvironment,need/provide*/narrow, and the runtime-checkedDynEnv. - compute
- Compute Fabric
- concurrency
- Structured concurrency on fibers:
fork_all,ConcurrencyandAdmission. - coordination
- Fiber coordination primitives:
Deferred(one-shot),Semaphore,Latch,Queue,Channel,PubSub,Ref,SynchronizedRef,SubscriptionRefandSupervisor. Effect.ts semantics throughout. - err
err!macro.- failure
- Stratum 4 — Failure Algebra
- foundation
- Stratum 0: Foundations — the small set of pure helpers the core runtime is built on.
- kernel
- The effect kernel:
Effect, its constructors and combinators, the erased runloop, typed binds, fork/resource combinators, the run edges andLocalEffect. - layer
Layer<Out, E, In>: lazy, memoised recipes for environment values.succeed/effect/from_effect/scoped/acquire_release/fresh/build/build_scoped/merge/provide_to/provide_merge/launchandEffect::provide_layer.- macros
- The macro surface, re-exported at the crate root.
- match_
- Runtime value matcher — mirrors Effect.ts-style
Match/ pattern routing. - observability
- Observability: atomic metrics (counter, gauge, histogram, bounded summary, frequency), the
MetricRegistrywith tagged snapshots, and the span /FiberRefhooks the otel crate builds on. - par
- Parallel combinators on fibers:
zip_par,allandfor_each_parunder aConcurrencypolicy. - parallelism
- Execution policy for bulk data-parallel operations (Rayon).
- pipe
pipe!— left-to-right application (seePipe).- race
- Racing and timeouts on fibers:
Effect::race,race_all,Effect::race_first,Effect::timeoutandEffect::timeout_fail. - random
- The
Randomcapability:next_u64,next_f64in[0, 1),next_rangeandshuffle, on an internal xoshiro256** generator (no new dependency, Q13). The deterministicTestRandom(seeded,feed_u64s/feed_f64s) is exported fromtesting. - request
- Request batching:
Effect::requestover a batchedRequestResolver(Effect.tsEffect.request(req, resolver)/RequestResolver.makeBatched), with request caching scoped to aLayerorScope. - resource
- Managed resources on top of
Scope:Cache,PoolandKeyedPool(Effect.tsCache,Pool,KeyedPool). - runtime
- Where effects run: the
Executortrait and its tokio backend, fiber state and handles, fiber refs, and theRuntimeedges. - scheduling
- Scheduling & time.
- schema
- Stratum 13 — Data & Schema
- scope
- Scopes: finalizer registries that outlive a single effect, and forking into them.
- streaming
- Streams: a pull-based, chunked
Stream, its consumers (Sink), producer-fed streams (stream_from_channel/StreamSender), and the stream-, sink- and fold-backed channels (StreamChannel,FoldChannel,Channel::to_stream/to_sink). - testing
- Test support for the 0.7 kernel: the deterministic
TestExecutor.
Macros§
- brand
- Define a named branded newtype with standard derives.
- caps
caps!(A, B, C)is the environment typeHCons<A, HCons<B, HCons<C, HNil>>>. A capability listed twice (compared by token) is one compile error at the repeat; the de-duplicated list is still emitted so no further errors cascade.- effect
- Do-notation over an async body, building an
id_effect::Effect. - effect_
local - Like
effect!, but builds anid_effect::LocalEffect, whose body may hold!Sendvalues.~exprbinds aLocalEffector aSendEffectover a part ofR. - err
- Type-level error sum (“union”) using nested
Or. - match_
effect - Enum match helper — prefix variant patterns with
EnumPathfor exhaustiveness checking. - pipe
- Apply functions left-to-right:
pipe!(x, f, g)expands tog(f(x)).
Enums§
- Ordering
- An
Orderingis the result of a comparison between two values.
Type Aliases§
- Either
Either<R, L>—Ok(R)is Right (success),Err(L)is Left (failure/alternative).
Attribute Macros§
- effect_
tagged - Injects
pub _tag: &'static str, an [id_effect::match_::HasTag] impl, andEFFECT_TAGGED_TAGon the struct (see generated inherent associated const).
Derive Macros§
- Effect
Data - Derive macro: structural [
PartialEq], [Eq], and [Hash] for Effect.ts-style data types. - Optics
- Derive field lenses and enum prisms for [
id_effect_optics]. - Provider
Spec Derive - Derive an inherent
layer()(anid_effect::Layerproviding the service) from#[provides(Service)]. Re-exported byid_effectasProviderSpecDerive. - Schema
- Derive an inherent
schema()constructor and an [id_effect::schema::HasSchema] impl for a struct with named fields (JSON-shaped [id_effect::schema::Unknown] wire).