Skip to main content

Crate graphrefly_operators

Crate graphrefly_operators 

Source
Expand description

Built-in operator node types for GraphReFly.

Operators in this crate are specialized node types implemented directly against the Core protocol — they are not “user fns wrapped in nodes.” A map operator’s plumbing (dirty propagation, equals dedup, batch handling) runs entirely in Rust; only the user-supplied (T) -> U callback crosses the FFI boundary on each fire.

§Status (Slice C-3, 2026-05-06)

Transform module: map, filter, scan, reduce, distinct_until_changed, pairwise (Slice C-1, D009–D019). Combine module: combine_latest, merge, with_latest_from (Slice C-2, D020–D023). Flow module: take, skip, take_while, last, last_with_default + first, find, element_at sugar (Slice C-3, D024–D029). Per-operator state lives behind a generic OperatorScratch slot on NodeRecord (D026 — replaces the typed operator_state field used by Slices C-1 / C-2).

§Module layout (planned)

  • transform — map, filter, scan, reduce, distinctUntilChanged, pairwise (✅ Slice C-1)
  • combine — combine, merge, withLatestFrom (✅ Slice C-2)
  • flow — take, skip, takeWhile, last + first/find/element_at sugar (✅ Slice C-3)
  • temporal — throttle, debounce, sample
  • switching — switchMap, mergeMap, concatMap
  • gating — valve, gate, budgetGate, policyGate
  • resilience — retry, circuitBreaker, timeout, fallback, rateLimiter, tokenBucket

§Layering

This crate depends on graphrefly-core only (per the user-direction constraint that operators do not depend on graphrefly-graph). Operator factories accept &Core directly. User callbacks travel through the OperatorBinding super-trait of BindingBoundary, which the binding crate (e.g., a TestOperatorBinding for tests, the napi-rs / pyo3 bindings in production) implements.

Re-exports§

pub use binding::OperatorBinding;
pub use combine::combine as combine_latest;
pub use combine::merge;
pub use combine::with_latest_from;
pub use combine::MergeRegistration;
pub use error::OperatorFactoryError;
pub use flow::element_at;
pub use flow::find;
pub use flow::first;
pub use flow::last;
pub use flow::last_with_default;
pub use flow::skip;
pub use flow::take;
pub use flow::take_while;
pub use flow::FlowRegistration;
pub use higher_order::concat_map;
pub use higher_order::exhaust_map;
pub use higher_order::merge_map;
pub use higher_order::merge_map_with_concurrency;
pub use higher_order::switch_map;
pub use higher_order::HigherOrderBinding;
pub use higher_order::ProjectFn;
pub use ops_impl::concat;
pub use ops_impl::race;
pub use ops_impl::take_until;
pub use ops_impl::zip;
pub use producer::default_producer_deactivate;
pub use producer::ProducerBinding;
pub use producer::ProducerBuildFn;
pub use producer::ProducerCtx;
pub use producer::ProducerNodeState;
pub use producer::ProducerStorage;
pub use transform::distinct_until_changed;
pub use transform::filter;
pub use transform::map;
pub use transform::pairwise;
pub use transform::reduce;
pub use transform::scan;
pub use transform::OperatorRegistration;

Modules§

binding
OperatorBinding — closure-registration helper trait for the operators crate. Sub-trait of BindingBoundary (D015).
combine
Multi-dep combinator operators (Slice C-2, D020).
error
Operator factory errors (Slice H /qa F7, 2026-05-07).
flow
Flow operators (Slice C-3, D024) — count / predicate / terminal-aware gates that bound which DATA reaches the downstream output.
higher_order
Higher-order operators (Slice E, D044) — operators whose project fn returns an inner NodeId for each outer DATA. Mirrors TS legacy extra/operators/higher-order.ts (switchMap / exhaustMap / concatMap / mergeMap).
ops_impl
Concrete implementations of the four subscription-managed combinators (zip / concat / race / takeUntil). Built on the super::producer::ProducerCtx substrate.
producer
Producer-shape operator substrate (Slice D-ops, Commit 2).
transform
Transform operators (R5.7) — element-wise mappings and folds.