Skip to main content

Crate id_effect

Crate id_effect 

Source
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).

§Cargo features

  • compute (default) — the Compute Fabric (compute): admission control, adaptive Rayon parallelism for bulk operations and sysinfo host telemetry. Without it, bulk operations run serially; rayon and sysinfo are not built.
  • schema-serde — serde_json::Value ↔ Unknown and 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 HList environment, need/provide*/narrow, and the runtime-checked DynEnv.
compute
Compute Fabric
concurrency
Structured concurrency on fibers: fork_all, Concurrency and Admission.
coordination
Fiber coordination primitives: Deferred (one-shot), Semaphore, Latch, Queue, Channel, PubSub, Ref, SynchronizedRef, SubscriptionRef and Supervisor. 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 and LocalEffect.
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 / launch and Effect::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 MetricRegistry with tagged snapshots, and the span / FiberRef hooks the otel crate builds on.
par
Parallel combinators on fibers: zip_par, all and for_each_par under a Concurrency policy.
parallelism
Execution policy for bulk data-parallel operations (Rayon).
pipe
pipe! — left-to-right application (see Pipe).
race
Racing and timeouts on fibers: Effect::race, race_all, Effect::race_first, Effect::timeout and Effect::timeout_fail.
random
The Random capability: next_u64, next_f64 in [0, 1), next_range and shuffle, on an internal xoshiro256** generator (no new dependency, Q13). The deterministic TestRandom (seeded, feed_u64s/feed_f64s) is exported from testing.
request
Request batching: Effect::request over a batched RequestResolver (Effect.ts Effect.request(req, resolver) / RequestResolver.makeBatched), with request caching scoped to a Layer or Scope.
resource
Managed resources on top of Scope: Cache, Pool and KeyedPool (Effect.ts Cache, Pool, KeyedPool).
runtime
Where effects run: the Executor trait and its tokio backend, fiber state and handles, fiber refs, and the Runtime edges.
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 type HCons<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 an id_effect::LocalEffect, whose body may hold !Send values. ~expr binds a LocalEffect or a Send Effect over a part of R.
err
Type-level error sum (“union”) using nested Or.
match_effect
Enum match helper — prefix variant patterns with EnumPath for exhaustiveness checking.
pipe
Apply functions left-to-right: pipe!(x, f, g) expands to g(f(x)).

Enums§

Ordering
An Ordering is 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, and EFFECT_TAGGED_TAG on the struct (see generated inherent associated const).

Derive Macros§

EffectData
Derive macro: structural [PartialEq], [Eq], and [Hash] for Effect.ts-style data types.
Optics
Derive field lenses and enum prisms for [id_effect_optics].
ProviderSpecDerive
Derive an inherent layer() (an id_effect::Layer providing the service) from #[provides(Service)]. Re-exported by id_effect as ProviderSpecDerive.
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).